Skip to content

Commit d69f7ad

Browse files
committed
Fixes from regression testing
CRL APIs not useable 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 b3f08f3 commit d69f7ad

8 files changed

Lines changed: 58 additions & 23 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;

tests/api.c

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

2121921219
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2122021220
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21221-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21221+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21222+
!defined(NO_ASN_TIME)
2122221223
/* Helper function to create, sign, and write a CRL */
2122321224
static int generate_crl_test(const char* keyFile, const char* certFile,
2122421225
const char* derFile, const char* pemFile,
@@ -21466,7 +21467,8 @@ static int test_sk_X509_CRL_encode(void)
2146621467
EXPECT_DECLS;
2146721468
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2146821469
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21469-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21470+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21471+
!defined(NO_ASN_TIME)
2147021472
#ifndef NO_RSA
2147121473
static const char* crlRsaPemFile = "./certs/crl/crlRsaOut.pem";
2147221474
static const char* crlRsaDerFile = "./certs/crl/crlRsaOut.der";
@@ -21505,7 +21507,8 @@ static int test_wolfSSL_X509_CRL_sign_large(void)
2150521507
EXPECT_DECLS;
2150621508
#if (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && !defined(NO_CERTS) && \
2150721509
defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \
21508-
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN)
21510+
!defined(NO_STDIO_FILESYSTEM) && defined(WOLFSSL_CERT_GEN) && \
21511+
!defined(NO_ASN_TIME)
2150921512
#ifndef NO_RSA
2151021513
static const char* testRsaKeyFile = "./certs/ca-key.pem";
2151121514
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/asn.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42683,19 +42683,24 @@ int wc_SignCRL_ex(const byte* tbsBuf, int tbsSz, int sType,
4268342683

4268442684
if (tbsBuf == NULL || tbsSz <= 0 || buf == NULL || rng == NULL)
4268542685
return BAD_FUNC_ARG;
42686-
if (rsaKey == NULL && eccKey == NULL)
42687-
return BAD_FUNC_ARG;
42688-
42689-
XMEMSET(certSignCtx, 0, sizeof(*certSignCtx));
4269042686

42687+
#ifndef NO_RSA
4269142688
if (rsaKey != NULL) {
4269242689
heap = rsaKey->heap;
4269342690
}
42691+
else
42692+
#endif
4269442693
#ifdef HAVE_ECC
42695-
else if (eccKey != NULL) {
42694+
if (eccKey != NULL) {
4269642695
heap = eccKey->heap;
4269742696
}
42697+
else
4269842698
#endif
42699+
{
42700+
return BAD_FUNC_ARG;
42701+
}
42702+
42703+
XMEMSET(certSignCtx, 0, sizeof(*certSignCtx));
4269942704

4270042705
/* Copy TBS to output buffer first */
4270142706
if ((word32)tbsSz > bufSz)

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
@@ -3025,16 +3025,16 @@ typedef enum {
30253025
#if !defined(NO_CERTS) && !defined(WOLFSSL_NO_SIGALG)
30263026
TLSX_SIGNATURE_ALGORITHMS_CERT = TLSXT_SIGNATURE_ALGORITHMS_CERT,
30273027
#endif
3028-
#if defined(WOLFSSL_DTLS_CID)
3029-
TLSX_CONNECTION_ID = TLSXT_CONNECTION_ID,
3030-
#endif /* defined(WOLFSSL_DTLS_CID) */
30313028
#ifdef WOLFSSL_QUIC
30323029
TLSX_KEY_QUIC_TP_PARAMS = TLSXT_KEY_QUIC_TP_PARAMS,
30333030
#endif
30343031
#ifdef HAVE_ECH
30353032
TLSX_ECH = TLSXT_ECH,
30363033
#endif
30373034
#endif
3035+
#if defined(WOLFSSL_DTLS_CID)
3036+
TLSX_CONNECTION_ID = TLSXT_CONNECTION_ID,
3037+
#endif /* defined(WOLFSSL_DTLS_CID) */
30383038
#if defined(WOLFSSL_TLS13) || !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
30393039
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
30403040
TLSX_PRE_SHARED_KEY = TLSXT_PRE_SHARED_KEY,

0 commit comments

Comments
 (0)