Fix line length and whitespace issues. Fix macro argument missing parentheses.

This commit is contained in:
David Garske
2023-01-18 10:35:10 -08:00
parent 50cb3a7b8c
commit 41c35b1249
6 changed files with 74 additions and 54 deletions

View File

@@ -2784,11 +2784,11 @@ static int GetMacDigestSize(byte macAlgo)
#define ADD_HASH_SIG_ALGO(out, inOutIdx, major, minor) \ #define ADD_HASH_SIG_ALGO(out, inOutIdx, major, minor) \
do { \ do { \
if (out != NULL) { \ if ((out) != NULL) { \
out[*inOutIdx ] = major; \ (out)[*(inOutIdx) ] = (major); \
out[*inOutIdx + 1] = minor; \ (out)[*(inOutIdx) + 1] = (minor); \
} \ } \
*inOutIdx += 2; \ *(inOutIdx) += 2; \
} while (0) } while (0)
static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo, static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
@@ -2811,38 +2811,45 @@ static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
if (addSigAlgo) { if (addSigAlgo) {
#ifdef HAVE_ED25519 #ifdef HAVE_ED25519
if (sigAlgo == ed25519_sa_algo) { if (sigAlgo == ed25519_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, ED25519_SA_MAJOR, ED25519_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
ED25519_SA_MAJOR, ED25519_SA_MINOR);
} }
else else
#endif #endif
#ifdef HAVE_ED448 #ifdef HAVE_ED448
if (sigAlgo == ed448_sa_algo) { if (sigAlgo == ed448_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, ED448_SA_MAJOR, ED448_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
ED448_SA_MAJOR, ED448_SA_MINOR);
} }
else else
#endif #endif
#ifdef HAVE_PQC #ifdef HAVE_PQC
#ifdef HAVE_FALCON #ifdef HAVE_FALCON
if (sigAlgo == falcon_level1_sa_algo) { if (sigAlgo == falcon_level1_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, FALCON_LEVEL1_SA_MAJOR, FALCON_LEVEL1_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
FALCON_LEVEL1_SA_MAJOR, FALCON_LEVEL1_SA_MINOR);
} }
else else
if (sigAlgo == falcon_level5_sa_algo) { if (sigAlgo == falcon_level5_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, FALCON_LEVEL5_SA_MAJOR, FALCON_LEVEL5_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
FALCON_LEVEL5_SA_MAJOR, FALCON_LEVEL5_SA_MINOR);
} }
else else
#endif /* HAVE_FALCON */ #endif /* HAVE_FALCON */
#ifdef HAVE_DILITHIUM #ifdef HAVE_DILITHIUM
if (sigAlgo == dilithium_level2_sa_algo) { if (sigAlgo == dilithium_level2_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, DILITHIUM_LEVEL2_SA_MAJOR, DILITHIUM_LEVEL2_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
DILITHIUM_LEVEL2_SA_MAJOR, DILITHIUM_LEVEL2_SA_MINOR);
} }
else else
if (sigAlgo == dilithium_level3_sa_algo) { if (sigAlgo == dilithium_level3_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, DILITHIUM_LEVEL3_SA_MAJOR, DILITHIUM_LEVEL3_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
DILITHIUM_LEVEL3_SA_MAJOR, DILITHIUM_LEVEL3_SA_MINOR);
} }
else else
if (sigAlgo == dilithium_level5_sa_algo) { if (sigAlgo == dilithium_level5_sa_algo) {
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, DILITHIUM_LEVEL5_SA_MAJOR, DILITHIUM_LEVEL5_SA_MINOR); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx,
DILITHIUM_LEVEL5_SA_MAJOR, DILITHIUM_LEVEL5_SA_MINOR);
} }
else else
#endif /* HAVE_DILITHIUM */ #endif /* HAVE_DILITHIUM */
@@ -2853,7 +2860,8 @@ static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, sigAlgo, macAlgo); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, sigAlgo, macAlgo);
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
/* Add the certificate algorithm as well */ /* Add the certificate algorithm as well */
ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, sigAlgo, PSS_RSAE_TO_PSS_PSS(macAlgo)); ADD_HASH_SIG_ALGO(hashSigAlgo, inOutIdx, sigAlgo,
PSS_RSAE_TO_PSS_PSS(macAlgo));
#endif #endif
} }
else else
@@ -2864,19 +2872,18 @@ static WC_INLINE void AddSuiteHashSigAlgo(byte* hashSigAlgo, byte macAlgo,
} }
} }
void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig, void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig, int haveRSAsig,
int haveRSAsig, int haveFalconSig, int haveFalconSig, int haveDilithiumSig, int haveAnon, int tls1_2,
int haveDilithiumSig, int haveAnon, int keySz)
int tls1_2, int keySz)
{ {
InitSuitesHashSigAlgo_ex(suites->hashSigAlgo, haveECDSAsig, haveRSAsig, InitSuitesHashSigAlgo_ex(suites->hashSigAlgo, haveECDSAsig, haveRSAsig,
haveFalconSig, haveDilithiumSig, haveAnon, tls1_2, keySz, haveFalconSig, haveDilithiumSig, haveAnon, tls1_2, keySz,
&suites->hashSigAlgoSz); &suites->hashSigAlgoSz);
} }
void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsig, void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig,
int haveFalconSig, int haveDilithiumSig, int haveRSAsig, int haveFalconSig, int haveDilithiumSig, int haveAnon,
int haveAnon, int tls1_2, int keySz, word16* len) int tls1_2, int keySz, word16* len)
{ {
word16 idx = 0; word16 idx = 0;
@@ -2887,13 +2894,16 @@ void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsi
if (haveECDSAsig) { if (haveECDSAsig) {
#ifdef HAVE_ECC #ifdef HAVE_ECC
#ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_SHA512
AddSuiteHashSigAlgo(hashSigAlgo, sha512_mac, ecc_dsa_sa_algo, keySz, &idx); AddSuiteHashSigAlgo(hashSigAlgo, sha512_mac, ecc_dsa_sa_algo, keySz,
&idx);
#endif #endif
#ifdef WOLFSSL_SHA384 #ifdef WOLFSSL_SHA384
AddSuiteHashSigAlgo(hashSigAlgo, sha384_mac, ecc_dsa_sa_algo, keySz, &idx); AddSuiteHashSigAlgo(hashSigAlgo, sha384_mac, ecc_dsa_sa_algo, keySz,
&idx);
#endif #endif
#ifndef NO_SHA256 #ifndef NO_SHA256
AddSuiteHashSigAlgo(hashSigAlgo, sha256_mac, ecc_dsa_sa_algo, keySz, &idx); AddSuiteHashSigAlgo(hashSigAlgo, sha256_mac, ecc_dsa_sa_algo, keySz,
&idx);
#endif #endif
#if !defined(NO_SHA) && (!defined(NO_OLD_TLS) || \ #if !defined(NO_SHA) && (!defined(NO_OLD_TLS) || \
defined(WOLFSSL_ALLOW_TLS_SHA1)) defined(WOLFSSL_ALLOW_TLS_SHA1))
@@ -2911,20 +2921,22 @@ void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsi
if (haveFalconSig) { if (haveFalconSig) {
#if defined(HAVE_PQC) #if defined(HAVE_PQC)
#ifdef HAVE_FALCON #ifdef HAVE_FALCON
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, falcon_level1_sa_algo, keySz, &idx); AddSuiteHashSigAlgo(hashSigAlgo, no_mac, falcon_level1_sa_algo, keySz,
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, falcon_level5_sa_algo, keySz, &idx); &idx);
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, falcon_level5_sa_algo, keySz,
&idx);
#endif /* HAVE_FALCON */ #endif /* HAVE_FALCON */
#endif /* HAVE_PQC */ #endif /* HAVE_PQC */
} }
if (haveDilithiumSig) { if (haveDilithiumSig) {
#if defined(HAVE_PQC) #if defined(HAVE_PQC)
#ifdef HAVE_DILITHIUM #ifdef HAVE_DILITHIUM
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level2_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level2_sa_algo,
&idx); keySz, &idx);
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level3_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level3_sa_algo,
&idx); keySz, &idx);
AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level5_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, no_mac, dilithium_level5_sa_algo,
&idx); keySz, &idx);
#endif /* HAVE_DILITHIUM */ #endif /* HAVE_DILITHIUM */
#endif /* HAVE_PQC */ #endif /* HAVE_PQC */
} }
@@ -2933,15 +2945,15 @@ void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsi
if (tls1_2) { if (tls1_2) {
#ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_SHA512
AddSuiteHashSigAlgo(hashSigAlgo, sha512_mac, rsa_pss_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, sha512_mac, rsa_pss_sa_algo, keySz,
&idx); &idx);
#endif #endif
#ifdef WOLFSSL_SHA384 #ifdef WOLFSSL_SHA384
AddSuiteHashSigAlgo(hashSigAlgo, sha384_mac, rsa_pss_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, sha384_mac, rsa_pss_sa_algo, keySz,
&idx); &idx);
#endif #endif
#ifndef NO_SHA256 #ifndef NO_SHA256
AddSuiteHashSigAlgo(hashSigAlgo, sha256_mac, rsa_pss_sa_algo, keySz, AddSuiteHashSigAlgo(hashSigAlgo, sha256_mac, rsa_pss_sa_algo, keySz,
&idx); &idx);
#endif #endif
} }
#endif #endif
@@ -2965,7 +2977,8 @@ void InitSuitesHashSigAlgo_ex(byte* hashSigAlgo, int haveECDSAsig, int haveRSAsi
#ifdef HAVE_ANON #ifdef HAVE_ANON
if (haveAnon) { if (haveAnon) {
AddSuiteHashSigAlgo(hashSigAlgo, sha_mac, anonymous_sa_algo, keySz, &idx); AddSuiteHashSigAlgo(hashSigAlgo, sha_mac, anonymous_sa_algo, keySz,
&idx);
} }
#endif #endif

View File

@@ -6637,8 +6637,8 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
sa = TLSX_SignatureAlgorithms_New(ssl, hashSigAlgoSz, ssl->heap); sa = TLSX_SignatureAlgorithms_New(ssl, hashSigAlgoSz, ssl->heap);
if (sa == NULL) if (sa == NULL)
return MEMORY_ERROR; return MEMORY_ERROR;
InitSuitesHashSigAlgo_ex(sa->hashSigAlgo, 1, 1, 1, 1, 0, 1, ssl->buffers.keySz, InitSuitesHashSigAlgo_ex(sa->hashSigAlgo, 1, 1, 1, 1, 0, 1,
&sa->hashSigAlgoSz); ssl->buffers.keySz, &sa->hashSigAlgoSz);
ret = TLSX_Push(&ssl->extensions, TLSX_SIGNATURE_ALGORITHMS, sa, ssl->heap); ret = TLSX_Push(&ssl->extensions, TLSX_SIGNATURE_ALGORITHMS, sa, ssl->heap);
if (ret != 0) { if (ret != 0) {
TLSX_SignatureAlgorithms_FreeAll(sa, ssl->heap); TLSX_SignatureAlgorithms_FreeAll(sa, ssl->heap);

View File

@@ -9389,7 +9389,8 @@ static int test_wolfSSL_SCR_Reconnect(void)
XMEMSET(&test_ctx, 0, sizeof(test_ctx)); XMEMSET(&test_ctx, 0, sizeof(test_ctx));
test_ctx.c_ciphers = "ECDHE-RSA-AES256-GCM-SHA384"; test_ctx.c_ciphers = "ECDHE-RSA-AES256-GCM-SHA384";
test_ctx.s_ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305"; test_ctx.s_ciphers =
"ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305";
AssertIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s, AssertIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0); wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0);
AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSecureRenegotiation(ctx_c)); AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSecureRenegotiation(ctx_c));

View File

@@ -7513,7 +7513,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
WOLFSSL_ENTER("wolfSSL_EVP_Cipher"); WOLFSSL_ENTER("wolfSSL_EVP_Cipher");
if (ctx == NULL || ((src == NULL || dst == NULL) && if (ctx == NULL || ((src == NULL || dst == NULL) &&
(TRUE (TRUE
#ifdef HAVE_AESGCM #ifdef HAVE_AESGCM
&& ctx->cipherType != AES_128_GCM_TYPE && && ctx->cipherType != AES_128_GCM_TYPE &&
ctx->cipherType != AES_192_GCM_TYPE && ctx->cipherType != AES_192_GCM_TYPE &&

View File

@@ -4868,7 +4868,9 @@ typedef struct CIDInfo CIDInfo;
/* The idea is to re-use the context suites object whenever possible to save /* The idea is to re-use the context suites object whenever possible to save
* space. */ * space. */
#define WOLFSSL_SUITES(ssl) \ #define WOLFSSL_SUITES(ssl) \
((const Suites*) (ssl->suites != NULL ? ssl->suites : ssl->ctx->suites)) ((const Suites*) ((ssl)->suites != NULL ? \
(ssl)->suites : \
(ssl)->ctx->suites))
/* wolfSSL ssl type */ /* wolfSSL ssl type */
struct WOLFSSL { struct WOLFSSL {
@@ -4878,7 +4880,8 @@ struct WOLFSSL {
* object needs separate instance of suites use * object needs separate instance of suites use
* AllocateSuites(). */ * AllocateSuites(). */
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
WOLF_STACK_OF(WOLFSSL_CIPHER)* suitesStack; /* stack of available cipher suites */ WOLF_STACK_OF(WOLFSSL_CIPHER)* suitesStack; /* stack of available cipher
* suites */
#endif #endif
Arrays* arrays; Arrays* arrays;
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
@@ -4898,7 +4901,8 @@ struct WOLFSSL {
byte dupSide; /* write side or read side */ byte dupSide; /* write side or read side */
#endif #endif
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
byte cbioFlag; /* WOLFSSL_CBIO_RECV/SEND: CBIORecv/Send is set */ byte cbioFlag; /* WOLFSSL_CBIO_RECV/SEND:
* CBIORecv/Send is set */
#endif #endif
#ifdef WOLFSSL_WOLFSENTRY_HOOKS #ifdef WOLFSSL_WOLFSENTRY_HOOKS
NetworkFilterCallback_t AcceptFilter; NetworkFilterCallback_t AcceptFilter;
@@ -4928,7 +4932,8 @@ struct WOLFSSL {
* to encounter encryption blocking or fragment the message. */ * to encounter encryption blocking or fragment the message. */
struct WOLFSSL_ASYNC* async; struct WOLFSSL_ASYNC* async;
#endif #endif
void* hsKey; /* Handshake key (RsaKey or ecc_key) allocated from heap */ void* hsKey; /* Handshake key (RsaKey or ecc_key)
* allocated from heap */
word32 hsType; /* Type of Handshake key (hsKey) */ word32 hsType; /* Type of Handshake key (hsKey) */
WOLFSSL_CIPHER cipher; WOLFSSL_CIPHER cipher;
#ifndef WOLFSSL_AEAD_ONLY #ifndef WOLFSSL_AEAD_ONLY

View File

@@ -5208,18 +5208,19 @@ void DEBUG_WRITE_DER(const byte* der, int derSz, const char* fileName);
#define DTLS_CID_BUFFER_SIZE 256 #define DTLS_CID_BUFFER_SIZE 256
#if !defined(NO_FILESYSTEM) && ( \ #if !defined(NO_FILESYSTEM) && ( \
defined(WOLFSSL_TICKET_NONCE_MALLOC) && defined(HAVE_SESSION_TICKET) \ defined(WOLFSSL_TICKET_NONCE_MALLOC) && defined(HAVE_SESSION_TICKET) \
&& defined(WOLFSSL_TLS13) && \ && defined(WOLFSSL_TLS13) && \
(!defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))) \ (!defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)))\
|| \ || \
(defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && \ (defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && \
!defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER)) \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER)) \
|| \ || \
(defined(HAVE_SECURE_RENEGOTIATION) && \ (defined(HAVE_SECURE_RENEGOTIATION) && \
!defined(NO_RSA) && defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \ !defined(NO_RSA) && \
defined(WOLFSSL_SHA384) && defined(WOLFSSL_AES_256) && \ defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \
defined(HAVE_AESGCM)) \ defined(WOLFSSL_SHA384) && defined(WOLFSSL_AES_256) && \
defined(HAVE_AESGCM)) \
) )
#define TEST_MEMIO_BUF_SZ (64 * 1024) #define TEST_MEMIO_BUF_SZ (64 * 1024)