Skip to content

Commit bb73c23

Browse files
Merge pull request #6973 from douzzer/20231115-misc-fixits
20231115-misc-fixits
2 parents 3576db8 + 263973b commit bb73c23

8 files changed

Lines changed: 86 additions & 31 deletions

File tree

configure.ac

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ then
720720
# this set is also enabled by enable-all-crypto:
721721
test "$enable_atomicuser" = "" && enable_atomicuser=yes
722722
test "$enable_aesgcm" = "" && enable_aesgcm=yes
723-
test "$enable_aesgcm_stream" = "" && enable_aesgcm_stream=yes
723+
test "$enable_aesgcm_stream" = "" && test "$enable_aesgcm" = "yes" && enable_aesgcm_stream=yes
724724
test "$enable_aesccm" = "" && enable_aesccm=yes
725725
test "$enable_aesctr" = "" && enable_aesctr=yes
726726
test "$enable_aeseax" = "" && enable_aeseax=yes
@@ -788,7 +788,6 @@ then
788788
test "$enable_session_ticket" = "" && enable_session_ticket=yes
789789
test "$enable_earlydata" = "" && enable_earlydata=yes
790790
test "$enable_ech" = "" && enable_ech=yes
791-
test "$enable_quic" = "" && enable_quic=yes
792791

793792
if test "$ENABLED_32BIT" != "yes"
794793
then
@@ -799,13 +798,14 @@ then
799798
if test "$ENABLED_LINUXKM_DEFAULTS" != "yes"
800799
then
801800
test "$enable_compkey" = "" && enable_compkey=yes
801+
test "$enable_quic" = "" && enable_quic=yes
802802
AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_IO -DHAVE_IO_TIMEOUT"
803803
fi
804804

805805
# sp-math is incompatible with opensslextra, ECC custom curves, and DSA.
806806
if test "$ENABLED_SP_MATH" = "no"
807807
then
808-
test "$enable_dsa" = "" && enable_dsa=yes
808+
test "$enable_dsa" = "" && test "$enable_sha" != "no" && enable_dsa=yes
809809
test "$enable_ecccustcurves" = "" && enable_ecccustcurves=yes
810810
test "$enable_brainpool" = "" && enable_brainpool=yes
811811
test "$enable_srp" = "" && enable_srp=yes
@@ -908,7 +908,7 @@ if test "$ENABLED_ALL_CRYPT" = "yes"
908908
then
909909
test "$enable_atomicuser" = "" && enable_atomicuser=yes
910910
test "$enable_aesgcm" = "" && enable_aesgcm=yes
911-
test "$enable_aesgcm_stream" = "" && enable_aesgcm_stream=yes
911+
test "$enable_aesgcm_stream" = "" && test "$enable_aesgcm" = "yes" && enable_aesgcm_stream=yes
912912
test "$enable_aesccm" = "" && enable_aesccm=yes
913913
test "$enable_aesctr" = "" && enable_aesctr=yes
914914
test "$enable_aeseax" = "" && enable_aeseax=yes
@@ -974,7 +974,7 @@ then
974974

975975
if test "$ENABLED_SP_MATH" = "no"
976976
then
977-
test "$enable_dsa" = "" && enable_dsa=yes
977+
test "$enable_dsa" = "" && test "$enable_sha" != "no" && enable_dsa=yes
978978
test "$enable_ecccustcurves" = "" && enable_ecccustcurves=yes
979979
test "$enable_brainpool" = "" && enable_brainpool=yes
980980
test "$enable_srp" = "" && enable_srp=yes
@@ -1476,6 +1476,10 @@ then
14761476
then
14771477
AC_MSG_ERROR([TLS 1.3 is disabled - necessary for QUIC])
14781478
fi
1479+
if test "$enable_aesgcm" = "no"
1480+
then
1481+
AC_MSG_ERROR([AES-GCM is disabled - necessary for QUIC])
1482+
fi
14791483
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_QUIC"
14801484
# QUIC proto handlers need app_data at WOLFSSL*
14811485
AM_CFLAGS="$AM_CFLAGS -DHAVE_EX_DATA"
@@ -3581,7 +3585,7 @@ AC_ARG_ENABLE([dsa],
35813585
[ ENABLED_DSA=no ]
35823586
)
35833587

3584-
if test "$enable_dsa" = ""
3588+
if test "$enable_dsa" = "" && test "$enable_sha" != "no"
35853589
then
35863590
if (test "$ENABLED_OPENSSH" = "yes" && test "x$ENABLED_FIPS" = "xno") || test "$ENABLED_OPENVPN" = "yes" || test "$ENABLED_NGINX" = "yes" || test "$ENABLED_WPAS" = "yes" || test "$ENABLED_QT" = "yes" || test "$ENABLED_BIND" = "yes" || test "$ENABLED_LIBSSH2" = "yes" || test "$ENABLED_NTP" = "yes"
35873591
then
@@ -9721,8 +9725,11 @@ echo " * Secure Renegotiation: $ENABLED_SECURE_RENEGOTIATION"
97219725
echo " * Fallback SCSV: $ENABLED_FALLBACK_SCSV"
97229726
echo " * Keying Material Exporter: $ENABLED_KEYING_MATERIAL"
97239727
echo " * All TLS Extensions: $ENABLED_TLSX"
9724-
echo " * PKCS#7: $ENABLED_PKCS7"
97259728
echo " * S/MIME: $ENABLED_SMIME"
9729+
echo " * PKCS#7: $ENABLED_PKCS7"
9730+
echo " * PKCS#8: $ENABLED_PKCS8"
9731+
echo " * PKCS#11: $ENABLED_PKCS11"
9732+
echo " * PKCS#12: $ENABLED_PKCS12"
97269733
echo " * wolfSSH: $ENABLED_WOLFSSH"
97279734
echo " * wolfEngine: $ENABLED_WOLFENGINE"
97289735
echo " * wolfTPM: $ENABLED_WOLFTPM"
@@ -9741,9 +9748,6 @@ echo " * User Crypto: $ENABLED_USER_CRYPTO"
97419748
echo " * Fast RSA: $ENABLED_FAST_RSA"
97429749
echo " * Asynchronous Crypto: $ENABLED_ASYNCCRYPT"
97439750
echo " * Asynchronous Crypto (sim): $ENABLED_ASYNCCRYPT_SW"
9744-
echo " * PKCS#8: $ENABLED_PKCS8"
9745-
echo " * PKCS#11: $ENABLED_PKCS11"
9746-
echo " * PKCS#12: $ENABLED_PKCS12"
97479751
echo " * Cavium Nitrox: $ENABLED_CAVIUM"
97489752
echo " * Cavium Octeon (Sync): $ENABLED_OCTEON_SYNC"
97499753
echo " * Intel Quick Assist: $ENABLED_INTEL_QA"

src/internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13219,9 +13219,11 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type)
1321913219

1322013220
len = wolfSSL_i2d_X509_NAME_canon(issuer, &pbuf);
1322113221
if (len > 0) {
13222-
#ifndef NO_SHA
13222+
#if defined(NO_SHA) && !defined(NO_SHA256)
13223+
retHash = wc_Sha256Hash((const byte*)pbuf, len, dgt);
13224+
#elif !defined(NO_SHA)
1322313225
retHash = wc_ShaHash((const byte*)pbuf, len, dgt);
13224-
#endif
13226+
#endif
1322513227
if (retHash == 0) {
1322613228
/* 4 bytes in little endian as unsigned long */
1322713229
hash = (((unsigned long)dgt[3] << 24) |

src/wolfio.c

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,11 +2489,18 @@ int MicriumSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
24892489
/* Micrium DTLS Generate Cookie callback
24902490
* return : number of bytes copied into buf, or error
24912491
*/
2492+
#if defined(NO_SHA) && !defined(NO_SHA256)
2493+
#define MICRIUM_COOKIE_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
2494+
#elif !defined(NO_SHA)
2495+
#define MICRIUM_COOKIE_DIGEST_SIZE WC_SHA_DIGEST_SIZE
2496+
#else
2497+
#error Must enable either SHA-1 or SHA256 (or both) for Micrium.
2498+
#endif
24922499
int MicriumGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx)
24932500
{
24942501
NET_SOCK_ADDR peer;
24952502
NET_SOCK_ADDR_LEN peerSz = sizeof(peer);
2496-
byte digest[WC_SHA_DIGEST_SIZE];
2503+
byte digest[MICRIUM_COOKIE_DIGEST_SIZE];
24972504
int ret = 0;
24982505

24992506
(void)ctx;
@@ -2505,12 +2512,16 @@ int MicriumGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx)
25052512
return GEN_COOKIE_E;
25062513
}
25072514

2515+
#if defined(NO_SHA) && !defined(NO_SHA256)
2516+
ret = wc_Sha256Hash((byte*)&peer, peerSz, digest);
2517+
#else
25082518
ret = wc_ShaHash((byte*)&peer, peerSz, digest);
2519+
#endif
25092520
if (ret != 0)
25102521
return ret;
25112522

2512-
if (sz > WC_SHA_DIGEST_SIZE)
2513-
sz = WC_SHA_DIGEST_SIZE;
2523+
if (sz > MICRIUM_COOKIE_DIGEST_SIZE)
2524+
sz = MICRIUM_COOKIE_DIGEST_SIZE;
25142525
XMEMCPY(buf, digest, sz);
25152526

25162527
return sz;
@@ -2804,20 +2815,31 @@ int uIPReceive(WOLFSSL *ssl, char *buf, int sz, void *_ctx)
28042815
/* uIP DTLS Generate Cookie callback
28052816
* return : number of bytes copied into buf, or error
28062817
*/
2818+
#if defined(NO_SHA) && !defined(NO_SHA256)
2819+
#define UIP_COOKIE_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
2820+
#elif !defined(NO_SHA)
2821+
#define UIP_COOKIE_DIGEST_SIZE WC_SHA_DIGEST_SIZE
2822+
#else
2823+
#error Must enable either SHA-1 or SHA256 (or both) for uIP.
2824+
#endif
28072825
int uIPGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *_ctx)
28082826
{
28092827
uip_wolfssl_ctx *ctx = (uip_wolfssl_ctx *)_ctx;
28102828
byte token[32];
2811-
byte digest[WC_SHA_DIGEST_SIZE];
2829+
byte digest[UIP_COOKIE_DIGEST_SIZE];
28122830
int ret = 0;
28132831
XMEMSET(token, 0, sizeof(token));
28142832
XMEMCPY(token, &ctx->peer_addr, sizeof(uip_ipaddr_t));
28152833
XMEMCPY(token + sizeof(uip_ipaddr_t), &ctx->peer_port, sizeof(word16));
2834+
#if defined(NO_SHA) && !defined(NO_SHA256)
2835+
ret = wc_Sha256Hash(token, sizeof(uip_ipaddr_t) + sizeof(word16), digest);
2836+
#else
28162837
ret = wc_ShaHash(token, sizeof(uip_ipaddr_t) + sizeof(word16), digest);
2838+
#endif
28172839
if (ret != 0)
28182840
return ret;
2819-
if (sz > WC_SHA_DIGEST_SIZE)
2820-
sz = WC_SHA_DIGEST_SIZE;
2841+
if (sz > UIP_COOKIE_DIGEST_SIZE)
2842+
sz = UIP_COOKIE_DIGEST_SIZE;
28212843
XMEMCPY(buf, digest, sz);
28222844
return sz;
28232845
}
@@ -2881,25 +2903,36 @@ int GNRC_ReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *_ctx)
28812903
* return : number of bytes copied into buf, or error
28822904
*/
28832905
#define GNRC_MAX_TOKEN_SIZE (32)
2906+
#if defined(NO_SHA) && !defined(NO_SHA256)
2907+
#define GNRC_COOKIE_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
2908+
#elif !defined(NO_SHA)
2909+
#define GNRC_COOKIE_DIGEST_SIZE WC_SHA_DIGEST_SIZE
2910+
#else
2911+
#error Must enable either SHA-1 or SHA256 (or both) for GNRC.
2912+
#endif
28842913
int GNRC_GenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *_ctx)
28852914
{
28862915
sock_tls_t *ctx = (sock_tls_t *)_ctx;
28872916
if (!ctx)
28882917
return WOLFSSL_CBIO_ERR_GENERAL;
28892918
byte token[GNRC_MAX_TOKEN_SIZE];
2890-
byte digest[WC_SHA_DIGEST_SIZE];
2919+
byte digest[GNRC_COOKIE_DIGEST_SIZE];
28912920
int ret = 0;
28922921
size_t token_size = sizeof(sock_udp_ep_t);
28932922
(void)ssl;
28942923
if (token_size > GNRC_MAX_TOKEN_SIZE)
28952924
token_size = GNRC_MAX_TOKEN_SIZE;
28962925
XMEMSET(token, 0, GNRC_MAX_TOKEN_SIZE);
28972926
XMEMCPY(token, &ctx->peer_addr, token_size);
2927+
#if defined(NO_SHA) && !defined(NO_SHA256)
2928+
ret = wc_Sha256Hash(token, token_size, digest);
2929+
#else
28982930
ret = wc_ShaHash(token, token_size, digest);
2931+
#endif
28992932
if (ret != 0)
29002933
return ret;
2901-
if (sz > WC_SHA_DIGEST_SIZE)
2902-
sz = WC_SHA_DIGEST_SIZE;
2934+
if (sz > GNRC_COOKIE_DIGEST_SIZE)
2935+
sz = GNRC_COOKIE_DIGEST_SIZE;
29032936
XMEMCPY(buf, digest, sz);
29042937
return sz;
29052938
}

tests/api.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,7 +3196,7 @@ static int test_wolfSSL_CertManagerCRL(void)
31963196
static int test_wolfSSL_CertManagerCheckOCSPResponse(void)
31973197
{
31983198
EXPECT_DECLS;
3199-
#if defined(HAVE_OCSP) && !defined(NO_RSA)
3199+
#if defined(HAVE_OCSP) && !defined(NO_RSA) && !defined(NO_SHA)
32003200
/* Need one of these for wolfSSL_OCSP_REQUEST_new. */
32013201
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \
32023202
defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_APACHE_HTTPD) || \
@@ -3516,7 +3516,8 @@ static int test_wolfSSL_CertManagerCheckOCSPResponse(void)
35163516
static int test_wolfSSL_CheckOCSPResponse(void)
35173517
{
35183518
EXPECT_DECLS;
3519-
#if defined(HAVE_OCSP) && !defined(NO_RSA) && defined(OPENSSL_ALL)
3519+
#if defined(HAVE_OCSP) && !defined(NO_RSA) && !defined(NO_SHA) && \
3520+
defined(OPENSSL_ALL)
35203521
const char* responseFile = "./certs/ocsp/test-response.der";
35213522
const char* responseMultiFile = "./certs/ocsp/test-multi-response.der";
35223523
const char* responseNoInternFile =

wolfcrypt/src/aes.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,11 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
859859
#endif
860860

861861
#elif defined(WOLFSSL_KCAPI_AES)
862-
/* Only CBC and GCM that are in wolfcrypt/src/port/kcapi/kcapi_aes.c */
862+
/* Only CBC and GCM are in wolfcrypt/src/port/kcapi/kcapi_aes.c */
863863
#if defined(WOLFSSL_AES_COUNTER) || defined(HAVE_AESCCM) || \
864864
defined(WOLFSSL_CMAC) || defined(WOLFSSL_AES_OFB) || \
865865
defined(WOLFSSL_AES_CFB) || defined(HAVE_AES_ECB) || \
866-
defined(WOLFSSL_AES_DIRECT) || \
866+
defined(WOLFSSL_AES_DIRECT) || defined(WOLFSSL_AES_XTS) || \
867867
(defined(HAVE_AES_CBC) && defined(WOLFSSL_NO_KCAPI_AES_CBC))
868868

869869
#define NEED_AES_TABLES
@@ -5460,8 +5460,12 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
54605460
#else
54615461
while (blocks--) {
54625462
int ret;
5463+
#ifdef WOLFSSL_AESNI
5464+
ret = wc_AesDecrypt(aes, in, out);
5465+
#else
54635466
XMEMCPY(aes->tmp, in, AES_BLOCK_SIZE);
54645467
ret = wc_AesDecrypt(aes, (byte*)aes->tmp, out);
5468+
#endif
54655469
if (ret != 0)
54665470
return ret;
54675471
xorbuf(out, (byte*)aes->reg, AES_BLOCK_SIZE);

wolfcrypt/src/wc_port.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,7 +2922,7 @@ time_t mynewt_time(time_t* timer)
29222922
#endif /* WOLFSSL_APACHE_MYNEWT */
29232923

29242924
#if defined(WOLFSSL_GMTIME)
2925-
struct tm* gmtime(const time_t* timer)
2925+
struct tm* gmtime_r(const time_t* timer, struct tm *ret)
29262926
{
29272927
#define YEAR0 1900
29282928
#define EPOCH_YEAR 1970
@@ -2936,8 +2936,6 @@ struct tm* gmtime(const time_t* timer)
29362936
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
29372937
};
29382938

2939-
static struct tm st_time;
2940-
struct tm* ret = &st_time;
29412939
time_t secs = *timer;
29422940
unsigned long dayclock, dayno;
29432941
int year = EPOCH_YEAR;
@@ -2971,6 +2969,12 @@ struct tm* gmtime(const time_t* timer)
29712969

29722970
return ret;
29732971
}
2972+
2973+
struct tm* gmtime(const time_t* timer) {
2974+
static struct tm st_time;
2975+
return gmtime_r(timer, &st_time);
2976+
}
2977+
29742978
#endif /* WOLFSSL_GMTIME */
29752979

29762980

wolfcrypt/test/test.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858

5959
#ifdef HAVE_STACK_SIZE_VERBOSE
6060
#ifdef WOLFSSL_TEST_MAX_RELATIVE_STACK_BYTES
61-
static ssize_t max_relative_stack = WOLFSSL_TEST_MAX_RELATIVE_STACK_BYTES;
61+
static WC_MAYBE_UNUSED ssize_t max_relative_stack =
62+
WOLFSSL_TEST_MAX_RELATIVE_STACK_BYTES;
6263
#else
63-
static ssize_t max_relative_stack = -1;
64+
static WC_MAYBE_UNUSED ssize_t max_relative_stack = -1;
6465
#endif
6566
#endif
6667

wolfssl/wolfcrypt/wc_port.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,11 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
10631063
#define XTIME(tl) time((tl))
10641064
#endif
10651065
#endif
1066+
1067+
#if defined(WOLFSSL_GMTIME) && !defined(HAVE_GMTIME_R)
1068+
#define HAVE_GMTIME_R
1069+
#endif
1070+
10661071
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
10671072
/* Always use gmtime_r if available. */
10681073
#if defined(HAVE_GMTIME_S)
@@ -1128,8 +1133,9 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
11281133
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
11291134
#elif defined(WOLFSSL_GMTIME)
11301135
struct tm* gmtime(const time_t* timer);
1136+
struct tm* gmtime_r(const time_t* timer, struct tm *ret);
11311137
#endif
1132-
#endif /* NO_ASN_TIME */
1138+
#endif /* !NO_ASN_TIME */
11331139

11341140

11351141
#ifndef WOLFSSL_LEANPSK

0 commit comments

Comments
 (0)