remove extraneous build gates and fix whitespace justification in a comment (peer review re PR #4772).

This commit is contained in:
Daniel Pouzzner
2022-01-20 16:43:32 -06:00
parent 386aac9694
commit bfada558bd
3 changed files with 55 additions and 56 deletions

103
src/ssl.c
View File

@@ -6549,9 +6549,7 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
#ifndef NO_RSA #ifndef NO_RSA
haveRSA = 1; haveRSA = 1;
#endif #endif
#ifndef NO_CERTS // NOLINT(readability-redundant-preprocessor)
keySz = ssl->buffers.keySz; keySz = ssl->buffers.keySz;
#endif
/* let's reset suites */ /* let's reset suites */
InitSuites(ssl->suites, ssl->version, keySz, haveRSA, InitSuites(ssl->suites, ssl->version, keySz, haveRSA,
@@ -8111,7 +8109,6 @@ int wolfSSL_CTX_check_private_key(const WOLFSSL_CTX* ctx)
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
#ifndef NO_CERTS // NOLINT(readability-redundant-preprocessor)
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
der = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_DCERT); der = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_DCERT);
if (der == NULL) if (der == NULL)
@@ -8197,10 +8194,6 @@ int wolfSSL_CTX_check_private_key(const WOLFSSL_CTX* ctx)
#endif #endif
return ret; return ret;
#else
WOLFSSL_MSG("NO_CERTS is defined, can not check private key");
return WOLFSSL_FAILURE;
#endif
} }
#endif /* !NO_CHECK_PRIVATE_KEY */ #endif /* !NO_CHECK_PRIVATE_KEY */
@@ -11374,7 +11367,6 @@ err:
#endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */ #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
#ifndef NO_CERTS // NOLINT(readability-redundant-preprocessor)
int wolfSSL_X509_add_altname_ex(WOLFSSL_X509* x509, const char* name, int wolfSSL_X509_add_altname_ex(WOLFSSL_X509* x509, const char* name,
word32 nameSz, int type) word32 nameSz, int type)
{ {
@@ -11972,11 +11964,8 @@ int wolfSSL_use_certificate(WOLFSSL* ssl, WOLFSSL_X509* x509)
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
#endif /* NO_CERTS */
#endif /* OPENSSL_EXTRA */ #endif /* OPENSSL_EXTRA */
#ifndef NO_CERTS // NOLINT(readability-redundant-preprocessor)
int wolfSSL_use_certificate_ASN1(WOLFSSL* ssl, const unsigned char* der, int wolfSSL_use_certificate_ASN1(WOLFSSL* ssl, const unsigned char* der,
int derSz) int derSz)
{ {
@@ -12068,7 +12057,6 @@ int wolfSSL_use_certificate_chain_file_format(WOLFSSL* ssl, const char* file,
} }
#endif /* !NO_FILESYSTEM */ #endif /* !NO_FILESYSTEM */
#endif /* !NO_CERTS */
#ifdef HAVE_ECC #ifdef HAVE_ECC
@@ -33013,60 +33001,72 @@ static int i2dProcessMembers(const void *src, byte *buf,
return len; return len;
} }
int wolfSSL_ASN1_item_i2d(const void *src, byte **dest, // NOLINT(misc-no-recursion) /* fixme */ static int wolfSSL_ASN1_item_i2d_1(const void *src, byte *buf,
const WOLFSSL_ASN1_ITEM *tpl) const WOLFSSL_ASN1_ITEM *tpl, int *len)
{ {
int len = 0; *len = 0;
byte *buf = NULL;
WOLFSSL_ENTER("wolfSSL_ASN1_item_i2d");
if (!src || !tpl) {
WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", WOLFSSL_FAILURE);
return WOLFSSL_FAILURE;
}
if (dest && !*dest) {
len = wolfSSL_ASN1_item_i2d(src, NULL, tpl);
if (!len) {
goto error;
}
buf = (byte*)XMALLOC(len, NULL, DYNAMIC_TYPE_ASN1);
if (!buf) {
goto error;
}
len = 0;
}
switch (tpl->type) { switch (tpl->type) {
case ASN_SEQUENCE: case ASN_SEQUENCE:
{ {
int seq_len = i2dProcessMembers(src, NULL, tpl->members, int seq_len = i2dProcessMembers(src, NULL, tpl->members,
tpl->mcount); tpl->mcount);
if (!seq_len) { if (seq_len == WOLFSSL_FAILURE)
goto error; return WOLFSSL_FAILURE;
*len += SetSequence(seq_len, bufLenOrNull(buf, *len));
if (buf) {
if (i2dProcessMembers(src, bufLenOrNull(buf, *len), tpl->members,
tpl->mcount) != seq_len) {
WOLFSSL_MSG("Inconsistent sequence length");
return WOLFSSL_FAILURE;
}
} }
len += SetSequence(seq_len, bufLenOrNull(buf, len)); *len += seq_len;
if (buf &&
i2dProcessMembers(src, bufLenOrNull(buf, len), tpl->members,
tpl->mcount) != seq_len) {
WOLFSSL_MSG("Inconsistent sequence length");
goto error;
}
len += seq_len;
break; break;
} }
default: default:
WOLFSSL_MSG("Type not supported in wolfSSL_ASN1_item_i2d"); WOLFSSL_MSG("Type not supported in wolfSSL_ASN1_item_i2d");
goto error; return WOLFSSL_FAILURE;
} }
if (dest && !*dest) { return WOLFSSL_SUCCESS;
*dest = buf; }
int wolfSSL_ASN1_item_i2d(const void *src, byte **dest,
const WOLFSSL_ASN1_ITEM *tpl)
{
int len;
byte *buf = NULL;
WOLFSSL_ENTER("wolfSSL_ASN1_item_i2d");
if ((src == NULL) || (tpl == NULL))
goto error;
if (wolfSSL_ASN1_item_i2d_1(src, NULL, tpl, &len) != WOLFSSL_SUCCESS)
goto error;
if (dest == NULL) {
WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", WOLFSSL_SUCCESS);
return len;
} }
else if (dest && *dest && buf) {
/* *dest length is not checked because the user is responsible if (*dest == NULL) {
* for providing a long enough buffer */ buf = (byte*)XMALLOC(len, NULL, DYNAMIC_TYPE_ASN1);
if (buf == NULL)
goto error;
} else
buf = *dest;
if (wolfSSL_ASN1_item_i2d_1(src, buf, tpl, &len) != WOLFSSL_SUCCESS)
goto error;
if (*dest == NULL)
*dest = buf;
else {
/* XXX *dest length is not checked because the user is responsible
* for providing a long enough buffer
*/
XMEMCPY(*dest, buf, len); XMEMCPY(*dest, buf, len);
} }
@@ -33079,6 +33079,7 @@ error:
WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", WOLFSSL_FAILURE); WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", WOLFSSL_FAILURE);
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
#endif /* OPENSSL_ALL */ #endif /* OPENSSL_ALL */
#ifndef NO_DH #ifndef NO_DH

View File

@@ -551,9 +551,9 @@ static const char* TagString(byte tag)
/* Returns whether ASN.1 item is an integer and the Most-Significant Bit is set. /* Returns whether ASN.1 item is an integer and the Most-Significant Bit is set.
* *
* @param [in] asn ASN.1 items to encode. * @param [in] asn ASN.1 items to encode.
* @param [in] data_a Data to place in each item. Lengths set were not known. * @param [in] data_a Data to place in each item. Lengths set were not known.
* @param [in] i Index of item to check. * @param [in] i Index of item to check.
* @return 1 when ASN.1 item is an integer and MSB is 1. * @return 1 when ASN.1 item is an integer and MSB is 1.
* @erturn 0 otherwise. * @erturn 0 otherwise.
*/ */

View File

@@ -2558,13 +2558,11 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
ret = RSA_BUFFER_E; ret = RSA_BUFFER_E;
} }
#ifndef WOLFSSL_XILINX_CRYPT // NOLINT(readability-redundant-preprocessor)
if (ret == 0) { if (ret == 0) {
*outLen = keyLen; *outLen = keyLen;
if (mp_to_unsigned_bin_len(tmp, out, keyLen) != MP_OKAY) if (mp_to_unsigned_bin_len(tmp, out, keyLen) != MP_OKAY)
ret = MP_TO_E; ret = MP_TO_E;
} }
#endif
#else #else
(void)type; (void)type;
(void)key; (void)key;