Skip to content

Commit 0b8930f

Browse files
committed
Fixes from regression testing
CRL APIs not usable when NO_ASN_TIME defined. WOLFSSL_TLS13 needs to be defined with HAVE_ECH. When session ticket encrypted with CBC, must be a multiple of block size. Fix test define protection. Fix ML-DSA protection of reduction functions. Need !NO_RSA with WC_RSA_PSS. Connection ID is not a DTLS 1.3 only extension.
1 parent 3540d89 commit 0b8930f

8 files changed

Lines changed: 49 additions & 19 deletions

File tree

src/crl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,7 @@ int StoreCRL(WOLFSSL_CRL* crl, const char* file, int type)
23262326
}
23272327
#endif /* NO_FILESYSTEM */
23282328

2329-
#if defined(OPENSSL_EXTRA)
2329+
#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME)
23302330
/* Create a new empty CRL object for generation.
23312331
* Version is set to 2 by default. Use wolfSSL_X509_CRL_set_version() to
23322332
* change it.
@@ -2601,6 +2601,8 @@ static int GetCrlSignBufSz(int tbsSz, int sigType, RsaKey* rsaKey,
26012601
if (tbsSz <= 0)
26022602
return BAD_FUNC_ARG;
26032603

2604+
(void)rsaKey;
2605+
(void)eccKey;
26042606
#ifndef NO_RSA
26052607
if (rsaKey != NULL) {
26062608
sigSz = wc_RsaEncryptSize(rsaKey);
@@ -2666,8 +2668,8 @@ int wolfSSL_X509_CRL_sign(WOLFSSL_X509_CRL* crl, WOLFSSL_EVP_PKEY* pkey,
26662668
}
26672669

26682670
/* Determine signature type from digest and key type */
2669-
#ifndef NO_RSA
26702671
if (ret == WOLFSSL_SUCCESS) {
2672+
#ifndef NO_RSA
26712673
if (pkey->type == WC_EVP_PKEY_RSA) {
26722674
if (md == wolfSSL_EVP_sha256()) {
26732675
sigType = CTC_SHA256wRSA;

src/internal.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,6 +3159,9 @@ static void FreeCiphersSide(Ciphers *cipher, void* heap)
31593159
XFREE(cipher->hmac, heap, DYNAMIC_TYPE_CIPHER);
31603160
cipher->hmac = NULL;
31613161
#endif
3162+
3163+
(void)cipher;
3164+
(void)heap;
31623165
}
31633166

31643167
/* Free ciphers */
@@ -8619,7 +8622,7 @@ void wolfSSL_ResourceFree(WOLFSSL* ssl)
86198622
}
86208623
FreeSuites(ssl);
86218624
FreeHandshakeHashes(ssl);
8622-
#ifdef HAVE_ECH
8625+
#if defined(WOLFSSL_TLS13) && defined(HAVE_ECH)
86238626
/* try to free the ech hashes in case we errored out */
86248627
ssl->hsHashes = ssl->hsHashesEch;
86258628
FreeHandshakeHashes(ssl);
@@ -39088,6 +39091,9 @@ static int AddPSKtoPreMasterSecret(WOLFSSL* ssl)
3908839091
#if defined(OPENSSL_ALL) && defined(KEEP_PEER_CERT) && \
3908939092
!defined(NO_CERT_IN_TICKET)
3909039093
internalTicketSz += peerCertSz;
39094+
#endif
39095+
#ifdef WOLFSSL_TICKET_ENC_CBC_HMAC
39096+
internalTicketSz = (internalTicketSz + 15) & (~0xf);
3909139097
#endif
3909239098
/* MAC is placed after the encrypted data */
3909339099
mac = et->enc_ticket + WOLFSSL_TICKET_ENC_SZ;

src/tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13647,7 +13647,7 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
1364713647
ato16(readBuf_p, &ech->innerClientHelloLen);
1364813648
readBuf_p += 2;
1364913649
offset += 2;
13650-
/* Check payload is no biffer than remaining bytes. */
13650+
/* Check payload is no buffer than remaining bytes. */
1365113651
if (ech->innerClientHelloLen > size - offset) {
1365213652
return BAD_FUNC_ARG;
1365313653
}

tests/api.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16788,7 +16788,7 @@ static int test_wolfSSL_d2i_SSL_SESSION_bounds_check(void)
1678816788
{
1678916789
EXPECT_DECLS;
1679016790
#if defined(OPENSSL_EXTRA) && defined(HAVE_EXT_CACHE) && \
16791-
defined(SESSION_CERTS)
16791+
defined(SESSION_CERTS) && !defined(NO_SESSION_CACHE)
1679216792
WOLFSSL_SESSION* sess = NULL;
1679316793
WOLFSSL_SESSION* restored = NULL;
1679416794
unsigned char* sessDer = NULL;
@@ -21219,7 +21219,8 @@ static int test_wolfSSL_X509_CRL_reason_critical_boolean(void)
2121921219

2122021220
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2122121221
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21222-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21222+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21223+
!defined(NO_ASN_TIME)
2122321224
/* Helper function to create, sign, and write a CRL */
2122421225
static int generate_crl_test(const char* keyFile, const char* certFile,
2122521226
const char* derFile, const char* pemFile,
@@ -21467,7 +21468,8 @@ static int test_sk_X509_CRL_encode(void)
2146721468
EXPECT_DECLS;
2146821469
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2146921470
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21470-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21471+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21472+
!defined(NO_ASN_TIME)
2147121473
#ifndef NO_RSA
2147221474
static const char* crlRsaPemFile = "./certs/crl/crlRsaOut.pem";
2147321475
static const char* crlRsaDerFile = "./certs/crl/crlRsaOut.der";
@@ -21506,7 +21508,8 @@ static int test_wolfSSL_X509_CRL_sign_large(void)
2150621508
EXPECT_DECLS;
2150721509
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2150821510
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21509-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21511+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21512+
!defined(NO_ASN_TIME)
2151021513
#ifndef NO_RSA
2151121514
static const char* testRsaKeyFile = "./certs/ca-key.pem";
2151221515
static const char* testRsaCertFile = "./certs/ca-cert.pem";

tests/api/test_tls13.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,9 @@ int test_key_share_mismatch(void)
27392739
EXPECT_DECLS;
27402740
#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && defined(WOLFSSL_TLS13) && \
27412741
defined(HAVE_SUPPORTED_CURVES) && defined(HAVE_ECC) && \
2742-
defined(BUILD_TLS_AES_128_GCM_SHA256)
2742+
defined(BUILD_TLS_AES_128_GCM_SHA256) && (!defined(WOLFSSL_SP_MATH) || \
2743+
(defined(WOLFSSL_SP_521) && !defined(WOLFSSL_SP_NO_256) && \
2744+
defined(WOLFSSL_SP_384)))
27432745
/* Taken from payload in https://github.com/wolfSSL/wolfssl/issues/9362 */
27442746
const byte ch1_bin[] = {
27452747
0x16, 0x03, 0x03, 0x00, 0x96, 0x01, 0x00, 0x00, 0x92, 0x03, 0x03, 0x01,

wolfcrypt/src/dilithium.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5452,8 +5452,13 @@ static sword32 dilithium_mont_red(sword64 a)
54525452
#endif
54535453
}
54545454

5455-
#if !defined(WOLFSSL_DILITHIUM_SMALL) || !defined(WOLFSSL_DILITHIUM_NO_SIGN)
5456-
5455+
#if !defined(WOLFSSL_DILITHIUM_SMALL) || \
5456+
(!defined(WOLFSSL_DILITHIUM_NO_SIGN) || \
5457+
(defined(WOLFSSL_DILITHIUM_SMALL) && \
5458+
(!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) || \
5459+
(!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \
5460+
!defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) || \
5461+
defined(WOLFSSL_DILITHIUM_CHECK_KEY))))
54575462
/* Reduce 32-bit a modulo q. r = a mod q.
54585463
*
54595464
* Barrett reduction.
@@ -5470,8 +5475,7 @@ static sword32 dilithium_red(sword32 a)
54705475
return (sword32)(a - (t << 23) + (t << 13) - t);
54715476
#endif
54725477
}
5473-
5474-
#endif /* !WOLFSSL_DILITHIUM_SMALL || !WOLFSSL_DILITHIUM_NO_SIGN */
5478+
#endif
54755479

54765480
/* Zetas for NTT. */
54775481
static const sword32 zetas[DILITHIUM_N] = {
@@ -7287,7 +7291,12 @@ static void dilithium_vec_mul(sword32* r, sword32* a, sword32* b, byte l)
72877291
#endif
72887292
#endif
72897293

7290-
#ifndef WOLFSSL_DILITHIUM_NO_SIGN
7294+
#if !defined(WOLFSSL_DILITHIUM_NO_SIGN) || \
7295+
(defined(WOLFSSL_DILITHIUM_SMALL) && \
7296+
(!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) || \
7297+
(!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \
7298+
!defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) || \
7299+
defined(WOLFSSL_DILITHIUM_CHECK_KEY)))
72917300
/* Modulo reduce values in polynomial. Range (-2^31)..(2^31-1).
72927301
*
72937302
* @param [in, out] a Polynomial.
@@ -7331,6 +7340,13 @@ static void dilithium_poly_red(sword32* a)
73317340
}
73327341
}
73337342

7343+
#if (defined(WOLFSSL_DILITHIUM_SMALL) && \
7344+
(!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) || \
7345+
(!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \
7346+
!defined(WOLFSSL_DILITHIUM_VERIFY_SMALL_MEM)) || \
7347+
defined(WOLFSSL_DILITHIUM_CHECK_KEY))) || \
7348+
(!defined(WOLFSSL_DILITHIUM_NO_SIGN) && \
7349+
!defined(WOLFSSL_DILITHIUM_SIGN_SMALL_MEM))
73347350
/* Modulo reduce values in polynomials of vector. Range (-2^31)..(2^31-1).
73357351
*
73367352
* @param [in, out] a Vector of polynomials.
@@ -7345,7 +7361,8 @@ static void dilithium_vec_red(sword32* a, byte l)
73457361
a += DILITHIUM_N;
73467362
}
73477363
}
7348-
#endif /* !WOLFSSL_DILITHIUM_NO_SIGN */
7364+
#endif
7365+
#endif
73497366

73507367
#if (!defined(WOLFSSL_DILITHIUM_NO_SIGN) || \
73517368
(!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && \

wolfcrypt/src/pkcs7.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3155,7 +3155,7 @@ static int PKCS7_EncodeSigned(wc_PKCS7* pkcs7,
31553155
idx = ret;
31563156
goto out;
31573157
}
3158-
#if defined(WC_RSA_PSS)
3158+
#if !defined(NO_RSA) && defined(WC_RSA_PSS)
31593159
if (digEncAlgoId == CTC_RSASSAPSS) {
31603160
/* Salt length policy: always encode as hash digest length.
31613161
* This is the common CMS/RFC 4055 profile and matches OpenSSL

wolfssl/internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,16 +3027,16 @@ typedef enum {
30273027
#if !defined(NO_CERTS) && !defined(WOLFSSL_NO_SIGALG)
30283028
TLSX_SIGNATURE_ALGORITHMS_CERT = TLSXT_SIGNATURE_ALGORITHMS_CERT,
30293029
#endif
3030-
#if defined(WOLFSSL_DTLS_CID)
3031-
TLSX_CONNECTION_ID = TLSXT_CONNECTION_ID,
3032-
#endif /* defined(WOLFSSL_DTLS_CID) */
30333030
#ifdef WOLFSSL_QUIC
30343031
TLSX_KEY_QUIC_TP_PARAMS = TLSXT_KEY_QUIC_TP_PARAMS,
30353032
#endif
30363033
#ifdef HAVE_ECH
30373034
TLSX_ECH = TLSXT_ECH,
30383035
#endif
30393036
#endif
3037+
#if defined(WOLFSSL_DTLS_CID)
3038+
TLSX_CONNECTION_ID = TLSXT_CONNECTION_ID,
3039+
#endif /* defined(WOLFSSL_DTLS_CID) */
30403040
#if defined(WOLFSSL_TLS13) || !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
30413041
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
30423042
TLSX_PRE_SHARED_KEY = TLSXT_PRE_SHARED_KEY,

0 commit comments

Comments
 (0)