Update logging enter, exit, msg to match function names. Fix some typos and improper use of "enter". Fix internal uses of SSL_SUCCESS and SSL_FAILURE. Add WOLFSSL_DEBUG_NONBLOCK option to allow printing iterations without debug enabled.

This commit is contained in:
David Garske
2023-02-21 12:02:15 -08:00
parent da04e0fb4c
commit fc6d693dae
18 changed files with 314 additions and 309 deletions
+6 -6
View File
@@ -5779,7 +5779,7 @@ int GetObjectId(const byte* input, word32* inOutIdx, word32* oid,
#ifndef WOLFSSL_ASN_TEMPLATE
int ret, length;
WOLFSSL_ENTER("GetObjectId()");
WOLFSSL_ENTER("GetObjectId");
ret = GetASNObjectId(input, inOutIdx, &length, maxIdx);
if (ret != 0)
@@ -5790,7 +5790,7 @@ int GetObjectId(const byte* input, word32* inOutIdx, word32* oid,
ASNGetData dataASN[objectIdASN_Length];
int ret;
WOLFSSL_ENTER("GetObjectId()");
WOLFSSL_ENTER("GetObjectId");
/* Clear dynamic data and set OID type expected. */
XMEMSET(dataASN, 0, sizeof(dataASN));
@@ -6841,7 +6841,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
return LENGTH_ONLY_E;
}
WOLFSSL_ENTER("wc_CreatePKCS8Key()");
WOLFSSL_ENTER("wc_CreatePKCS8Key");
if (key == NULL || out == NULL || outSz == NULL) {
return BAD_FUNC_ARG;
@@ -6914,7 +6914,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
word32 keyIdx = 0;
word32 tmpAlgId = 0;
WOLFSSL_ENTER("wc_CreatePKCS8Key()");
WOLFSSL_ENTER("wc_CreatePKCS8Key");
/* Check validity of parameters. */
if (out == NULL && outSz != NULL) {
@@ -8785,7 +8785,7 @@ int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz,
(void)heap;
WOLFSSL_ENTER("EncryptContent()");
WOLFSSL_ENTER("EncryptContent");
if (CheckAlgo(vPKCS, vAlgo, &id, &version, &blockSz) < 0)
return ASN_INPUT_E; /* Algo ID error */
@@ -8952,7 +8952,7 @@ int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz,
(void)heap;
WOLFSSL_ENTER("EncryptContent()");
WOLFSSL_ENTER("EncryptContent");
/* Must have a output size to return or check. */
if (outSz == NULL) {
+1 -1
View File
@@ -5175,7 +5175,7 @@ int wc_ecc_make_pub(ecc_key* key, ecc_point* pubOut)
*/
int wc_ecc_make_pub_ex(ecc_key* key, ecc_point* pubOut, WC_RNG* rng)
{
WOLFSSL_ENTER("wc_ecc_make_pub");
WOLFSSL_ENTER("wc_ecc_make_pub_ex");
return ecc_make_pub_ex(key, NULL, pubOut, rng);
}
+15 -15
View File
@@ -1739,7 +1739,7 @@ int wolfSSL_EVP_PKEY_CTX_free(WOLFSSL_EVP_PKEY_CTX *ctx)
#else
return 0;
#endif
WOLFSSL_ENTER("EVP_PKEY_CTX_free");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_CTX_free");
if (ctx->pkey != NULL)
wolfSSL_EVP_PKEY_free(ctx->pkey);
if (ctx->peerKey != NULL)
@@ -1764,7 +1764,7 @@ WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_E
if (pkey == NULL) return 0;
if (e != NULL) return 0;
WOLFSSL_ENTER("EVP_PKEY_CTX_new");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_CTX_new");
ctx = (WOLFSSL_EVP_PKEY_CTX*)XMALLOC(sizeof(WOLFSSL_EVP_PKEY_CTX), NULL,
DYNAMIC_TYPE_PUBLIC_KEY);
@@ -1801,7 +1801,7 @@ WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_E
int wolfSSL_EVP_PKEY_CTX_set_rsa_padding(WOLFSSL_EVP_PKEY_CTX *ctx, int padding)
{
if (ctx == NULL) return 0;
WOLFSSL_ENTER("EVP_PKEY_CTX_set_rsa_padding");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_CTX_set_rsa_padding");
ctx->padding = padding;
return WOLFSSL_SUCCESS;
}
@@ -1817,7 +1817,7 @@ int wolfSSL_EVP_PKEY_CTX_set_signature_md(WOLFSSL_EVP_PKEY_CTX *ctx,
const EVP_MD* md)
{
if (ctx == NULL) return 0;
WOLFSSL_ENTER("EVP_PKEY_CTX_set_signature_md");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_CTX_set_signature_md");
#ifndef NO_RSA
ctx->md = md;
#else
@@ -2254,7 +2254,7 @@ int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
{
int len = 0;
WOLFSSL_ENTER("EVP_PKEY_decrypt");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_decrypt");
if (ctx == NULL || ctx->pkey == NULL) {
WOLFSSL_MSG("Bad parameter.");
@@ -2318,7 +2318,7 @@ int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
int wolfSSL_EVP_PKEY_decrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx)
{
if (ctx == NULL) return WOLFSSL_FAILURE;
WOLFSSL_ENTER("EVP_PKEY_decrypt_init");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_decrypt_init");
switch (ctx->pkey->type) {
case EVP_PKEY_RSA:
ctx->op = EVP_PKEY_OP_DECRYPT;
@@ -2351,7 +2351,7 @@ int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
{
int len = 0;
WOLFSSL_ENTER("EVP_PKEY_encrypt");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_encrypt");
if (ctx == NULL || ctx->pkey == NULL) {
WOLFSSL_MSG("Bad parameter.");
@@ -2422,7 +2422,7 @@ int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
int wolfSSL_EVP_PKEY_encrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx)
{
if (ctx == NULL) return WOLFSSL_FAILURE;
WOLFSSL_ENTER("EVP_PKEY_encrypt_init");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_encrypt_init");
switch (ctx->pkey->type) {
case EVP_PKEY_RSA:
@@ -2703,7 +2703,7 @@ int wolfSSL_EVP_PKEY_bits(const WOLFSSL_EVP_PKEY *pkey)
int bytes;
if (pkey == NULL) return 0;
WOLFSSL_ENTER("EVP_PKEY_bits");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_bits");
if ((bytes = wolfSSL_EVP_PKEY_size((WOLFSSL_EVP_PKEY*)pkey)) ==0) return 0;
return bytes*8;
}
@@ -2923,7 +2923,7 @@ int wolfSSL_EVP_PKEY_keygen(WOLFSSL_EVP_PKEY_CTX *ctx,
int wolfSSL_EVP_PKEY_size(WOLFSSL_EVP_PKEY *pkey)
{
if (pkey == NULL) return 0;
WOLFSSL_ENTER("EVP_PKEY_size");
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_size");
switch (pkey->type) {
#ifndef NO_RSA
@@ -4841,7 +4841,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
/* return a pointer to MD4 EVP type */
const WOLFSSL_EVP_MD* wolfSSL_EVP_md4(void)
{
WOLFSSL_ENTER("wolfSSL_EVP_md4");
WOLFSSL_ENTER("EVP_md4");
return EVP_get_digestbyname("MD4");
}
@@ -5675,7 +5675,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx)
{
int ret = WOLFSSL_SUCCESS;
WOLFSSL_ENTER("EVP_MD_CTX_cleanup");
WOLFSSL_ENTER("wolfSSL_EVP_MD_CTX_cleanup");
if (ctx->pctx != NULL)
wolfSSL_EVP_PKEY_CTX_free(ctx->pctx);
@@ -5777,7 +5777,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx)
{
WOLFSSL_ENTER("EVP_CIPHER_CTX_init");
WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_init");
if (ctx) {
XMEMSET(ctx, 0, sizeof(WOLFSSL_EVP_CIPHER_CTX));
ctx->cipherType = WOLFSSL_EVP_CIPH_TYPE_INIT; /* not yet initialized */
@@ -5801,7 +5801,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
(void)arg;
(void)ptr;
WOLFSSL_ENTER("EVP_CIPHER_CTX_ctrl");
WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_ctrl");
switch(type) {
case EVP_CTRL_INIT:
@@ -5987,7 +5987,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
/* WOLFSSL_SUCCESS on ok */
int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx)
{
WOLFSSL_ENTER("EVP_CIPHER_CTX_cleanup");
WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_cleanup");
if (ctx) {
#if (!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
+1 -1
View File
@@ -2347,7 +2347,7 @@ WC_PKCS12* wc_PKCS12_create(char* pass, word32 passSz, char* name,
word32 certCiSz;
word32 keyCiSz;
WOLFSSL_ENTER("wc_PKCS12_create()");
WOLFSSL_ENTER("wc_PKCS12_create");
if (wc_InitRng_ex(&rng, heap, INVALID_DEVID) != 0) {
return NULL;
+8 -8
View File
@@ -1852,7 +1852,7 @@ static int maxq10xx_read_device_cert_der(byte* p_dest_buff, word32* p_len)
int pk_offset = 0;
#endif
WOLFSSL_ENTER("maxq10xx_read_device_cert_der()");
WOLFSSL_ENTER("maxq10xx_read_device_cert_der");
if (!p_dest_buff || !p_len) {
return BAD_FUNC_ARG;
}
@@ -2025,7 +2025,7 @@ static int maxq10xx_tls12_ecc_shared_secret(WOLFSSL* ssl, ecc_key* otherKey,
(void)outlen;
(void)side;
WOLFSSL_ENTER("maxq10xx_ecc_shared_secret()");
WOLFSSL_ENTER("maxq10xx_ecc_shared_secret");
if (ssl->specs.kea != ecc_diffie_hellman_kea) {
WOLFSSL_MSG("MAXQ: key exchange algo not supported");
@@ -2215,7 +2215,7 @@ static int maxq10xx_create_dh_key(byte* p, word32 pSz, byte* g, word32 gSz,
int rc;
mxq_err_t mxq_rc;
WOLFSSL_ENTER("maxq10xx_create_dh_key()");
WOLFSSL_ENTER("maxq10xx_create_dh_key");
if (!tls13active) {
return NOT_COMPILED_IN;
}
@@ -2278,7 +2278,7 @@ static int maxq10xx_dh_agree(WOLFSSL* ssl, struct DhKey* key,
(void)priv;
(void)privSz;
WOLFSSL_ENTER("maxq10xx_dh_agree()");
WOLFSSL_ENTER("maxq10xx_dh_agree");
mxq_u2 csid_param = ssl->options.cipherSuite |
(ssl->options.cipherSuite0 << 8);
@@ -2330,7 +2330,7 @@ static int maxq10xx_ecc_key_gen(WOLFSSL* ssl, ecc_key* key, word32 keySz,
(void)ctx;
(void)ssl;
WOLFSSL_ENTER("maxq10xx_ecc_key_gen()");
WOLFSSL_ENTER("maxq10xx_ecc_key_gen");
if (tls13_ecc_obj_id == -1) {
tls13_ecc_obj_id = alloc_temp_key_id();
@@ -2375,7 +2375,7 @@ static int maxq10xx_ecc_verify(WOLFSSL* ssl, const byte* sig,
(void)keySz;
(void)ctx;
WOLFSSL_ENTER("maxq10xx_ecc_verify()");
WOLFSSL_ENTER("maxq10xx_ecc_verify");
if (!tls13active) {
return CRYPTOCB_UNAVAILABLE;
@@ -2418,7 +2418,7 @@ static int maxq10xx_tls13_ecc_shared_secret(WOLFSSL* ssl, ecc_key* otherKey,
(void)side;
(void)pubKeySz;
WOLFSSL_ENTER("maxq10xx_ecc_shared_secret()");
WOLFSSL_ENTER("maxq10xx_ecc_shared_secret");
rc = wc_ecc_export_public_raw(otherKey, qx, &qxLen, qy, &qyLen);
@@ -3331,7 +3331,7 @@ static int maxq10xx_perform_tls13_record_processing(WOLFSSL* ssl,
return rc;
}
WOLFSSL_MSG("MAXQ: MXQ_TLS13_Update_IV()");
WOLFSSL_MSG("MAXQ: MXQ_TLS13_Update_IV");
mxq_rc = MXQ_TLS13_Update_IV( key_id, (mxq_u1 *)iv, ivSz);
if (mxq_rc) {
WOLFSSL_ERROR_MSG("MAXQ: MXQ_TLS13_Update_IV() failed");
+7 -7
View File
@@ -14604,7 +14604,7 @@ static int rsa_nb_test(RsaKey* key, const byte* in, word32 inLen, byte* out,
if (ret < 0) {
return ret;
}
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
printf("RSA non-block sign: %d times\n", count);
#endif
signSz = ret;
@@ -14622,7 +14622,7 @@ static int rsa_nb_test(RsaKey* key, const byte* in, word32 inLen, byte* out,
if (ret < 0) {
return ret;
}
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
printf("RSA non-block verify: %d times\n", count);
#endif
@@ -14642,7 +14642,7 @@ static int rsa_nb_test(RsaKey* key, const byte* in, word32 inLen, byte* out,
if (ret < 0) {
return ret;
}
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
printf("RSA non-block inline verify: %d times\n", count);
#endif
@@ -26474,7 +26474,7 @@ static int crypto_ecc_verify(const byte *key, uint32_t keySz,
/* This is where real-time work could be called */
} while (ret == FP_WOULDBLOCK);
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
printf("ECC non-block verify: %d times\n", count);
#endif
if (ret < 0)
@@ -26563,7 +26563,7 @@ static int crypto_ecc_sign(const byte *key, uint32_t keySz,
/* This is where real-time work could be called */
} while (ret == FP_WOULDBLOCK);
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
printf("ECC non-block sign: %d times\n", count);
#endif
if (ret < 0)
@@ -26629,7 +26629,7 @@ static int ecc_test_nonblock_dhe(int curveId, word32 curveSz,
if (ret < 0)
ret = -16120;
}
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
fprintf(stderr, "ECC non-block key gen: %d times\n", count);
#endif
if (ret == 0) {
@@ -26652,7 +26652,7 @@ static int ecc_test_nonblock_dhe(int curveId, word32 curveSz,
if (ret < 0)
ret = -16123;
}
#ifdef DEBUG_WOLFSSL
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_NONBLOCK)
fprintf(stderr, "ECC non-block shared secret: %d times\n", count);
#endif
if (ret == 0) {