From 0b4f34d62aae460d997a0cc804ac612645dda917 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 5 Nov 2021 18:16:08 -0500 Subject: [PATCH] typographic cleanup: fix whitespace, remove unneeded UTF-8, convert C++ comment constructs to C. --- examples/client/client.c | 6 +- examples/configs/user_settings_min_ecc.h | 2 +- examples/configs/user_settings_stm32.h | 12 +- examples/configs/user_settings_template.h | 12 +- examples/server/server.c | 12 +- mcapi/include.am | 4 +- resource.h | 2 +- src/bio.c | 6 +- src/crl.c | 10 +- src/internal.c | 176 ++--- src/sniffer.c | 172 ++--- src/ssl.c | 156 ++-- src/tls.c | 48 +- src/tls13.c | 32 +- src/wolfio.c | 4 +- sslSniffer/sslSnifferTest/snifftest.c | 3 - support/include.am | 2 - swig/wolfssl_adds.c | 2 +- tests/api.c | 514 +++++++------- tests/suites.c | 2 +- testsuite/testsuite.c | 2 +- wolfcrypt/benchmark/benchmark.c | 24 +- wolfcrypt/src/aes.c | 10 +- wolfcrypt/src/aes_asm.S | 2 +- wolfcrypt/src/asn.c | 20 +- wolfcrypt/src/blake2b.c | 4 +- wolfcrypt/src/camellia.c | 624 ++++++++-------- wolfcrypt/src/cmac.c | 6 +- wolfcrypt/src/cryptocb.c | 2 +- wolfcrypt/src/curve448.c | 2 +- wolfcrypt/src/des3.c | 10 +- wolfcrypt/src/dh.c | 4 +- wolfcrypt/src/ecc.c | 20 +- wolfcrypt/src/eccsi.c | 2 +- wolfcrypt/src/evp.c | 122 ++-- wolfcrypt/src/fe_low_mem.c | 664 +++++++++--------- wolfcrypt/src/fe_operations.c | 36 +- wolfcrypt/src/integer.c | 2 +- wolfcrypt/src/memory.c | 2 +- wolfcrypt/src/misc.c | 16 +- wolfcrypt/src/pkcs12.c | 2 +- .../src/port/Renesas/renesas_tsip_util.c | 6 +- wolfcrypt/src/port/af_alg/afalg_hash.c | 2 +- wolfcrypt/src/random.c | 24 +- wolfcrypt/src/rsa.c | 8 +- wolfcrypt/src/sha.c | 4 +- wolfcrypt/src/sha256.c | 12 +- wolfcrypt/src/sha3.c | 4 +- wolfcrypt/src/sha512.c | 6 +- wolfcrypt/src/signature.c | 8 +- wolfcrypt/src/tfm.c | 8 +- wolfcrypt/src/wc_port.c | 28 +- wolfcrypt/src/wolfmath.c | 2 +- wolfcrypt/user-crypto/src/rsa.c | 2 +- wolfssl/internal.h | 10 +- wolfssl/openssl/dh.h | 2 +- wolfssl/openssl/dsa.h | 2 +- wolfssl/openssl/evp.h | 8 +- wolfssl/openssl/opensslv.h | 2 +- wolfssl/openssl/pem.h | 2 +- wolfssl/openssl/ripemd.h | 2 +- wolfssl/openssl/rsa.h | 4 +- wolfssl/openssl/sha.h | 20 +- wolfssl/openssl/sha3.h | 4 +- wolfssl/openssl/ssl.h | 2 +- wolfssl/sniffer.h | 28 +- wolfssl/ssl.h | 26 +- wolfssl/test.h | 26 +- wolfssl/wolfcrypt/arc4.h | 4 +- wolfssl/wolfcrypt/chacha.h | 6 +- wolfssl/wolfcrypt/ecc.h | 12 +- wolfssl/wolfcrypt/error-crypt.h | 2 +- wolfssl/wolfcrypt/fe_operations.h | 6 +- wolfssl/wolfcrypt/hc128.h | 2 +- wolfssl/wolfcrypt/hmac.h | 6 +- wolfssl/wolfcrypt/mem_track.h | 20 +- wolfssl/wolfcrypt/pkcs11.h | 2 +- wolfssl/wolfcrypt/poly1305.h | 4 +- wolfssl/wolfcrypt/pwdbased.h | 4 +- wolfssl/wolfcrypt/rabbit.h | 2 +- wolfssl/wolfcrypt/rsa.h | 6 +- wolfssl/wolfcrypt/settings.h | 14 +- wolfssl/wolfcrypt/sha.h | 4 +- wolfssl/wolfcrypt/sha256.h | 4 +- wolfssl/wolfcrypt/sha512.h | 8 +- wolfssl/wolfcrypt/tfm.h | 2 +- wolfssl/wolfcrypt/visibility.h | 2 +- wolfssl/wolfcrypt/wc_encrypt.h | 4 +- wolfssl/wolfcrypt/wc_port.h | 10 +- 89 files changed, 1558 insertions(+), 1571 deletions(-) diff --git a/examples/client/client.c b/examples/client/client.c index d1fcbaa21..a6b86917b 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -20,7 +20,7 @@ */ /* For simpler wolfSSL TLS client examples, visit - * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls + * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls */ #ifdef HAVE_CONFIG_H @@ -1708,7 +1708,7 @@ static void Usage(void) printf("%s", msg[++msgid]); /* --wolfsentry-config */ #endif printf("%s", msg[++msgid]); /* -7 */ - printf("%s", msg[++msgid]); /* Examples repo link */ + printf("%s", msg[++msgid]); /* Examples repo link */ #ifdef HAVE_LIBOQS printf("%s", msg[++msgid]); /* --oqs */ printf("%s", msg[++msgid]); /* --oqs options */ @@ -2987,7 +2987,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) if (useCertFolder) { WOLFSSL_X509_STORE *store; WOLFSSL_X509_LOOKUP *lookup; - + store = wolfSSL_CTX_get_cert_store(ctx); if (store == NULL) { wolfSSL_CTX_free(ctx); ctx = NULL; diff --git a/examples/configs/user_settings_min_ecc.h b/examples/configs/user_settings_min_ecc.h index 6a705f365..5b2ccf834 100644 --- a/examples/configs/user_settings_min_ecc.h +++ b/examples/configs/user_settings_min_ecc.h @@ -70,7 +70,7 @@ extern "C" { /* Optional Feature Disables */ #define NO_SIG_WRAPPER -//#define NO_ECC_KEY_EXPORT +//#define NO_ECC_KEY_EXPORT //#define NO_ECC_DHE //#define NO_ECC_SIGN //#define NO_ECC_VERIFY diff --git a/examples/configs/user_settings_stm32.h b/examples/configs/user_settings_stm32.h index 84b1f089c..8e2ce9c18 100644 --- a/examples/configs/user_settings_stm32.h +++ b/examples/configs/user_settings_stm32.h @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -/* STM32 Cube Sample Configuration File +/* STM32 Cube Sample Configuration File * Generated automatically using `default_conf.ftl` template * - * Included automatically when USE_HAL_DRIVER is defined + * Included automatically when USE_HAL_DRIVER is defined * (and not WOLFSSL_USER_SETTINGS or HAVE_CONF_H). */ @@ -476,12 +476,12 @@ /* Sha3 */ #undef WOLFSSL_SHA3 #if defined(WOLF_CONF_SHA3) && WOLF_CONF_SHA3 == 1 - #define WOLFSSL_SHA3 + #define WOLFSSL_SHA3 #endif /* MD5 */ #if defined(WOLF_CONF_MD5) && WOLF_CONF_MD5 == 1 - /* enabled */ + /* enabled */ #else #define NO_MD5 #endif @@ -504,8 +504,8 @@ #if 0 #define USE_WOLFSSL_MEMORY #define WOLFSSL_TRACK_MEMORY - #define WOLFSSL_DEBUG_MEMORY - #define WOLFSSL_DEBUG_MEMORY_PRINT + #define WOLFSSL_DEBUG_MEMORY + #define WOLFSSL_DEBUG_MEMORY_PRINT #endif #else //#define NO_WOLFSSL_MEMORY diff --git a/examples/configs/user_settings_template.h b/examples/configs/user_settings_template.h index 30b1a7736..cfc95ddc8 100644 --- a/examples/configs/user_settings_template.h +++ b/examples/configs/user_settings_template.h @@ -52,8 +52,8 @@ extern "C" { /* reduce stack use. For variables over 100 bytes allocate from heap */ #define WOLFSSL_SMALL_STACK - /* disable the built-in socket support and use the IO callbacks. - * Set with wolfSSL_CTX_SetIORecv/wolfSSL_CTX_SetIOSend + /* disable the built-in socket support and use the IO callbacks. + * Set with wolfSSL_CTX_SetIORecv/wolfSSL_CTX_SetIOSend */ #define WOLFSSL_USER_IO #endif @@ -78,14 +78,14 @@ extern "C" { #define WOLFSSL_HAVE_SP_ECC //#define WOLFSSL_SP_4096 /* Enable RSA/RH 4096-bit support */ //#define WOLFSSL_SP_384 /* Enable ECC 384-bit SECP384R1 support */ - + //#define WOLFSSL_SP_CACHE_RESISTANT #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */ #define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */ //#define WOLFSSL_SP_NO_MALLOC //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */ - + #ifdef TARGET_EMBEDDED /* use smaller version of code */ #define WOLFSSL_SP_SMALL @@ -117,7 +117,7 @@ extern "C" { /* Enables blinding mode, to prevent timing attacks */ #define WC_RSA_BLINDING - + /* RSA PSS Support */ #define WC_RSA_PSS #else @@ -199,7 +199,7 @@ extern "C" { /* AES */ #undef NO_AES #if 1 - #define HAVE_AES_CBC + #define HAVE_AES_CBC /* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */ #define HAVE_AESGCM diff --git a/examples/server/server.c b/examples/server/server.c index 0bd0dc83a..c28f9ac18 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -20,7 +20,7 @@ */ /* For simpler wolfSSL TLS server examples, visit - * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls + * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls */ #ifdef HAVE_CONFIG_H @@ -1411,8 +1411,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) #endif #ifdef WOLFSSL_STATIC_MEMORY - /* Note: Actual memory used is much less, this is the entire buffer buckets, - * which is partitioned into pools of common sizes. To adjust the buckets + /* Note: Actual memory used is much less, this is the entire buffer buckets, + * which is partitioned into pools of common sizes. To adjust the buckets * sizes see WOLFMEM_BUCKETS in memory.h */ #if (defined(HAVE_ECC) && !defined(ALT_ECC_SIZE)) \ || defined(SESSION_CERTS) @@ -2181,7 +2181,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) #endif /* WOLFSSL_STATIC_MEMORY */ if (ctx == NULL) err_sys_ex(catastrophic, "unable to get ctx"); - + if (minVersion != SERVER_INVALID_VERSION) { wolfSSL_CTX_SetMinVersion(ctx, minVersion); } @@ -2221,7 +2221,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) #endif #if defined(WOLFSSL_SNIFFER) && defined(WOLFSSL_STATIC_EPHEMERAL) - /* used for testing only to set a static/fixed ephemeral key + /* used for testing only to set a static/fixed ephemeral key for use with the sniffer */ #if defined(HAVE_ECC) && !defined(NO_ECC_SECP) && \ (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) @@ -2443,7 +2443,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args) if (useCertFolder) { WOLFSSL_X509_STORE *store; WOLFSSL_X509_LOOKUP *lookup; - + store = wolfSSL_CTX_get_cert_store(ctx); if (store == NULL) { wolfSSL_CTX_free(ctx); ctx = NULL; diff --git a/mcapi/include.am b/mcapi/include.am index 9448a5232..7a174c1c4 100644 --- a/mcapi/include.am +++ b/mcapi/include.am @@ -4,10 +4,10 @@ if BUILD_MCAPI check_PROGRAMS += mcapi/test -noinst_PROGRAMS += mcapi/test +noinst_PROGRAMS += mcapi/test mcapi_test_SOURCES = mcapi/crypto.c \ mcapi/mcapi_test.c -mcapi_test_LDADD = src/libwolfssl.la +mcapi_test_LDADD = src/libwolfssl.la mcapi_test_DEPENDENCIES = src/libwolfssl.la endif diff --git a/resource.h b/resource.h index b8c8297e7..46af9b0f3 100644 --- a/resource.h +++ b/resource.h @@ -3,7 +3,7 @@ // Used by wolfssl.rc // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 diff --git a/src/bio.c b/src/bio.c index 9a6f0551a..3d748d0b4 100644 --- a/src/bio.c +++ b/src/bio.c @@ -277,7 +277,7 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len) break; case WOLFSSL_BIO_SOCKET: #ifdef USE_WOLFSSL_IO - /* BIO requires built-in socket support + /* BIO requires built-in socket support * (cannot be used with WOLFSSL_USER_IO) */ ret = wolfIO_Recv(bio->num, (char*)buf, len, 0); #else @@ -659,12 +659,12 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) break; case WOLFSSL_BIO_SOCKET: #ifdef USE_WOLFSSL_IO - /* BIO requires built-in socket support + /* BIO requires built-in socket support * (cannot be used with WOLFSSL_USER_IO) */ ret = wolfIO_Send(bio->num, (char*)data, len, 0); #else ret = NOT_COMPILED_IN; - #endif + #endif break; } /* switch */ } diff --git a/src/crl.c b/src/crl.c index bfc743015..dd3a18855 100644 --- a/src/crl.c +++ b/src/crl.c @@ -381,7 +381,7 @@ int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert) /* When not set the folder or not use hash_dir, do nothing. */ if ((foundEntry == 0) && (ret != OCSP_WANT_READ)) { if (crl->cm->x509_store_p != NULL) { - ret = LoadCertByIssuer(crl->cm->x509_store_p, + ret = LoadCertByIssuer(crl->cm->x509_store_p, (WOLFSSL_X509_NAME*)cert->issuerName, X509_LU_CRL); if (ret == WOLFSSL_SUCCESS) { /* try again */ @@ -1350,10 +1350,10 @@ int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor) #else int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor) { - (void)crl; - (void)path; - (void)type; - (void)monitor; + (void)crl; + (void)path; + (void)type; + (void)monitor; /* stub for scenario where file system is not supported */ return NOT_COMPILED_IN; diff --git a/src/internal.c b/src/internal.c index 1d26a1691..13553ac8d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2179,7 +2179,7 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap) } XMEMSET(ctx->param, 0, sizeof(WOLFSSL_X509_VERIFY_PARAM)); /* WOLFSSL_X509_LOOKUP */ - if ((ctx->x509_store.lookup.dirs = + if ((ctx->x509_store.lookup.dirs = (WOLFSSL_BY_DIR*)XMALLOC(sizeof(WOLFSSL_BY_DIR), heap, DYNAMIC_TYPE_OPENSSL)) == NULL) { WOLFSSL_MSG("ctx-x509_store.lookup.dir memory allocation error"); @@ -2236,7 +2236,7 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap) #endif #if defined(WOLFSSL_QT) && !defined(NO_PSK) - /* Qt retrieves supported cipher list at initialization + /* Qt retrieves supported cipher list at initialization * from get_cipher_compat(). * Qt doesn't allow to use a cipher if it is not in the supported list. * Therefore, we need to enable PSK cipher at the beginning. @@ -2268,9 +2268,9 @@ void wolfSSL_CRYPTO_cleanup_ex_data(WOLFSSL_CRYPTO_EX_DATA* ex_data) /* In case contexts are held in array and don't want to free actual ctx. */ /* The allocations done in InitSSL_Ctx must be free'd with ctx->onHeapHint - * logic. A WOLFSSL_CTX can be assigned a static memory heap hint using - * wolfSSL_CTX_load_static_memory after CTX creation, which means variables - * allocated in InitSSL_Ctx were allocated from heap and should be free'd with + * logic. A WOLFSSL_CTX can be assigned a static memory heap hint using + * wolfSSL_CTX_load_static_memory after CTX creation, which means variables + * allocated in InitSSL_Ctx were allocated from heap and should be free'd with * a NULL heap hint. */ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) { @@ -2392,7 +2392,7 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) if (ctx->x509_store.lookup.dirs->dir_entry) { wolfSSL_sk_BY_DIR_entry_free(ctx->x509_store.lookup.dirs->dir_entry); } - + #endif wc_FreeMutex(&ctx->x509_store.lookup.dirs->lock); XFREE(ctx->x509_store.lookup.dirs, heapAtCTXInit, DYNAMIC_TYPE_OPENSSL); @@ -6425,7 +6425,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup) #endif #if !defined(NO_BIO) && defined(OPENSSL_EXTRA) if (ctx->alpn_cli_protos != NULL && ctx->alpn_cli_protos_len > 0) { - ret = wolfSSL_set_alpn_protos(ssl, ctx->alpn_cli_protos, + ret = wolfSSL_set_alpn_protos(ssl, ctx->alpn_cli_protos, ctx->alpn_cli_protos_len); #if defined(WOLFSSL_ERROR_CODE_OPENSSL) if (ret) { @@ -6436,7 +6436,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup) return ret; } } - #endif + #endif #endif #ifdef HAVE_SUPPORTED_CURVES ssl->options.userCurves = ctx->userCurves; @@ -11461,7 +11461,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) byte suffix = 0; int retHash = NOT_COMPILED_IN; byte dgt[WC_MAX_DIGEST_SIZE]; - + WOLFSSL_ENTER("LoadCertByIssuer"); /* sanity check */ @@ -11472,7 +11472,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) if (lookup->dirs == NULL || lookup->type != 1) { return WOLFSSL_FAILURE; } - + len = wolfSSL_i2d_X509_NAME_canon(issuer, &pbuf); if (len > 0) { #ifndef NO_SHA @@ -11480,7 +11480,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) #endif if (retHash == 0) { /* 4 bytes in little endian as unsigned long */ - hash = (((unsigned long)dgt[3] << 24) | + hash = (((unsigned long)dgt[3] << 24) | ((unsigned long)dgt[2] << 16) | ((unsigned long)dgt[1] << 8) | ((unsigned long)dgt[0])); @@ -11490,28 +11490,28 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) } wolfSSL_OPENSSL_free(pbuf); } - + /* try to load each hashed name file in path */ #if !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) - + if (type == X509_LU_CRL) { post = "r"; } - + num = wolfSSL_sk_BY_DIR_entry_num(lookup->dirs->dir_entry); - + for (i=0; idirs->dir_entry, i); - - if (type == X509_LU_CRL && entry->hashes != NULL && + + if (type == X509_LU_CRL && entry->hashes != NULL && wolfSSL_sk_BY_DIR_HASH_num(entry->hashes) > 0) { /* lock the list */ if (wc_LockMutex(&lookup->dirs->lock) != 0) { WOLFSSL_MSG("wc_LockMutex cdir Lock error"); return BAD_MUTEX_E; } - + hash_tmp.hash_value = hash; index = wolfSSL_sk_BY_DIR_HASH_find(entry->hashes, &hash_tmp); if (index >= 0) { @@ -11522,10 +11522,10 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) ph = NULL; suffix = 0; } - + wc_UnLockMutex(&lookup->dirs->lock); } - + /* Additional buffer length for file name memory allocation : */ /* / .(r)N\0 */ /*|1| 8 |1|1|1|1| => 13 */ @@ -11533,25 +11533,25 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) if (filename != NULL) { XFREE(filename, NULL, DYNAMIC_TYPE_OPENSSL); } - + filename = (char*)XMALLOC(len, NULL, DYNAMIC_TYPE_OPENSSL); if (filename == NULL) { WOLFSSL_MSG("memory allocation error"); return MEMORY_E; } - + /* set as FAILURE, if successfuly loading cert of CRL, this becomes */ /* WOLFSSL_SUCCESS */ ret = WOLFSSL_FAILURE; - + for (; suffix < MAX_SUFFIX; suffix++) { /* /folder-path/.(r)N[0..9] */ - XSNPRINTF(filename, len, "%s/%08lx.%s%d", entry->dir_name, + XSNPRINTF(filename, len, "%s/%08lx.%s%d", entry->dir_name, hash, post, suffix); if(wc_FileExists(filename) == 0/*0 file exists */) { - + if (type == X509_LU_X509) { - x509 = wolfSSL_X509_load_certificate_file(filename, + x509 = wolfSSL_X509_load_certificate_file(filename, WOLFSSL_FILETYPE_PEM); if (x509 != NULL) { ret = wolfSSL_X509_STORE_add_cert(store, x509); @@ -11561,7 +11561,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) ret = WOLFSSL_FAILURE; break; } - } + } #if defined(HAVE_CRL) && !defined(NO_BIO) else if (type == X509_LU_CRL) { ret = wolfSSL_X509_load_crl_file(&store->lookup, filename, @@ -11581,7 +11581,7 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) } else break; } - + if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("not found file"); ret = WOLFSSL_FAILURE; @@ -11600,14 +11600,14 @@ int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int type) } else { ph->hash_value = hash; ph->last_suffix = suffix; - + ret = wolfSSL_sk_BY_DIR_HASH_push(entry->hashes, ph); } } wc_UnLockMutex(&lookup->dirs->lock); } } - + XFREE(filename, NULL, DYNAMIC_TYPE_OPENSSL); } #else @@ -12521,7 +12521,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx, { if (args->count > 0) { #if defined(HAVE_OCSP) || defined(HAVE_CRL) - /* only attempt to check OCSP or CRL if not previous error such + /* only attempt to check OCSP or CRL if not previous error such * as ASN_BEFORE_DATE_E or ASN_AFTER_DATE_E */ if (args->fatal == 0 && ret == 0) { int doLookup = 1; @@ -19421,35 +19421,35 @@ int SendCertificateStatus(WOLFSSL* ssl) } if (chain && chain->buffer) { - while (idx + OPAQUE24_LEN < chain->length) { - c24to32(chain->buffer + idx, &der.length); - idx += OPAQUE24_LEN; + while (idx + OPAQUE24_LEN < chain->length) { + c24to32(chain->buffer + idx, &der.length); + idx += OPAQUE24_LEN; - der.buffer = chain->buffer + idx; - idx += der.length; + der.buffer = chain->buffer + idx; + idx += der.length; - if (idx > chain->length) - break; + if (idx > chain->length) + break; - ret = CreateOcspRequest(ssl, request, cert, der.buffer, - der.length); - if (ret == 0) { - request->ssl = ssl; + ret = CreateOcspRequest(ssl, request, cert, der.buffer, + der.length); + if (ret == 0) { + request->ssl = ssl; ret = CheckOcspRequest(SSL_CM(ssl)->ocsp_stapling, request, &responses[i + 1]); - /* Suppressing, not critical */ - if (ret == OCSP_CERT_REVOKED || - ret == OCSP_CERT_UNKNOWN || - ret == OCSP_LOOKUP_FAIL) { - ret = 0; - } + /* Suppressing, not critical */ + if (ret == OCSP_CERT_REVOKED || + ret == OCSP_CERT_UNKNOWN || + ret == OCSP_LOOKUP_FAIL) { + ret = 0; + } - i++; - FreeOcspRequest(request); - } - } + i++; + FreeOcspRequest(request); + } + } } XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); @@ -20538,13 +20538,13 @@ const char* wolfSSL_ERR_func_error_string(unsigned long e) /* return library name * @param e error code - * @return text library name, + * @return text library name, * if there is no suitable library found, returns empty string */ const char* wolfSSL_ERR_lib_error_string(unsigned long e) { int libe = 0; - + (void)libe; (void)e; @@ -20798,7 +20798,7 @@ static const CipherSuiteInfo cipher_names[] = #endif #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM - SUITE_INFO("ECDHE-ECDSA-AES128-CCM","TLS_ECDHE_ECDSA_WITH_AES_128_CCM",ECC_BYTE,TLS_ECDHE_ECDSA_WITH_AES_128_CCM, TLSv1_2_MINOR, SSLv3_MAJOR), + SUITE_INFO("ECDHE-ECDSA-AES128-CCM","TLS_ECDHE_ECDSA_WITH_AES_128_CCM",ECC_BYTE,TLS_ECDHE_ECDSA_WITH_AES_128_CCM, TLSv1_2_MINOR, SSLv3_MAJOR), #endif #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 @@ -21125,18 +21125,18 @@ const char* GetCipherSegment(const WOLFSSL_CIPHER* cipher, char n[][MAX_SEGMENT_ int strLen; unsigned long offset; const char* name; - + /* sanity check */ if (cipher == NULL || n == NULL) return NULL; - + offset = cipher->offset; - + if (offset >= (unsigned long)GetCipherNamesSize()) return NULL; - + name = cipher_names[offset].name; - + if (name == NULL) return NULL; @@ -21149,11 +21149,11 @@ const char* GetCipherSegment(const WOLFSSL_CIPHER* cipher, char n[][MAX_SEGMENT_ * and n = [n0,n1,n2,n3,0] */ strLen = (int)XSTRLEN(name); - + for (i = 0, j = 0, k = 0; i <= strLen; i++) { if (k >= MAX_SEGMENTS || j >= MAX_SEGMENT_SZ) break; - + if (name[i] != '-' && name[i] != '\0') { n[k][j] = name[i]; /* Fill kth segment string until '-' */ j++; @@ -21164,7 +21164,7 @@ const char* GetCipherSegment(const WOLFSSL_CIPHER* cipher, char n[][MAX_SEGMENT_ k++; } } - + return name; } @@ -21312,14 +21312,14 @@ int IsCipherAEAD(char n[][MAX_SEGMENT_SZ]) n1 = n[1]; n2 = n[2]; n3 = n[3]; - + WOLFSSL_ENTER("IsCipherAEAD"); if (n == NULL) { WOLFSSL_MSG("bad function argumet. n is NULL."); return 0; } - + if ((XSTRNCMP(n2,"GCM",3) == 0) || (XSTRNCMP(n3,"GCM",3) == 0) || (XSTRNCMP(n1,"CCM",3) == 0) || (XSTRNCMP(n2,"CCM",3) == 0) || (XSTRNCMP(n3,"CCM",3) == 0) || @@ -29127,11 +29127,11 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, #ifndef WOLFSSL_NO_TLS12 /** - * Handles session resumption. + * Handles session resumption. * Session tickets are checked for validity based on the time each ticket * was created, timeout value and the current time. If the tickets are - * judged expired, falls back to full-handshake. If you want disable this - * session ticket validation check in TLS1.2 and below, define + * judged expired, falls back to full-handshake. If you want disable this + * sessin ticket validation check in TLS1.2 and below, define * WOLFSSL_NO_TICKET_EXPRE. */ int HandleTlsResumption(WOLFSSL* ssl, int bogusID, Suites* clSuites) @@ -30928,7 +30928,7 @@ static int TicketEncDec(byte* key, int keyLen, byte* iv, byte* aad, int aadSz, * Generate a new key if the current ones are expired. * If the secondary key has not been used and the primary key has expired then * generate a new primary key. - * + * * @param [in] Ticket encryption callback context. * @param [in] Session ticket lifetime. * @param [out] Index of key to use for encryption. @@ -32760,9 +32760,9 @@ int wolfSSL_set_iotsafe_ctx(WOLFSSL *ssl, IOTSAFE *iotsafe) WOLFSSL_BY_DIR_HASH* wolfSSL_BY_DIR_HASH_new(void) { WOLFSSL_BY_DIR_HASH* dir_hash; - + WOLFSSL_ENTER("wolfSSL_BY_DIR_HASH_new"); - + dir_hash = (WOLFSSL_BY_DIR_HASH*)XMALLOC(sizeof(WOLFSSL_BY_DIR_HASH), NULL, DYNAMIC_TYPE_OPENSSL); if (dir_hash) { @@ -32782,9 +32782,9 @@ void wolfSSL_BY_DIR_HASH_free(WOLFSSL_BY_DIR_HASH* dir_hash) WOLFSSL_STACK* wolfSSL_sk_BY_DIR_HASH_new_null(void) { WOLFSSL_STACK* sk = wolfSSL_sk_new_node(NULL); - + WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_new_null"); - + if (sk) { sk->type = STACK_TYPE_BY_DIR_hash; } @@ -32801,7 +32801,7 @@ int wolfSSL_sk_BY_DIR_HASH_find( int i, sz; WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_find"); - + if (sk == NULL || toFind == NULL) { return WOLFSSL_FAILURE; } @@ -32820,7 +32820,7 @@ int wolfSSL_sk_BY_DIR_HASH_find( int wolfSSL_sk_BY_DIR_HASH_num(const WOLF_STACK_OF(WOLFSSL_BY_DIR_HASH) *sk) { WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_num"); - + if (sk == NULL) return -1; return (int)sk->num; @@ -32844,9 +32844,9 @@ WOLFSSL_BY_DIR_HASH* wolfSSL_sk_BY_DIR_HASH_pop( { WOLFSSL_STACK* node; WOLFSSL_BY_DIR_HASH* hash; - + WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_pop"); - + if (sk == NULL) { return NULL; } @@ -32925,7 +32925,7 @@ int wolfSSL_sk_BY_DIR_HASH_push(WOLF_STACK_OF(WOLFSSL_BY_DIR_HASH)* sk, WOLFSSL_STACK* node; WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_push"); - + if (sk == NULL || in == NULL) { return WOLFSSL_FAILURE; } @@ -32960,12 +32960,12 @@ int wolfSSL_sk_BY_DIR_HASH_push(WOLF_STACK_OF(WOLFSSL_BY_DIR_HASH)* sk, WOLFSSL_BY_DIR_entry* wolfSSL_BY_DIR_entry_new(void) { WOLFSSL_BY_DIR_entry* entry; - + WOLFSSL_ENTER("wolfSSL_BY_DIR_entry_new"); - + entry = (WOLFSSL_BY_DIR_entry*)XMALLOC(sizeof(WOLFSSL_BY_DIR_entry), NULL, DYNAMIC_TYPE_OPENSSL); - + if (entry) { XMEMSET(entry, 0, sizeof(WOLFSSL_BY_DIR_entry)); } @@ -32975,7 +32975,7 @@ WOLFSSL_BY_DIR_entry* wolfSSL_BY_DIR_entry_new(void) void wolfSSL_BY_DIR_entry_free(WOLFSSL_BY_DIR_entry* entry) { WOLFSSL_ENTER("wolfSSL_BY_DIR_entry_free"); - + if (entry == NULL) return; @@ -32986,16 +32986,16 @@ void wolfSSL_BY_DIR_entry_free(WOLFSSL_BY_DIR_entry* entry) if (entry->dir_name != NULL) { XFREE(entry->dir_name, NULL, DYNAMIC_TYPE_OPENSSL); } - + XFREE(entry, NULL, DYNAMIC_TYPE_OPENSSL); } WOLFSSL_STACK* wolfSSL_sk_BY_DIR_entry_new_null(void) { WOLFSSL_STACK* sk = wolfSSL_sk_new_node(NULL); - + WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_entry_new_null"); - + if (sk) { sk->type = STACK_TYPE_BY_DIR_entry; } @@ -33005,7 +33005,7 @@ WOLFSSL_STACK* wolfSSL_sk_BY_DIR_entry_new_null(void) int wolfSSL_sk_BY_DIR_entry_num(const WOLF_STACK_OF(WOLFSSL_BY_DIR_entry) *sk) { WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_entry_num"); - + if (sk == NULL) return -1; return (int)sk->num; @@ -33031,7 +33031,7 @@ WOLFSSL_BY_DIR_entry* wolfSSL_sk_BY_DIR_entry_pop( WOLFSSL_BY_DIR_entry* entry; WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_entry_pop"); - + if (sk == NULL) { return NULL; } diff --git a/src/sniffer.c b/src/sniffer.c index 6a26406e7..6112b018c 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -148,7 +148,7 @@ enum { PSEUDO_HDR_SZ = 12, /* TCP Pseudo Header size in bytes */ FATAL_ERROR_STATE = 1, /* SnifferSession fatal error state */ TICKET_HINT_LEN = 4, /* Session Ticket Hint length */ - TICKET_HINT_AGE_LEN= 4, /* Session Ticket Age add length */ + TICKET_HINT_AGE_LEN= 4, /* Session Ticket Age add length */ EXT_TYPE_SZ = 2, /* Extension type length */ MAX_INPUT_SZ = MAX_RECORD_SIZE + COMP_EXTRA + MAX_MSG_EXTRA + MTU_EXTRA, /* Max input sz of reassembly */ @@ -188,26 +188,26 @@ BOOL APIENTRY DllMain( HMODULE hModule, LPVOID lpReserved ) { - static int didInit = 0; + static int didInit = 0; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - if (didInit == 0) { + if (didInit == 0) { dllModule = hModule; - ssl_InitSniffer(); - didInit = 1; - } + ssl_InitSniffer(); + didInit = 1; + } break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: - if (didInit) { - ssl_FreeSniffer(); - didInit = 0; - } + if (didInit) { + ssl_FreeSniffer(); + didInit = 0; + } break; } return TRUE; @@ -363,7 +363,7 @@ static const char* const msgTable[] = /* *nix version uses table above */ static void GetError(int idx, char* str) { - if (str == NULL || + if (str == NULL || idx < 0 || idx > (int)(sizeof(msgTable)/sizeof(const char* const))) return; XSTRNCPY(str, msgTable[idx - 1], MAX_ERROR_LEN-1); @@ -769,7 +769,7 @@ void ssl_FreeSniffer(void) srv = srv->next; FreeSnifferServer(removeServer); } - ServerList = NULL; + ServerList = NULL; wc_UnLockMutex(&SessionMutex); wc_UnLockMutex(&ServerListMutex); @@ -1074,10 +1074,10 @@ static void TraceSetNamedServer(const char* name, if (TraceOn) { XFPRINTF(TraceFile, "\tTrying to install a new Sniffer Server with\n"); XFPRINTF(TraceFile, "\tname: %s, server: %s, port: %d, keyFile: %s\n", - name ? name : "", - srv ? srv : "", - port, - keyFile ? keyFile : ""); + name ? name : "", + srv ? srv : "", + port, + keyFile ? keyFile : ""); } } @@ -1543,7 +1543,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz, return -1; } fileSz = keySz; - XMEMCPY(loadBuf, keyFile, fileSz); + XMEMCPY(loadBuf, keyFile, fileSz); } if (typeKey == WOLFSSL_FILETYPE_PEM) { @@ -1607,7 +1607,7 @@ static int CreateWatchSnifferServer(char* error) } #ifdef WOLF_CRYPTO_CB if (CryptoDeviceId != INVALID_DEVID) - wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId); + wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId); #endif /* add to server list */ @@ -1725,7 +1725,7 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port, if (isEphemeralKey) { /* auto detect key type with WC_PK_TYPE_NONE */ /* keySz == 0 mean load file */ - ret = wolfSSL_CTX_set_ephemeral_key(sniffer->ctx, WC_PK_TYPE_NONE, + ret = wolfSSL_CTX_set_ephemeral_key(sniffer->ctx, WC_PK_TYPE_NONE, keyFile, keySz, type); if (ret == 0) ret = WOLFSSL_SUCCESS; @@ -1747,9 +1747,9 @@ static int SetNamedPrivateKey(const char* name, const char* address, int port, FreeSnifferServer(sniffer); return -1; } - #ifdef WOLF_CRYPTO_CB - wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId); - #endif + #ifdef WOLF_CRYPTO_CB + wolfSSL_CTX_SetDevId(sniffer->ctx, CryptoDeviceId); + #endif } #ifdef HAVE_SNI else { @@ -1795,7 +1795,7 @@ int ssl_SetNamedPrivateKey(const char* name, int ssl_SetNamedPrivateKeyBuffer(const char* name, const char* address, int port, - const char* keyBuf, int keySz, int typeKey, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error) { int ret; @@ -1817,8 +1817,8 @@ int ssl_SetNamedPrivateKeyBuffer(const char* name, /* Sets the private key for a specific server and port */ /* returns 0 on success, -1 on error */ -int ssl_SetPrivateKey(const char* address, int port, - const char* keyFile, int typeKey, +int ssl_SetPrivateKey(const char* address, int port, + const char* keyFile, int typeKey, const char* password, char* error) { int ret; @@ -1838,7 +1838,7 @@ int ssl_SetPrivateKey(const char* address, int port, } int ssl_SetPrivateKeyBuffer(const char* address, int port, - const char* keyBuf, int keySz, int typeKey, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error) { int ret; @@ -1867,82 +1867,82 @@ int ssl_SetNamedEphemeralKey(const char* name, const char* password, char* error) { int ret; - + TraceHeader(); TraceSetNamedServer(name, address, port, keyFile); - + wc_LockMutex(&ServerListMutex); ret = SetNamedPrivateKey(name, address, port, keyFile, 0, typeKey, password, error, 1); wc_UnLockMutex(&ServerListMutex); - + if (ret == 0) Trace(NEW_SERVER_STR); - + return ret; } int ssl_SetNamedEphemeralKeyBuffer(const char* name, const char* address, int port, - const char* keyBuf, int keySz, int typeKey, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error) { int ret; - + TraceHeader(); TraceSetNamedServer(name, address, port, NULL); - + wc_LockMutex(&ServerListMutex); ret = SetNamedPrivateKey(name, address, port, keyBuf, keySz, typeKey, password, error, 1); wc_UnLockMutex(&ServerListMutex); - + if (ret == 0) Trace(NEW_SERVER_STR); - + return ret; } #endif /* HAVE_SNI */ /* Sets the ephemeral key for a specific server and port */ /* returns 0 on success, -1 on error */ -int ssl_SetEphemeralKey(const char* address, int port, - const char* keyFile, int typeKey, +int ssl_SetEphemeralKey(const char* address, int port, + const char* keyFile, int typeKey, const char* password, char* error) { int ret; - + TraceHeader(); TraceSetServer(address, port, keyFile); - + wc_LockMutex(&ServerListMutex); ret = SetNamedPrivateKey(NULL, address, port, keyFile, 0, typeKey, password, error, 1); wc_UnLockMutex(&ServerListMutex); - + if (ret == 0) Trace(NEW_SERVER_STR); - + return ret; } -int ssl_SetEphemeralKeyBuffer(const char* address, int port, - const char* keyBuf, int keySz, int typeKey, +int ssl_SetEphemeralKeyBuffer(const char* address, int port, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error) { int ret; - + TraceHeader(); TraceSetServer(address, port, "from buffer"); - + wc_LockMutex(&ServerListMutex); ret = SetNamedPrivateKey(NULL, address, port, keyBuf, keySz, typeKey, password, error, 1); wc_UnLockMutex(&ServerListMutex); - + if (ret == 0) Trace(NEW_SERVER_STR); - + return ret; } #endif /* WOLFSSL_STATIC_EPHEMERAL */ @@ -2174,7 +2174,7 @@ typedef struct { #endif } KeyBuffers_t; -static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, +static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, char* error, KeyShareInfo* ksInfo, KeyBuffers_t* keys) { word32 idx = 0; @@ -2353,7 +2353,7 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, ret = wc_DhSetNamedKey(&dhKey, ksInfo->named_group); #endif if (ret == 0) { - ret = wc_DhKeyDecode(keyBuf->buffer, &idx, &dhKey, + ret = wc_DhKeyDecode(keyBuf->buffer, &idx, &dhKey, keyBuf->length); } #ifndef HAVE_PUBLIC_FFDHE @@ -2364,7 +2364,7 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, } #endif if (ret == 0) { - ret = wc_DhExportKeyPair(&dhKey, privKey, &privKeySz, NULL, + ret = wc_DhExportKeyPair(&dhKey, privKey, &privKeySz, NULL, NULL); } @@ -2406,7 +2406,7 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, if (ret == 0 && p_len > session->sslServer->arrays->preMasterSz) { word32 diff = p_len - session->sslServer->arrays->preMasterSz; XMEMMOVE(session->sslServer->arrays->preMasterSecret + diff, - session->sslServer->arrays->preMasterSecret, + session->sslServer->arrays->preMasterSecret, session->sslServer->arrays->preMasterSz); XMEMSET(session->sslServer->arrays->preMasterSecret, 0, diff); session->sslServer->arrays->preMasterSz = p_len; @@ -2420,7 +2420,7 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, /* Static ECC Key */ if (useCurveId >= 0 && keys->ecKey #ifdef HAVE_CURVE25519 - && useCurveId != ECC_X25519 + && useCurveId != ECC_X25519 #endif ) { ecc_key key; @@ -2609,8 +2609,8 @@ static int SetupKeys(const byte* input, int* sslBytes, SnifferSession* session, session->sslServer->arrays->preMasterSz; #ifdef SHOW_SECRETS - PrintSecret("pre master secret", - session->sslServer->arrays->preMasterSecret, + PrintSecret("pre master secret", + session->sslServer->arrays->preMasterSecret, session->sslServer->arrays->preMasterSz); #endif @@ -2802,7 +2802,7 @@ static int ProcessServerKeyShare(SnifferSession* session, const byte* input, int int ret; if (session->cliKeyShare == NULL || session->cliKeyShareSz == 0) { - /* session->cliKeyShareSz could not be provided yet if the client_hello + /* session->cliKeyShareSz could not be provided yet if the client_hello did not send a key share to force a hello_retry_request */ return 0; } @@ -2820,7 +2820,7 @@ static int ProcessServerKeyShare(SnifferSession* session, const byte* input, int } return ret; -} +} #endif /* WOLFSSL_TLS13 */ /* Process Session Ticket */ @@ -2929,7 +2929,7 @@ static int ProcessSessionTicket(const byte* input, int* sslBytes, /* store session with macID as sessionID */ session->sslServer->options.haveSessionId = 1; if (session->sslServer->arrays) { - XMEMCPY(session->sslServer->arrays->sessionID, + XMEMCPY(session->sslServer->arrays->sessionID, input + len - ID_LEN, ID_LEN); } } @@ -2944,7 +2944,7 @@ static int DoResume(SnifferSession* session, char* error) #ifdef WOLFSSL_TLS13 if (IsAtLeastTLSv1_3(session->sslServer->version)) { - resume = GetSession(session->sslServer, + resume = GetSession(session->sslServer, session->sslServer->session.masterSecret, 0); if (resume == NULL) { /* TLS v1.3 with hello_retry uses session_id even for new session, @@ -3001,11 +3001,11 @@ static int DoResume(SnifferSession* session, char* error) session->sslServer->arrays->psk_keySz = session->sslServer->specs.hash_size; session->sslClient->arrays->psk_keySz = session->sslClient->specs.hash_size; ret = DeriveResumptionPSK(session->sslServer, - session->sslServer->session.ticketNonce.data, + session->sslServer->session.ticketNonce.data, session->sslServer->session.ticketNonce.len, session->sslServer->arrays->psk_key); /* Copy resumption PSK to client */ - XMEMCPY(session->sslClient->arrays->psk_key, + XMEMCPY(session->sslClient->arrays->psk_key, session->sslServer->arrays->psk_key, session->sslServer->arrays->psk_keySz); #endif @@ -3179,7 +3179,7 @@ static int ProcessServerHello(int msgSz, const byte* input, int* sslBytes, case EXT_KEY_SHARE: ret = ProcessServerKeyShare(session, input, extLen, error); if (ret != 0) { - SetError(SERVER_HELLO_INPUT_STR, error, session, + SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE); return -1; } @@ -3254,8 +3254,8 @@ static int ProcessServerHello(int msgSz, const byte* input, int* sslBytes, if (XMEMCMP(session->sslServer->arrays->sessionID, session->sslClient->arrays->sessionID, ID_LEN) == 0) { doResume = 1; - } - } + } + } else if (session->sslClient->options.haveSessionId == 0 && session->sslServer->options.haveSessionId == 0 && session->ticketID) { @@ -3290,9 +3290,9 @@ static int ProcessServerHello(int msgSz, const byte* input, int* sslBytes, #endif /* hash server_hello */ - HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, initialBytes + HANDSHAKE_HEADER_SZ); - HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, initialBytes + HANDSHAKE_HEADER_SZ); if (doResume) { @@ -3332,7 +3332,7 @@ static int ProcessServerHello(int msgSz, const byte* input, int* sslBytes, #endif #endif - ret = SetupKeys(session->cliKs.key, &session->cliKs.key_len, + ret = SetupKeys(session->cliKs.key, &session->cliKs.key_len, session, error, &session->cliKs, &keys); if (ret != 0) { SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE); @@ -3365,15 +3365,15 @@ static int LoadNamedKey(SnifferSession* session, const byte* name, word16 nameSz #ifdef WOLFSSL_STATIC_EPHEMERAL if (namedKey->isEphemeralKey) { /* auto detect key type with WC_PK_TYPE_NONE */ - ret = wolfSSL_set_ephemeral_key(ssl, - WC_PK_TYPE_NONE, (const char*)namedKey->key, + ret = wolfSSL_set_ephemeral_key(ssl, + WC_PK_TYPE_NONE, (const char*)namedKey->key, namedKey->keySz, WOLFSSL_FILETYPE_ASN1); } else #endif { ret = wolfSSL_use_PrivateKey_buffer(ssl, - namedKey->key, namedKey->keySz, + namedKey->key, namedKey->keySz, WOLFSSL_FILETYPE_ASN1); /* translate return code */ ret = (ret == WOLFSSL_SUCCESS) ? 0 : -1; @@ -3598,7 +3598,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes, idx += idLen; /* Obfuscated Ticket Age 32-bits */ - ticketAge = (word32)((input[idx] << 24) | (input[idx+1] << 16) | + ticketAge = (word32)((input[idx] << 24) | (input[idx+1] << 16) | (input[idx+2] << 8) | input[idx+3]); (void)ticketAge; /* not used */ idx += OPAQUE32_LEN; @@ -3615,9 +3615,9 @@ static int ProcessClientHello(const byte* input, int* sslBytes, (void)binders; /* not used */ /* Hash data up to binders for deriving binders in PSK extension. */ - HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, inputHelloSz - bindersLen + HANDSHAKE_HEADER_SZ); - HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, inputHelloSz - bindersLen + HANDSHAKE_HEADER_SZ); /* call to decrypt session ticket */ @@ -3668,9 +3668,9 @@ static int ProcessClientHello(const byte* input, int* sslBytes, } if (!didHash) { - HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslServer, inputHello - HANDSHAKE_HEADER_SZ, inputHelloSz + HANDSHAKE_HEADER_SZ); - HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, + HashRaw(session->sslClient, inputHello - HANDSHAKE_HEADER_SZ, inputHelloSz + HANDSHAKE_HEADER_SZ); } @@ -3785,7 +3785,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes, #ifdef WOLFSSL_TLS13 if (IsAtLeastTLSv1_3(ssl->version)) { - ret = DoTls13Finished(ssl, input, &inOutIdx, (word32)size, + ret = DoTls13Finished(ssl, input, &inOutIdx, (word32)size, (word32)*sslBytes, SNIFF); ssl->options.handShakeState = HANDSHAKE_DONE; @@ -3794,7 +3794,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes, else #endif { - ret = DoFinished(ssl, input, &inOutIdx, (word32)size, + ret = DoFinished(ssl, input, &inOutIdx, (word32)size, (word32)*sslBytes, SNIFF); } *sslBytes -= (int)inOutIdx; @@ -3841,7 +3841,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes, session->flags.gotFinished = 1; #ifdef SHOW_SECRETS - ShowTlsSecrets(session); + ShowTlsSecrets(session); #endif } @@ -3971,7 +3971,7 @@ static int DoHandShake(const byte* input, int* sslBytes, /* For resumption the hash is before / after client_hello PSK binder */ /* hash the packet including header */ /* TLS v1.3 requires the hash for the handshake and transfer key derivation */ - /* we hash even for non TLS v1.3, since we don't know if its actually + /* we hash even for non TLS v1.3, since we don't know if its actually TLS v1.3 till later at EXT_SUPPORTED_VERSIONS in server_hello */ /* hello retry request restarts hash prior to server_hello hash calc */ HashRaw(session->sslServer, input - HANDSHAKE_HEADER_SZ, size + HANDSHAKE_HEADER_SZ); @@ -4215,7 +4215,7 @@ static const byte* DecryptMessage(WOLFSSL* ssl, const byte* input, word32 sz, { int ivExtra = 0; int ret; - + #ifdef WOLFSSL_TLS13 if (IsAtLeastTLSv1_3(ssl->version)) { ret = DecryptTls13(ssl, output, input, sz, (byte*)rh, RECORD_HEADER_SZ); @@ -4574,7 +4574,7 @@ static int CheckHeaders(IpInfo* ipInfo, TcpInfo* tcpInfo, const byte* packet, SetError(PACKET_HDR_SHORT_STR, error, NULL, 0); return -1; } - + /* We only care about the data in the TCP/IP record. There may be extra * data after the IP record for the FCS for Ethernet. */ *sslBytes = (int)(packet + ipInfo->total - *sslFrame); @@ -4861,7 +4861,7 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session, /* adjust to expected, remove duplicate */ *sslFrame += overlap; *sslBytes -= overlap; - + newEnd = *expected + *sslBytes; if (newEnd > reassemblyList->begin) { Trace(OVERLAP_REASSEMBLY_BEGIN_STR); @@ -4891,7 +4891,7 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session, /* This can happen with unseen acks, out of order packets, or * possible spurious retransmission. */ if (*sslBytes > 0) { - /* If packet has data attempt to process packet, if hasn't + /* If packet has data attempt to process packet, if hasn't * already been ack'd during handshake */ if (FindPrevAck(session, real)) { Trace(DUPLICATE_STR); @@ -5025,7 +5025,7 @@ static int FindNextRecordInAssembly(SnifferSession* session, return 0; } else if (ssl->specs.cipher_type == block) { - int ivPos = (int)(curr->end - curr->begin - + int ivPos = (int)(curr->end - curr->begin - ssl->specs.block_size + 1); if (ssl->specs.bulk_cipher_algorithm == wolfssl_aes) { #ifdef BUILD_AES @@ -5071,7 +5071,7 @@ static int FixSequence(TcpInfo* tcpInfo, SnifferSession* session) &session->flags.cliSkipPartial; *skipPartial = 1; - + if (list != NULL) *expected = list->begin; else @@ -5417,7 +5417,7 @@ doMessage: recordEnd = sslFrame + rhSize; /* may have more than one record */ inRecordEnd = recordEnd; - /* Make sure cipher is on for client, if we get an application data packet + /* Make sure cipher is on for client, if we get an application data packet * and handhsake is done for server. This workaround is required if client * handshake packets were missed, retransmitted or sent out of order. */ if ((enum ContentType)rh.type == application_data && @@ -6075,7 +6075,7 @@ int ssl_SetWatchKey_buffer(void* vSniffer, const byte* key, word32 keySz, #ifdef WOLFSSL_STATIC_EPHEMERAL /* try setting static ephemeral first */ /* auto detect key type with WC_PK_TYPE_NONE */ - ret = wolfSSL_set_ephemeral_key(sniffer->sslServer, + ret = wolfSSL_set_ephemeral_key(sniffer->sslServer, WC_PK_TYPE_NONE, (const char*)key, keySz, WOLFSSL_FILETYPE_ASN1); if (ret != 0) { diff --git a/src/ssl.c b/src/ssl.c index fa69038d7..a0f6eb64a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1964,8 +1964,8 @@ int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz, keySz = ssl->buffers.keySz; #endif InitSuites(ssl->suites, ssl->version, keySz, haveRSA, havePSK, - ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveDH, ssl->options.haveECDSAsig, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); } @@ -4420,8 +4420,8 @@ int wolfSSL_SetVersion(WOLFSSL* ssl, int version) #endif InitSuites(ssl->suites, ssl->version, keySz, haveRSA, havePSK, - ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveDH, ssl->options.haveECDSAsig, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); @@ -5586,7 +5586,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der *keyFormat = ED25519k; if (ssl != NULL) { - /* ED25519 requires caching enabled for tracking message + /* ED25519 requires caching enabled for tracking message * hash used in EdDSA_Update for signing */ ssl->options.cacheMessages = 1; if (ssl->options.side == WOLFSSL_SERVER_END) { @@ -5648,7 +5648,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der *keyFormat = ED448k; if (ssl != NULL) { - /* ED448 requires caching enabled for tracking message + /* ED448 requires caching enabled for tracking message * hash used in EdDSA_Update for signing */ ssl->options.cacheMessages = 1; if (ssl->options.side == WOLFSSL_SERVER_END) { @@ -6325,7 +6325,7 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, /* let's reset suites */ InitSuites(ssl->suites, ssl->version, keySz, haveRSA, havePSK, ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); } @@ -8062,7 +8062,7 @@ WOLFSSL_PKCS8_PRIV_KEY_INFO* wolfSSL_d2i_PKCS8_PKEY( if (ret == 0) { pkcs8->pkey.ptr = (char*)XMALLOC(der->length, NULL, DYNAMIC_TYPE_PUBLIC_KEY); - if (pkcs8->pkey.ptr == NULL) + if (pkcs8->pkey.ptr == NULL) ret = MEMORY_E; } if (ret == 0) { @@ -8813,7 +8813,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_id(int type, WOLFSSL_EVP_PKEY** out, key = (ecc_key*)local->ecc->internal; key->devId = devId; key->type = ECC_PRIVATEKEY; - /* key is required to have a key size / curve set, although + /* key is required to have a key size / curve set, although * actual one used is determined by devId callback function */ wc_ecc_set_curve(key, ECDHE_SIZE, ECC_CURVE_DEF); @@ -9134,7 +9134,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_EXTENSION_dup(WOLFSSL_X509_EXTENSION* src) } if (err == 0) { ret->crit = src->crit; - if (wolfSSL_ASN1_STRING_copy(&ret->value, &src->value) != + if (wolfSSL_ASN1_STRING_copy(&ret->value, &src->value) != WOLFSSL_SUCCESS) { err = 1; } @@ -15570,7 +15570,7 @@ int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session) row = idx >> SESSIDX_ROW_SHIFT; col = idx & SESSIDX_IDX_MASK; - if (session == NULL || + if (session == NULL || row < 0 || row >= SESSION_ROWS || col >= SESSIONS_PER_ROW) { return WOLFSSL_FAILURE; } @@ -16126,8 +16126,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) keySz = ssl->buffers.keySz; #endif InitSuites(ssl->suites, ssl->version, keySz, haveRSA, TRUE, - ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveDH, ssl->options.haveECDSAsig, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); } @@ -16179,8 +16179,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) keySz = ssl->buffers.keySz; #endif InitSuites(ssl->suites, ssl->version, keySz, haveRSA, TRUE, - ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveDH, ssl->options.haveECDSAsig, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); } @@ -18170,7 +18170,7 @@ int wolfSSL_CTX_set_max_proto_version(WOLFSSL_CTX* ctx, int version) } /* when 0 is specified as version, try to find out the min version from - * the bottom to top of the protoverTbl. + * the bottom to top of the protoverTbl. */ for (i = NUMBER_OF_PROTOCOLS -1; i >= 0; i--) { ret = Set_CTX_max_proto_version(ctx, protoVerTbl[i]); @@ -18350,7 +18350,7 @@ int wolfSSL_set_max_proto_version(WOLFSSL* ssl, int version) } /* when 0 is specified as version, try to find out the min version from - * the bottom to top of the protoverTbl. + * the bottom to top of the protoverTbl. */ for (i = NUMBER_OF_PROTOCOLS -1; i >= 0; i--) { ret = Set_SSL_max_proto_version(ssl, protoVerTbl[i]); @@ -21841,7 +21841,7 @@ void wolfSSL_GENERAL_NAMES_free(WOLFSSL_GENERAL_NAMES *gens) } #if defined(OPENSSL_ALL) && !defined(NO_BIO) -/* Outputs name string of the given WOLFSSL_GENERAL_NAME_OBJECT to WOLFSSL_BIO. +/* Outputs name string of the given WOLFSSL_GENERAL_NAME_OBJECT to WOLFSSL_BIO. * Can handle following GENERAL_NAME_OBJECT types: * - GEN_OTHERNAME # * - GEN_EMAIL @@ -21853,13 +21853,13 @@ void wolfSSL_GENERAL_NAMES_free(WOLFSSL_GENERAL_NAMES *gens) * - GEN_RID * The each name string to be output has "typename:namestring" format. * For instance, email name string will be output as "email:info@wolfssl.com". - * However,some types above marked with "#" will be output with + * However,some types above marked with "#" will be output with * "typename:". - * + * * Parameters: * - out: WOLFSSL_BIO object which is the output destination * - gen: WOLFSSL_GENERAL_NAME object to be output its name - * + * * Returns WOLFSSL_SUCCESS on success, WOLFSSL_FAILURE on failure. */ int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out, WOLFSSL_GENERAL_NAME* gen) @@ -21913,7 +21913,7 @@ int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out, WOLFSSL_GENERAL_NAME* gen) XN_FLAG_ONELINE); } break; - + case GEN_EDIPARTY: ret = wolfSSL_BIO_printf(out, "EdiPartyName:"); ret = (ret > 0) ? WOLFSSL_SUCCESS : WOLFSSL_FAILURE; @@ -21940,14 +21940,14 @@ int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out, WOLFSSL_GENERAL_NAME* gen) p = (unsigned char*)gen->d.iPAddress->strData; if (gen->d.iPAddress->length == 4) { - ret = wolfSSL_BIO_printf(out, ":%d.%d.%d.%d", + ret = wolfSSL_BIO_printf(out, ":%d.%d.%d.%d", p[0],p[1],p[2],p[3]); } else if (gen->d.iPAddress->length == 16) { for (i = 0; i < 16 && ret == WOLFSSL_SUCCESS;) { wd = p[i] << 8 | p[i+1]; - + i += 2; ret = wolfSSL_BIO_printf(out, ":%X", wd); ret = (ret > 0) ? WOLFSSL_SUCCESS : WOLFSSL_FAILURE; @@ -25307,20 +25307,20 @@ int wolfSSL_CIPHER_get_cipher_nid(const WOLFSSL_CIPHER* cipher) {"HC128", NID_undef}, {NULL, NID_undef} }; - + const struct ciphernid* c; const char* encStr; char n[MAX_SEGMENTS][MAX_SEGMENT_SZ] = {{0}}; - + WOLFSSL_ENTER("wolfSSL_CIPHER_get_cipher_nid"); - + if (GetCipherSegment(cipher, n) == NULL) { WOLFSSL_MSG("no suitable cipher name found"); return NID_undef; } encStr = GetCipherEncStr(n); - + if (encStr != NULL) { for(c = ciphernid_tbl; c->alg_name != NULL; c++) { if (XSTRNCMP(c->alg_name, encStr, XSTRLEN(c->alg_name)) == 0) { @@ -25328,7 +25328,7 @@ int wolfSSL_CIPHER_get_cipher_nid(const WOLFSSL_CIPHER* cipher) } } } - + return NID_undef; } /* return digest NID corresponding to cipher suite @@ -25346,27 +25346,27 @@ int wolfSSL_CIPHER_get_digest_nid(const WOLFSSL_CIPHER* cipher) {"SHA384", NID_sha384}, {NULL, NID_undef} }; - + const struct macnid* mc; const char* name; const char* macStr; char n[MAX_SEGMENTS][MAX_SEGMENT_SZ] = {{0}}; (void)name; - + WOLFSSL_ENTER("wolfSSL_CIPHER_get_digest_nid"); - + if ((name = GetCipherSegment(cipher, n)) == NULL) { WOLFSSL_MSG("no suitable cipher name found"); return NID_undef; } - + /* in MD5 case, NID will be NID_md5 */ if (XSTRSTR(name, "MD5") != NULL) { return NID_md5; } - + macStr = GetCipherMacStr(n); - + if (macStr != NULL) { for(mc = macnid_tbl; mc->alg_name != NULL; mc++) { if (XSTRNCMP(mc->alg_name, macStr, XSTRLEN(mc->alg_name)) == 0) { @@ -25374,7 +25374,7 @@ int wolfSSL_CIPHER_get_digest_nid(const WOLFSSL_CIPHER* cipher) } } } - + return NID_undef; } /* return key exchange NID corresponding to cipher suite @@ -25397,27 +25397,27 @@ static const struct kxnid { {"RSA", NID_kx_rsa}, {NULL, NID_undef} }; - + const struct kxnid* k; const char* name; const char* keaStr; char n[MAX_SEGMENTS][MAX_SEGMENT_SZ] = {{0}}; (void)name; - + WOLFSSL_ENTER("wolfSSL_CIPHER_get_kx_nid"); - + if ((name = GetCipherSegment(cipher, n)) == NULL) { WOLFSSL_MSG("no suitable cipher name found"); return NID_undef; } - + /* in TLS 1.3 case, NID will be NID_kx_any */ if (XSTRNCMP(name, "TLS13", 5) == 0) { return NID_kx_any; } - + keaStr = GetCipherKeaStr(n); - + if (keaStr != NULL) { for(k = kxnid_table; k->name != NULL; k++) { if (XSTRNCMP(k->name, keaStr, XSTRLEN(k->name)) == 0) { @@ -25426,7 +25426,7 @@ static const struct kxnid { } } } - + return NID_undef; } /* check if cipher suite is AEAD @@ -25443,7 +25443,7 @@ int wolfSSL_CIPHER_is_aead(const WOLFSSL_CIPHER* cipher) WOLFSSL_MSG("no suitable cipher name found"); return NID_undef; } - + return IsCipherAEAD(n); } /* Creates cipher->description based on cipher->offset @@ -25480,7 +25480,7 @@ int wolfSSL_sk_CIPHER_description(WOLFSSL_CIPHER* cipher) pv.major = cipher_names[offset].major; pv.minor = cipher_names[offset].minor; protocol = wolfSSL_internal_get_version(&pv); - + if ((name = GetCipherSegment(cipher, n)) == NULL) { WOLFSSL_MSG("no suitable cipher name found"); return WOLFSSL_FAILURE; @@ -27246,7 +27246,7 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip_asc(WOLFSSL_X509_VERIFY_PARAM *param, return ret; } -/* Sets the expected IP address to ip(asc) +/* Sets the expected IP address to ip(asc) * by re-constructing IP address in ascii * @param param is a pointer to the X509_VERIFY_PARAM structure * @param ip in binary format of ip address @@ -27288,26 +27288,26 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, /* ipv6 normal address scheme * y1:y2:y3:y4:y5:y6:y7:y8, len(yx):4, len(y1-y8):32. len(":"):7 * Max len is 32 + 7 + 1(Termination) = 40 bytes - * + * * ipv6 dual address * Or y1:y2:y3:y4:y:y6:x.x.x.x yx is 4, y1-y6 is 24, ":" is 6 * x.x.x.x is 15. * Max len is 24 + 6 + 15 + 1(Termination) = 46 bytes - * + * * Expect data in ip[16] * e.g (aaaa):(bbbb):(cccc):....(hhhh) * (aaaa) = (ip[0<<8)|ip[1] * ...... * (hhhh) = (ip[14]<<8)|(ip[15]) - * + * * e.g ::(gggg):(hhhh) * ip[0]-[11] = 0 * (gggg) = (ip[12]<<8) |(ip[13]) * (hhhh) = (ip[14]<<8) |(ip[15]) - * + * * Because it is not able to know which ivp6 scheme uses from data to - * reconstruct IP address, this function assumes - * ivp6 normal address scheme, not dual adress scheme, + * reconstruct IP address, this function assumes + * ivp6 normal address scheme, not dual adress scheme, * to re-construct IP address in ascii. */ buf = (char*)XMALLOC(max_ipv6_len, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -27349,7 +27349,7 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, if ((*p) == ':') { /* when the last character is :, the followig segments are zero * Therefore, adding : and null termination - */ + */ p++; *p++ = ':'; *p = '\0'; @@ -27371,7 +27371,7 @@ int wolfSSL_X509_VERIFY_PARAM_set1_ip(WOLFSSL_X509_VERIFY_PARAM* param, (void)ip; (void)iplen; #endif - + return ret; } @@ -28645,8 +28645,8 @@ long wolfSSL_set_options(WOLFSSL* ssl, long op) if (ssl->suites != NULL && ssl->options.side != WOLFSSL_NEITHER_END) InitSuites(ssl->suites, ssl->version, keySz, haveRSA, havePSK, - ssl->options.haveDH, ssl->options.haveECDSAsig, - ssl->options.haveECC, ssl->options.haveStaticECC, + ssl->options.haveDH, ssl->options.haveECDSAsig, + ssl->options.haveECC, ssl->options.haveStaticECC, ssl->options.haveFalconSig, ssl->options.haveAnon, ssl->options.side); @@ -29247,16 +29247,16 @@ WOLFSSL_API WOLFSSL_EVP_PKEY *wolfSSL_get_privatekey(const WOLFSSL *ssl) /** * Get a textual representation of given WOLFSSL_ASN1_OBJECT then write it to - * buf at most buf_len bytes. - * + * buf at most buf_len bytes. + * * params * - buf: buffer where the textual representation is to be written to * - buf_len: buffer size in bytes * - a: WOLFSSL_ASN1_OBJECT - * + * * return the string length written on success, WOLFSSL_FAILURE on failure. */ -WOLFSSL_API int wolfSSL_i2t_ASN1_OBJECT(char *buf, int buf_len, +WOLFSSL_API int wolfSSL_i2t_ASN1_OBJECT(char *buf, int buf_len, WOLFSSL_ASN1_OBJECT *a) { WOLFSSL_ENTER("wolfSSL_i2t_ASN1_OBJECT"); @@ -29488,7 +29488,7 @@ WOLFSSL_API size_t wolfSSL_get_peer_finished(const WOLFSSL *ssl, void *buf, size { byte len = 0; WOLFSSL_ENTER("SSL_get_peer_finished"); - + if (!ssl || !buf || count < TLS_FINISHED_SZ) { WOLFSSL_MSG("Bad parameter"); return WOLFSSL_FAILURE; @@ -29579,21 +29579,21 @@ WOLFSSL_API long wolfSSL_set_tlsext_status_ocsp_resp(WOLFSSL *s, unsigned char * * @param mode maximum fragment length mode * @return 1 on success, otherwise 0 or negative error code */ -WOLFSSL_API int wolfSSL_CTX_set_tlsext_max_fragment_length(WOLFSSL_CTX *c, +WOLFSSL_API int wolfSSL_CTX_set_tlsext_max_fragment_length(WOLFSSL_CTX *c, unsigned char mode) -{ +{ if (c == NULL || (mode < WOLFSSL_MFL_2_9 || mode > WOLFSSL_MFL_2_12 )) return BAD_FUNC_ARG; return wolfSSL_CTX_UseMaxFragment(c, mode); } /** - * Set max fragment tls extension + * Set max fragment tls extension * @param c a pointer to WOLFSSL object * @param mode maximum fragment length mode * @return 1 on success, otherwise 0 or negative error code */ -WOLFSSL_API int wolfSSL_set_tlsext_max_fragment_length(WOLFSSL *s, +WOLFSSL_API int wolfSSL_set_tlsext_max_fragment_length(WOLFSSL *s, unsigned char mode) { if (s == NULL || (mode < WOLFSSL_MFL_2_9 || mode > WOLFSSL_MFL_2_12 )) @@ -33332,7 +33332,7 @@ int wolfSSL_DH_set0_pqg(WOLFSSL_DH *dh, WOLFSSL_BIGNUM *p, return WOLFSSL_SUCCESS; } #endif /* v1.1.0 or later */ -#endif /* !HAVE_FIPS || (HAVE_FIPS && !WOLFSSL_DH_EXTRA) || +#endif /* !HAVE_FIPS || (HAVE_FIPS && !WOLFSSL_DH_EXTRA) || * HAVE_FIPS_VERSION > 2 */ void wolfSSL_DH_get0_key(const WOLFSSL_DH *dh, @@ -33697,7 +33697,7 @@ static int wolfSSL_RSA_generate_key_native(WOLFSSL_RSA* rsa, int bits, WOLFSSL_B WOLFSSL_MSG("SetRsaExternal failed"); else { rsa->inSet = 1; - ret = WOLFSSL_ERROR_NONE; + ret = WOLFSSL_ERROR_NONE; } wc_FreeRng(rng); @@ -35692,8 +35692,8 @@ int wolfSSL_CMAC_Init(WOLFSSL_CMAC_CTX* ctx, const void *key, size_t keyLen, WOLFSSL_ENTER("wolfSSL_CMAC_Init"); if (ctx == NULL || cipher == NULL || ( - cipher != EVP_AES_128_CBC && - cipher != EVP_AES_192_CBC && + cipher != EVP_AES_128_CBC && + cipher != EVP_AES_192_CBC && cipher != EVP_AES_256_CBC)) { ret = WOLFSSL_FAILURE; } @@ -37515,7 +37515,7 @@ int wolfSSL_ECDSA_sign(int type, return ret; } -int wolfSSL_ECDSA_verify(int type, +int wolfSSL_ECDSA_verify(int type, const unsigned char *digest, int digestSz, const unsigned char *sig, int sigSz, WOLFSSL_EC_KEY *key) { @@ -42771,7 +42771,7 @@ cleanup: } out: - if (der) + if (der) XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret; @@ -43519,7 +43519,7 @@ err: /* unused */ (void)cb; (void)u; - (void)derSz; + (void)derSz; return NULL; } @@ -44048,11 +44048,11 @@ err: (*info)->x509 = x509; - //@TODO info->num - //@TODO info->enc_cipher - //@TODO info->enc_len - //@TODO info->enc_data - //@TODO info->crl + /* @TODO info->num */ + /* @TODO info->enc_cipher */ + /* @TODO info->enc_len */ + /* @TODO info->enc_data */ + /* @TODO info->crl */ (*info)->x_pkey = wolfSSL_X509_PKEY_new(x509->heap); return wolfSSL_X509_PKEY_set((*info)->x_pkey, x509); @@ -55711,7 +55711,7 @@ static int SetStaticEphemeralKey(StaticKeyExchangeInfo_t* staticKE, int keyAlgo, } #endif #ifdef HAVE_CURVE25519 - if (keyAlgo == WC_PK_TYPE_CURVE25519 && staticKE->x25519Key && + if (keyAlgo == WC_PK_TYPE_CURVE25519 && staticKE->x25519Key && staticKE->weOwnX25519) { FreeDer(&staticKE->x25519Key); } diff --git a/src/tls.c b/src/tls.c index 1506d9a0e..92b2f4034 100644 --- a/src/tls.c +++ b/src/tls.c @@ -119,7 +119,7 @@ static int TLSX_PopulateSupportedGroups(WOLFSSL* ssl, TLSX** extensions); #endif #ifdef WOLFSSL_RENESAS_TSIP_TLS - + #if (WOLFSSL_RENESAS_TSIP_VER >=109) int tsip_generateMasterSecretEx( @@ -131,14 +131,14 @@ static int TLSX_PopulateSupportedGroups(WOLFSSL* ssl, TLSX** extensions); byte* ms); #elif (WOLFSSL_RENESAS_TSIP_VER >=106) - + int tsip_generateMasterSecret( const byte* pre, const byte* cr, const byte* sr, byte* ms); - - #endif + + #endif int tsip_useable(const WOLFSSL *ssl); int tsip_generateSeesionKey(WOLFSSL *ssl); @@ -551,17 +551,17 @@ int MakeTlsMasterSecret(WOLFSSL* ssl) #if defined(WOLFSSL_RENESAS_TSIP_TLS) && \ !defined(NO_WOLFSSL_RENESAS_TSIP_TLS_SESSION) if (tsip_useable(ssl)) { - + #if (WOLFSSL_RENESAS_TSIP_VER>=109) ret = tsip_generateMasterSecretEx( ssl->options.cipherSuite0, - ssl->options.cipherSuite, + ssl->options.cipherSuite, &ssl->arrays->preMasterSecret[VERSION_SZ], ssl->arrays->clientRandom, ssl->arrays->serverRandom, ssl->arrays->tsip_masterSecret); - + #elif (WOLFSSL_RENESAS_TSIP_VER>=106) ret = tsip_generateMasterSecret( @@ -3015,7 +3015,7 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length, #endif #if !defined(NO_WOLFSSL_CLIENT) && defined(WOLFSSL_TLS13) \ - || !defined(NO_WOLFSSL_SERVER) + || !defined(NO_WOLFSSL_SERVER) word32 offset = 0; #endif @@ -3050,7 +3050,7 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length, case WOLFSSL_CSR_OCSP: /* propagate nonce */ if (csr->request.ocsp.nonceSz) { - request = + request = (OcspRequest*)TLSX_CSR_GetRequest(ssl->extensions); if (request) { @@ -5519,7 +5519,7 @@ static int TLSX_SupportedVersions_Write(void* data, byte* output, } #ifdef WOLFSSL_ALLOW_TLSV10 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - if ((ssl->options.mask & SSL_OP_NO_TLSv1) == 0 && + if ((ssl->options.mask & SSL_OP_NO_TLSv1) == 0 && (ssl->options.minDowngrade <= TLSv1_MINOR)) #endif { @@ -6214,7 +6214,7 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse) if (kse->privKey == NULL) ret = MEMORY_E; } - + if (ret == 0) { #if defined(WOLFSSL_STATIC_EPHEMERAL) && defined(WOLFSSL_DH_EXTRA) if (ssl->staticKE.dhKey) { @@ -6224,7 +6224,7 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse) ret = wc_DhKeyDecode(keyDer->buffer, &idx, dhKey, keyDer->length); if (ret == 0) { - ret = wc_DhExportKeyPair(dhKey, + ret = wc_DhExportKeyPair(dhKey, (byte*)kse->privKey, &kse->keyLen, /* private */ kse->pubKey, &kse->pubKeyLen /* public */ ); @@ -6234,7 +6234,7 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse) #endif { /* Generate a new key pair */ - /* For async this is called once and when event is done, the + /* For async this is called once and when event is done, the * provided buffers will be populated. * Final processing is zero pad below. */ ret = DhGenKeyPair(ssl, dhKey, @@ -6273,7 +6273,7 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse) #endif } - /* Always release the DH key to free up memory. + /* Always release the DH key to free up memory. * The DhKey will be setup again in TLSX_KeyShare_ProcessDh */ if (dhKey != NULL) wc_FreeDhKey(dhKey); @@ -6445,7 +6445,7 @@ static int TLSX_KeyShare_GenX448Key(WOLFSSL *ssl, KeyShareEntry* kse) } kse->pubKeyLen = CURVE448_KEY_SIZE; /* always CURVE448_KEY_SIZE */ } - + #ifdef WOLFSSL_DEBUG_TLS if (ret == 0) { WOLFSSL_MSG("Public Curve448 Key"); @@ -6553,7 +6553,7 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse) ret = wc_ecc_set_curve(eccKey, kse->keyLen, curveId); if (ret == 0) { /* Generate ephemeral ECC key */ - /* For async this is called once and when event is done, the + /* For async this is called once and when event is done, the * provided buffers in key be populated. * Final processing is x963 key export below. */ ret = EccMakeKey(ssl, eccKey, eccKey); @@ -7307,7 +7307,7 @@ static int TLSX_KeyShare_ProcessEcc(WOLFSSL* ssl, KeyShareEntry* keyShareEntry) /* unsupported curve */ return ECC_PEERKEY_ERROR; } - + #ifdef WOLFSSL_ASYNC_CRYPT if (keyShareEntry->lastRet == 0) /* don't enter here if WC_PENDING_E */ #endif @@ -7782,7 +7782,7 @@ static int TLSX_KeyShare_Parse(WOLFSSL* ssl, const byte* input, word16 length, return BUFFER_ERROR; /* Not in list sent if there isn't a private key. */ - if (keyShareEntry == NULL || (keyShareEntry->key == NULL + if (keyShareEntry == NULL || (keyShareEntry->key == NULL #if !defined(NO_DH) || defined(HAVE_LIBOQS) && keyShareEntry->privKey == NULL #endif @@ -8536,7 +8536,7 @@ int TLSX_KeyShare_Establish(WOLFSSL *ssl, int* doHelloRetry) if (clientKSE == NULL) { /* Set KEY_SHARE_ERROR to indicate HelloRetryRequest required. */ *doHelloRetry = 1; - return TLSX_KeyShare_SetSupported(ssl); + return TLSX_KeyShare_SetSupported(ssl); } list = NULL; @@ -8565,7 +8565,7 @@ int TLSX_KeyShare_Establish(WOLFSSL *ssl, int* doHelloRetry) } /* for async do setup of serverKSE below, but return WC_PENDING_E */ - if (ret != 0 + if (ret != 0 #ifdef WOLFSSL_ASYNC_CRYPT && ret != WC_PENDING_E #endif @@ -9444,16 +9444,16 @@ static int TLSX_EarlyData_Parse(WOLFSSL* ssl, const byte* input, word16 length, return BUFFER_E; if (ssl->earlyData == expecting_early_data) { - + if (ssl->options.maxEarlyDataSz != 0) ssl->earlyDataStatus = WOLFSSL_EARLY_DATA_ACCEPTED; else ssl->earlyDataStatus = WOLFSSL_EARLY_DATA_REJECTED; - + return TLSX_EarlyData_Use(ssl, 0); } ssl->earlyData = early_data_ext; - + return 0; } if (msgType == encrypted_extensions) { @@ -10404,7 +10404,7 @@ int TLSX_PopulateExtensions(WOLFSSL* ssl, byte isServer) ret = 0; } #endif /* !(HAVE_ECC || CURVE25519 || CURVE448) && HAVE_SUPPORTED_CURVES */ - + #if !defined(NO_CERTS) && !defined(WOLFSSL_NO_SIGALG) if (ssl->certHashSigAlgoSz > 0) { WOLFSSL_MSG("Adding signature algorithms cert extension"); diff --git a/src/tls13.c b/src/tls13.c index 81af312fb..ae82ccdc6 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -3313,7 +3313,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, args->idx += OPAQUE16_LEN; #ifndef WOLFSSL_NO_TLS12 - if (args->pv.major == ssl->version.major && + if (args->pv.major == ssl->version.major && args->pv.minor < TLSv1_2_MINOR && ssl->options.downgrade) { @@ -3323,7 +3323,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return DoServerHello(ssl, input, inOutIdx, helloSz); } #endif - if (args->pv.major != ssl->version.major || + if (args->pv.major != ssl->version.major || args->pv.minor != TLSv1_2_MINOR) { return VERSION_ERROR; } @@ -3409,7 +3409,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return BUFFER_ERROR; /* Need to negotiate version first. */ - if ((ret = TLSX_ParseVersion(ssl, input + args->idx, + if ((ret = TLSX_ParseVersion(ssl, input + args->idx, args->totalExtSz, *extMsgType, &foundVersion))) { return ret; } @@ -3434,7 +3434,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, ssl->version.minor = args->pv.minor; } } - + /* Advance state and proceed */ ssl->options.asyncState = TLS_ASYNC_BUILD; } /* case TLS_ASYNC_BEGIN */ @@ -3448,7 +3448,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, if (args->totalExtSz > 0) { /* Parse and handle extensions. */ - ret = TLSX_Parse(ssl, input + args->idx, args->totalExtSz, + ret = TLSX_Parse(ssl, input + args->idx, args->totalExtSz, *extMsgType, NULL); if (ret != 0) { #ifdef WOLFSSL_ASYNC_CRYPT @@ -3496,7 +3496,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return BUFFER_ERROR; } else if (ssl->arrays->sessionIDSz) { - XMEMCPY(ssl->arrays->sessionID, args->sessId, + XMEMCPY(ssl->arrays->sessionID, args->sessId, ssl->arrays->sessionIDSz); ssl->options.haveSessionId = 1; } @@ -3527,18 +3527,18 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return INVALID_PARAMETER; if (ssl->session.sessionIDSz != 0) { if (ssl->session.sessionIDSz != args->sessIdSz || - XMEMCMP(ssl->session.sessionID, args->sessId, + XMEMCMP(ssl->session.sessionID, args->sessId, args->sessIdSz) != 0) { return INVALID_PARAMETER; } } - else if (XMEMCMP(ssl->arrays->clientRandom, args->sessId, + else if (XMEMCMP(ssl->arrays->clientRandom, args->sessId, args->sessIdSz) != 0) { return INVALID_PARAMETER; } #else if (args->sessIdSz != ssl->session.sessionIDSz || (args->sessIdSz > 0 && - XMEMCMP(ssl->session.sessionID, args->sessId, args->sessIdSz) != 0)) + XMEMCMP(ssl->session.sessionID, args->sessId, args->sessIdSz) != 0)) { WOLFSSL_MSG("Server sent different session id"); return INVALID_PARAMETER; @@ -4226,7 +4226,7 @@ static int CheckPreSharedKeys(WOLFSSL* ssl, const byte* input, word32 helloSz, ext != NULL) { /* Only use named group used in last session. */ ssl->namedGroup = ssl->session.namedGroup; - + *usingPSK = 2; /* generate new ephemeral key */ } else @@ -4236,7 +4236,7 @@ static int CheckPreSharedKeys(WOLFSSL* ssl, const byte* input, word32 helloSz, return PSK_KEY_ERROR; ssl->options.noPskDheKe = 1; ssl->arrays->preMasterSz = 0; - + *usingPSK = 1; } } @@ -4515,7 +4515,7 @@ typedef struct Dch13Args { word32 begin; int usingPSK; } Dch13Args; - + static void FreeDch13Args(WOLFSSL* ssl, void* pArgs) { Dch13Args* args = (Dch13Args*)pArgs; @@ -4612,7 +4612,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, ssl->version.minor = args->pv.minor; } else { - ret = DoTls13SupportedVersions(ssl, input + args->begin, + ret = DoTls13SupportedVersions(ssl, input + args->begin, args->idx - args->begin, helloSz, &wantDowngrade); if (ret < 0) goto exit_dch; @@ -4745,7 +4745,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, if ((ext = TLSX_Find(ssl->extensions, TLSX_COOKIE)) == NULL) ERROR_OUT(HRR_COOKIE_ERROR, exit_dch); - + /* Ensure the cookie came from client and isn't the one in the * response - HelloRetryRequest. */ @@ -4812,7 +4812,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, goto exit_dch; } } - else + else #endif #ifdef HAVE_SUPPORTED_CURVES if (args->usingPSK == 2) { @@ -4840,7 +4840,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, ssl->options.clientState = CLIENT_HELLO_COMPLETE; if (!args->usingPSK) { -#ifndef NO_CERTS +#ifndef NO_CERTS #ifdef HAVE_NULL_CIPHER if (ssl->options.cipherSuite0 == ECC_BYTE && (ssl->options.cipherSuite == TLS_SHA256_SHA256 || diff --git a/src/wolfio.c b/src/wolfio.c index 4c7efad88..28da546a1 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -368,7 +368,7 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx) if (recvd < 0) { WOLFSSL_MSG("Embed Receive From error"); recvd = TranslateIoError(recvd); - if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && + if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && !wolfSSL_dtls_get_using_nonblock(ssl)) { recvd = WOLFSSL_CBIO_ERR_TIMEOUT; } @@ -436,7 +436,7 @@ int EmbedReceiveFromMcast(WOLFSSL *ssl, char *buf, int sz, void *ctx) if (recvd < 0) { WOLFSSL_MSG("Embed Receive From error"); recvd = TranslateIoError(recvd); - if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && + if (recvd == WOLFSSL_CBIO_ERR_WANT_READ && !wolfSSL_dtls_get_using_nonblock(ssl)) { recvd = WOLFSSL_CBIO_ERR_TIMEOUT; } diff --git a/sslSniffer/sslSnifferTest/snifftest.c b/sslSniffer/sslSnifferTest/snifftest.c index 171662be8..10f47f30d 100644 --- a/sslSniffer/sslSnifferTest/snifftest.c +++ b/sslSniffer/sslSnifferTest/snifftest.c @@ -410,9 +410,6 @@ int main(int argc, char** argv) #ifndef _WIN32 ssl_InitSniffer(); /* dll load on Windows */ -#endif -#ifdef DEBUG_WOLFSSL - //wolfSSL_Debugging_ON(); #endif ssl_Trace("./tracefile.txt", err); ssl_EnableRecovery(1, -1, err); diff --git a/support/include.am b/support/include.am index db3ed7387..113eee022 100644 --- a/support/include.am +++ b/support/include.am @@ -6,5 +6,3 @@ EXTRA_DIST += support/wolfssl.pc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = support/wolfssl.pc - - diff --git a/swig/wolfssl_adds.c b/swig/wolfssl_adds.c index 74356eda7..080206f4e 100644 --- a/swig/wolfssl_adds.c +++ b/swig/wolfssl_adds.c @@ -43,7 +43,7 @@ #include #include #ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */ - #include + #include #include #endif #define SOCKET_T int diff --git a/tests/api.c b/tests/api.c index 884b3e9dd..20800ef9c 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1156,11 +1156,11 @@ static void test_wolfSSL_CertManagerCheckOCSPResponse(void) defined(HAVE_LIGHTY) WOLFSSL_CERT_MANAGER* cm = NULL; /* Raw OCSP response bytes captured using the following setup: - * - Run responder with + * - Run responder with * openssl ocsp -port 9999 -ndays 9999 * -index certs/ocsp/index-intermediate1-ca-issued-certs.txt * -rsigner certs/ocsp/ocsp-responder-cert.pem - * -rkey certs/ocsp/ocsp-responder-key.pem + * -rkey certs/ocsp/ocsp-responder-key.pem * -CA certs/ocsp/intermediate1-ca-cert.pem * - Run client with * openssl ocsp -host 127.0.0.1:9999 -respout resp.out @@ -3454,7 +3454,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void) BIO_gets(wbio, line, sizeof(line)); strcpy(line1, - " 00:C2:35:2D:EC:83:83:6C:73:13:9E:52:7C:74:C8:\n"); + " 00:C2:35:2D:EC:83:83:6C:73:13:9E:52:7C:74:C8:\n"); AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of pub element*/ @@ -4371,7 +4371,7 @@ static int nonblocking_accept_read(void* args, WOLFSSL* ssl, SOCKET_T* sockfd) /* TODO: Expand and enable this when EVP_chacha20_poly1305 is supported */ #if defined(HAVE_SESSION_TICKET) && defined(OPENSSL_EXTRA) && \ - defined(HAVE_AES_CBC) + defined(HAVE_AES_CBC) typedef struct openssl_key_ctx { byte name[WOLFSSL_TICKET_NAME_SZ]; /* server name */ @@ -4651,7 +4651,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) XMEMSET(server_side_msg2, 0, MD_MAX_SIZE); msg_len = wolfSSL_get_peer_finished(ssl, server_side_msg2, MD_MAX_SIZE); AssertIntGE(msg_len, 0); - + XMEMSET(server_side_msg1, 0, MD_MAX_SIZE); msg_len = wolfSSL_get_finished(ssl, server_side_msg1, MD_MAX_SIZE); AssertIntGE(msg_len, 0); @@ -5327,7 +5327,7 @@ static void test_client_verifyDepth(void* args) #if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && !defined(NO_WOLFSSL_CLIENT) SOCKET_T sockfd = 0; callback_functions* cbf; - + WOLFSSL_CTX* ctx = 0; WOLFSSL* ssl = 0; @@ -5337,10 +5337,10 @@ static void test_client_verifyDepth(void* args) int msgSz = (int)XSTRLEN(msg); int ret, err = 0; int verify_depth = ((func_args*)args)->argc; - + ((func_args*)args)->return_code = TEST_FAIL; cbf = ((func_args*)args)->callbacks; - + { WOLFSSL_METHOD* method = NULL; if (cbf != NULL && cbf->method != NULL) { @@ -5351,12 +5351,12 @@ static void test_client_verifyDepth(void* args) } ctx = wolfSSL_CTX_new(method); } - + /* Do connect here so server detects failures */ tcp_connect(&sockfd, wolfSSLIP, ((func_args*)args)->signal->port, 0, 0, NULL); - if (wolfSSL_CTX_load_verify_locations(ctx, caCertFile, 0) + if (wolfSSL_CTX_load_verify_locations(ctx, caCertFile, 0) != WOLFSSL_SUCCESS) { /* err_sys("can't load ca file, Please run from wolfSSL home dir");*/ @@ -5374,9 +5374,9 @@ static void test_client_verifyDepth(void* args) "Please run from wolfSSL home dir");*/ goto done; } - + SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify); - + /* set verify depth */ if (verify_depth == 0) { myVerifyAction = VERIFY_OVERRIDE_ERROR; @@ -5388,7 +5388,7 @@ static void test_client_verifyDepth(void* args) myVerifyAction = VERIFY_USE_PREVERFIY; SSL_CTX_set_verify_depth(ctx, verify_depth); } - + ssl = wolfSSL_new(ctx); if (ssl == NULL) { goto done; @@ -5476,7 +5476,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) ((func_args*)args)->return_code = TEST_FAIL; #ifdef WOLFSSL_STATIC_MEMORY - if (callbacks->method_ex != NULL && callbacks->mem != NULL && + if (callbacks->method_ex != NULL && callbacks->mem != NULL && callbacks->memSz > 0) { ret = wolfSSL_CTX_load_static_memory(&ctx, callbacks->method_ex, callbacks->mem, callbacks->memSz, 0, 1); @@ -5686,7 +5686,7 @@ static void run_wolfssl_client(void* args) callbacks->keyPemFile = cliKeyFile; #ifdef WOLFSSL_STATIC_MEMORY - if (callbacks->method_ex != NULL && callbacks->mem != NULL && + if (callbacks->method_ex != NULL && callbacks->mem != NULL && callbacks->memSz > 0) { ret = wolfSSL_CTX_load_static_memory(&ctx, callbacks->method_ex, callbacks->mem, callbacks->memSz, 0, 1); @@ -5716,7 +5716,7 @@ static void run_wolfssl_client(void* args) wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); #endif - AssertIntEQ(WOLFSSL_SUCCESS, + AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_load_verify_locations(ctx, callbacks->caPemFile, 0)); if (!callbacks->loadToSSL) { @@ -5724,7 +5724,7 @@ static void run_wolfssl_client(void* args) wolfSSL_CTX_use_certificate_file(ctx, callbacks->certPemFile, WOLFSSL_FILETYPE_PEM)); - AssertIntEQ(WOLFSSL_SUCCESS, + AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_use_PrivateKey_file(ctx, callbacks->keyPemFile, WOLFSSL_FILETYPE_PEM)); } @@ -5750,7 +5750,7 @@ static void run_wolfssl_client(void* args) wolfSSL_use_certificate_file(ssl, callbacks->certPemFile, WOLFSSL_FILETYPE_PEM)); - AssertIntEQ(WOLFSSL_SUCCESS, + AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_use_PrivateKey_file(ssl, callbacks->keyPemFile, WOLFSSL_FILETYPE_PEM)); } @@ -5942,19 +5942,19 @@ static void test_wolfSSL_CTX_verifyDepth_ServerClient(void) func_args server_args; THREAD_TYPE serverThread; callback_functions client_cbf; - + XMEMSET(&client_args, 0, sizeof(func_args)); XMEMSET(&server_args, 0, sizeof(func_args)); XMEMSET(&client_cbf, 0, sizeof(callback_functions)); - + printf(testingFmt, "test_wolfSSL_CTX_verifyDepth_ServerClient()\n"); - + #ifdef WOLFSSL_TLS13 client_cbf.method = wolfTLSv1_3_client_method; #endif /* WOLFSSL_TLS13 */ - + client_args.callbacks = &client_cbf; - + StartTCP(); InitTcpReady(&ready); @@ -5967,32 +5967,32 @@ static void test_wolfSSL_CTX_verifyDepth_ServerClient(void) client_args.signal = &ready; /* the var is used for loop number */ server_args.argc = 1; - + /* test case 1 verify depth is equal to peer chain */ { start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - + /* the var is used for verify depth */ client_args.argc = 2; - + test_client_verifyDepth(&client_args); join_thread(serverThread); AssertIntEQ(client_args.return_code, TEST_SUCCESS); AssertIntEQ(server_args.return_code, TEST_SUCCESS); } - - /* test case 2 + + /* test case 2 * verify depth is zero, number of peer's chain is 2. * verify result becomes MAX_CHAIN_ERROR, but it is overridden in * callback. */ - + /* the var is used for verify depth 0 and VERIFY_OVERRIDE_ERROR */ { start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - + client_args.argc = 0; test_client_verifyDepth(&client_args); join_thread(serverThread); @@ -6008,14 +6008,14 @@ static void test_wolfSSL_CTX_verifyDepth_ServerClient(void) { start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - + client_args.argc = -1; test_client_verifyDepth(&client_args); join_thread(serverThread); AssertIntEQ(client_args.return_code, TEST_SUCCESS); AssertIntEQ(server_args.return_code, TEST_SUCCESS); } - + FreeTcpReady(&ready); printf(resultFmt, passed); #else @@ -6040,7 +6040,7 @@ static void test_client_get_finished(void* args, cbType cb) int ret, err = 0; WOLFSSL_METHOD* method = NULL; size_t msg_len = 0; - + ((func_args*)args)->return_code = TEST_FAIL; cbf = ((func_args*)args)->callbacks; @@ -6051,7 +6051,7 @@ static void test_client_get_finished(void* args, cbType cb) method = wolfSSLv23_client_method(); } ctx = wolfSSL_CTX_new(method); - + /* Do connect here so server detects failures */ tcp_connect(&sockfd, wolfSSLIP, ((func_args*)args)->signal->port, 0, 0, NULL); @@ -6108,7 +6108,7 @@ static void test_client_get_finished(void* args, cbType cb) printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); goto done; } - + /* get_finished test */ /* 1. get own sent message */ XMEMSET(client_side_msg1, 0, MD_MAX_SIZE); @@ -6172,7 +6172,7 @@ done: static void test_wolfSSL_get_finished(void) { #if defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_WPAS) - + tcp_ready ready; func_args client_args; func_args server_args; @@ -7047,7 +7047,7 @@ static void test_wolfSSL_UseSNI_connection(void) { callback_functions client_cb; callback_functions server_cb; - + XMEMSET(&client_cb, 0, sizeof(callback_functions)); XMEMSET(&server_cb, 0, sizeof(callback_functions)); client_cb.method = wolfSSLv23_client_method; @@ -7315,12 +7315,12 @@ static void test_wolfSSL_UseMaxFragment(void) CTX_UseMaxFragment = SSL_CTX_set_tlsext_max_fragment_length; UseMaxFragment = SSL_set_tlsext_max_fragment_length; -#else +#else int (*UseMaxFragment)(WOLFSSL *s, unsigned char mode); int (*CTX_UseMaxFragment)(WOLFSSL_CTX *c, unsigned char mode); UseMaxFragment = wolfSSL_UseMaxFragment; - CTX_UseMaxFragment = wolfSSL_CTX_UseMaxFragment; + CTX_UseMaxFragment = wolfSSL_CTX_UseMaxFragment; #endif AssertNotNull(ctx); @@ -7565,7 +7565,7 @@ static void test_wolfSSL_UseALPN_connection(void) { callback_functions client_cb; callback_functions server_cb; - + XMEMSET(&client_cb, 0, sizeof(callback_functions)); XMEMSET(&server_cb, 0, sizeof(callback_functions)); client_cb.method = wolfSSLv23_client_method; @@ -7698,12 +7698,12 @@ static void CTX_set_alpn_protos(SSL_CTX *ctx) 6, 's', 'p', 'd', 'y', '/', '2', 6, 's', 'p', 'd', 'y', '/', '1', }; - + unsigned char p_len = sizeof(p); int ret; - + ret = SSL_CTX_set_alpn_protos(ctx, p, p_len); - + #ifdef WOLFSSL_ERROR_CODE_OPENSSL AssertIntEQ(ret, 0); #else @@ -7711,7 +7711,7 @@ static void CTX_set_alpn_protos(SSL_CTX *ctx) #endif } -static void set_alpn_protos(SSL* ssl) +static void set_alpn_protos(SSL* ssl) { unsigned char p[] = { 6, 's', 'p', 'd', 'y', '/', '3', @@ -7719,12 +7719,12 @@ static void set_alpn_protos(SSL* ssl) 6, 's', 'p', 'd', 'y', '/', '2', 6, 's', 'p', 'd', 'y', '/', '1', }; - + unsigned char p_len = sizeof(p); int ret; - + ret = SSL_set_alpn_protos(ssl, p, p_len); - + #ifdef WOLFSSL_ERROR_CODE_OPENSSL AssertIntEQ(ret, 0); #else @@ -7765,7 +7765,7 @@ static void test_wolfSSL_set_alpn_protos(void) { callback_functions client_cb; callback_functions server_cb; - + XMEMSET(&client_cb, 0, sizeof(callback_functions)); XMEMSET(&server_cb, 0, sizeof(callback_functions)); client_cb.method = wolfSSLv23_client_method; @@ -7978,7 +7978,7 @@ static void test_wolfSSL_PKCS12(void) /* check verify MAC directly */ ret = PKCS12_verify_mac(pkcs12, goodPsw, goodPswLen); - AssertIntEQ(ret, 1); + AssertIntEQ(ret, 1); /* check verify MAC fail case directly */ ret = PKCS12_verify_mac(pkcs12, badPsw, badPswLen); @@ -7989,7 +7989,7 @@ static void test_wolfSSL_PKCS12(void) AssertIntEQ(ret, 0); AssertNull(pkey); AssertNull(cert); - + /* check parse with no extra certs kept */ ret = PKCS12_parse(pkcs12, "wolfSSL test", &pkey, &cert, NULL); AssertIntEQ(ret, 1); @@ -10312,14 +10312,14 @@ static int test_wc_Sha512Update (void) #ifdef WOLFSSL_SHA512 #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && \ (!defined(WOLFSSL_NOSHA512_224) || !defined(WOLFSSL_NOSHA512_256)) -/* Perfoms test for +/* Perfoms test for * - wc_Sha512Final/wc_Sha512FinalRaw * - wc_Sha512_224Final/wc_Sha512_224Final * - wc_Sha512_256Final/wc_Sha512_256Final * parameter: * - type : must be one of WC_HASH_TYPE_SHA512, WC_HASH_TYPE_SHA512_224 or - * WC_HASH_TYPE_SHA512_256 - * - isRaw: if is non-zero, xxxFinalRaw function will be tested + * WC_HASH_TYPE_SHA512_256 + * - isRaw: if is non-zero, xxxFinalRaw function will be tested *return 0 on success */ static int test_Sha512_Family_Final(int type, int isRaw) @@ -10340,7 +10340,7 @@ static int test_Sha512_Family_Final(int type, int isRaw) #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && \ !defined(WOLFSSL_NO_HASH_RAW) finalFp = (isRaw)? wc_Sha512FinalRaw : wc_Sha512Final; -#else +#else finalFp = (isRaw)? NULL : wc_Sha512Final; #endif freeFp = wc_Sha512Free; @@ -10408,7 +10408,7 @@ static int test_Sha512_Family_Final(int type, int isRaw) freeFp(&sha512); return ret; } -#endif /* !HAVE_FIPS && !HAVE_SELFTEST && +#endif /* !HAVE_FIPS && !HAVE_SELFTEST && (!WOLFSSL_NOSHA512_224 || !WOLFSSL_NOSHA512_256) */ #endif /* WOLFSSL_SHA512 */ /* @@ -10606,13 +10606,13 @@ static int test_Sha512_Family_GetHash(int type ) int(*ghashFp)(wc_Sha512*, byte*); wc_Sha512 sha512; byte hash1[WC_SHA512_DIGEST_SIZE]; - + if (type == WC_HASH_TYPE_SHA512) { initFp = wc_InitSha512; ghashFp = wc_Sha512GetHash; } #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) -#if !defined(WOLFSSL_NOSHA512_224) +#if !defined(WOLFSSL_NOSHA512_224) else if (type == WC_HASH_TYPE_SHA512_224) { initFp = wc_InitSha512_224; ghashFp = wc_Sha512_224GetHash; @@ -10640,7 +10640,7 @@ static int test_Sha512_Family_GetHash(int type ) if (!flag) { flag = ghashFp(&sha512, hash1); } - + /*test bad arguements*/ if (!flag) { if (ghashFp(NULL, NULL) != BAD_FUNC_ARG ) @@ -10651,7 +10651,7 @@ static int test_Sha512_Family_GetHash(int type ) if (ghashFp(NULL, hash1) != BAD_FUNC_ARG ) flag = WOLFSSL_FATAL_ERROR; } - + if (!flag) { if (ghashFp(&sha512, NULL) != BAD_FUNC_ARG ) flag = WOLFSSL_FATAL_ERROR; @@ -10660,7 +10660,7 @@ static int test_Sha512_Family_GetHash(int type ) wc_Sha512Free(&sha512); return flag; } -#endif /* !HAVE_FIPS && !HAVE_SELFTEST && +#endif /* !HAVE_FIPS && !HAVE_SELFTEST && (!WOLFSSL_NOSHA512_224 || !WOLFSSL_NOSHA512_256) */ #endif /* WOLFSSL_SHA512 */ /* @@ -10761,7 +10761,7 @@ static int test_wc_Sha512Copy (void) static int test_wc_InitSha512_224 (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) wc_Sha512 sha512; int ret; @@ -10893,7 +10893,7 @@ static int test_wc_Sha512_224Update (void) static int test_wc_Sha512_224Final (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) printf(testingFmt, "wc_Sha512_224Final()"); flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_224, 0); @@ -10906,7 +10906,7 @@ static int test_wc_Sha512_224Final (void) static int test_wc_Sha512_224GetFlags (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) && defined(WOLFSSL_HASH_FLAGS) wc_Sha512 sha512, copy; word32 flags = 0; @@ -10938,7 +10938,7 @@ static int test_wc_Sha512_224GetFlags (void) #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ return flag; -} +} static int test_wc_Sha512_224FinalRaw (void) { @@ -10958,8 +10958,8 @@ static int test_wc_Sha512_224FinalRaw (void) static int test_wc_Sha512_224Free (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) -#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) printf(testingFmt, "wc_Sha512_224Free()"); wc_Sha512_224Free(NULL); @@ -10973,7 +10973,7 @@ static int test_wc_Sha512_224Free (void) static int test_wc_Sha512_224GetHash (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) printf(testingFmt, "wc_Sha512_224GetHash()"); flag = test_Sha512_Family_GetHash(WC_HASH_TYPE_SHA512_224); @@ -10986,7 +10986,7 @@ static int test_wc_Sha512_224GetHash (void) static int test_wc_Sha512_224Copy (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) wc_Sha512 sha512; wc_Sha512 temp; @@ -11028,7 +11028,7 @@ static int test_wc_Sha512_224Copy (void) static int test_wc_InitSha512_256 (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; int ret; @@ -11062,7 +11062,7 @@ static int test_wc_InitSha512_256 (void) static int test_wc_Sha512_256Update (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; byte hash[WC_SHA512_DIGEST_SIZE]; @@ -11161,7 +11161,7 @@ static int test_wc_Sha512_256Update (void) static int test_wc_Sha512_256Final (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) printf(testingFmt, "wc_Sha512_256Final()"); flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_256, 0); @@ -11174,7 +11174,7 @@ static int test_wc_Sha512_256Final (void) static int test_wc_Sha512_256GetFlags (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) && defined(WOLFSSL_HASH_FLAGS) wc_Sha512 sha512, copy; word32 flags = 0; @@ -11206,7 +11206,7 @@ static int test_wc_Sha512_256GetFlags (void) #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ return flag; -} +} static int test_wc_Sha512_256FinalRaw (void) { @@ -11225,8 +11225,8 @@ static int test_wc_Sha512_256FinalRaw (void) static int test_wc_Sha512_256Free (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) -#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) printf(testingFmt, "wc_Sha512_256Free()"); wc_Sha512_256Free(NULL); @@ -11253,7 +11253,7 @@ static int test_wc_Sha512_256GetHash (void) static int test_wc_Sha512_256Copy (void) { int flag = 0; -#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) +#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; wc_Sha512 temp; @@ -28189,7 +28189,7 @@ static void test_wc_PKCS7_EncodeDecodeEnvelopedData (void) #endif tempWrd32 = pkcs7->privateKeySz; pkcs7->privateKeySz = 0; - + AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, (word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG); pkcs7->privateKeySz = tempWrd32; @@ -30148,7 +30148,7 @@ static void test_wolfSSL_certs(void) AssertIntEQ(SSL_CTX_check_private_key(ctx), SSL_SUCCESS); #endif AssertNotNull(ssl = SSL_new(ctx)); - + #if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY) AssertIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS); #endif @@ -31345,10 +31345,10 @@ static void test_wolfSSL_PEM_PUBKEY(void) const char* fname = "./certs/ecc-client-keyPub.pem"; size_t sz; byte* buf; - + EVP_PKEY* pkey2; EC_KEY* ec_key; - + file = XFOPEN(fname, "rb"); AssertTrue((file != XBADFILE)); XFSEEK(file, 0, XSEEK_END); @@ -31365,7 +31365,7 @@ static void test_wolfSSL_PEM_PUBKEY(void) XFREE(buf, NULL, DYNAMIC_TYPE_FILE); BIO_free(bio); bio = NULL; - + /* Qt unit test case*/ AssertNotNull(pkey2 = EVP_PKEY_new()); AssertNotNull(ec_key = EVP_PKEY_get1_EC_KEY(pkey)); @@ -31375,7 +31375,7 @@ static void test_wolfSSL_PEM_PUBKEY(void) #else AssertIntEQ(EVP_PKEY_cmp(pkey, pkey2), 0); #endif - + EC_KEY_free(ec_key); EVP_PKEY_free(pkey2); EVP_PKEY_free(pkey); @@ -32437,7 +32437,7 @@ static void test_wolfSSL_X509_Name_canon(void) !defined(NO_FILESYSTEM) && !defined(NO_SHA) && \ defined(WOLFSSL_CERT_GEN) && \ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && !defined(NO_RSA) - + const long ex_hash1 = 0x0fdb2da4; const long ex_hash2 = 0x9f3e8c9e; X509_NAME *name = NULL; @@ -32454,10 +32454,10 @@ static void test_wolfSSL_X509_Name_canon(void) AssertNotNull(file); AssertNotNull(x509 = PEM_read_X509(file, NULL, NULL, NULL)); AssertNotNull(name = X509_get_issuer_name(x509)); - + AssertIntGT((len = wolfSSL_i2d_X509_NAME_canon(name, &pbuf)), 0); AssertIntEQ(wc_ShaHash((const byte*)pbuf, (word32)len, digest), 0); - + hash = (((unsigned long)digest[3] << 24) | ((unsigned long)digest[2] << 16) | ((unsigned long)digest[1] << 8) | @@ -32481,7 +32481,7 @@ static void test_wolfSSL_X509_Name_canon(void) ((unsigned long)digest[2] << 16) | ((unsigned long)digest[1] << 8) | ((unsigned long)digest[0])); - + AssertIntEQ(hash, ex_hash2); XFCLOSE(file); @@ -32498,39 +32498,39 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) { #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) const int MAX_DIR = 4; - const char paths[][32] = { + const char paths[][32] = { "./certs/ed25519", "./certs/ecc", "./certs/crl", "./certs/", }; - + char CertCrl_path[MAX_FILENAME_SZ]; char *p; X509_STORE* str; X509_LOOKUP* lookup; WOLFSSL_STACK* sk = NULL; int len, total_len, i; - + (void) sk; - + printf(testingFmt, "test_wolfSSL_X509_LOOKUP_ctrl_hash_dir()"); - + XMEMSET(CertCrl_path, 0, MAX_FILENAME_SZ); - + /* illegal string */ AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, "", + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, "", SSL_FILETYPE_PEM,NULL), 0); - + /* free store */ X509_STORE_free(str); - + /* short folder string */ AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, "./", + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, "./", SSL_FILETYPE_PEM,NULL), 1); #if defined(WOLFSSL_INT_H) /* only available when including internal.h */ @@ -32538,11 +32538,11 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) #endif /* free store */ X509_STORE_free(str); - + /* typical function check */ p = &CertCrl_path[0]; total_len = 0; - + for(i = MAX_DIR - 1; i>=0 && total_len < MAX_FILENAME_SZ; i--) { len = (int)XSTRLEN((const char*)&paths[i]); total_len += len; @@ -32550,18 +32550,18 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) p += len; if (i != 0) *(p++) = SEPARATOR_CHAR; } - + AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, CertCrl_path, + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_ADD_DIR, CertCrl_path, SSL_FILETYPE_PEM,NULL), 1); #if defined(WOLFSSL_INT_H) /* only available when including internal.h */ AssertNotNull(sk = lookup->dirs->dir_entry); #endif - + X509_STORE_free(str); - + printf(resultFmt, passed); #endif @@ -32572,7 +32572,7 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_file(void) #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \ defined(WOLFSSL_SIGNER_DER_CERT) - + X509_STORE_CTX* ctx; X509_STORE* str; X509_LOOKUP* lookup; @@ -32588,7 +32588,7 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_file(void) FILE* file1 = NULL; int i, cert_count, cmp; - + char der[] = "certs/ca-cert.der"; #ifdef HAVE_CRL @@ -32610,7 +32610,7 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_file(void) AssertNotNull(ctx = X509_STORE_CTX_new()); AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, caCertFile, + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, caCertFile, SSL_FILETYPE_PEM,NULL), 1); AssertNotNull(sk = wolfSSL_CertManagerGetCerts(str->cm)); AssertIntEQ((cert_count = sk_X509_num(sk)), 1); @@ -32646,7 +32646,7 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_file(void) AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, der, + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, der, SSL_FILETYPE_ASN1,NULL), 1); AssertNotNull(sk = wolfSSL_CertManagerGetCerts(str->cm)); AssertIntEQ((cert_count = sk_X509_num(sk)), 1); @@ -32659,39 +32659,39 @@ static void test_wolfSSL_X509_LOOKUP_ctrl_file(void) X509_STORE_free(str); sk_X509_free(sk); X509_free(cert1); - + #ifdef HAVE_CRL AssertNotNull(str = wolfSSL_X509_STORE_new()); AssertNotNull(lookup = X509_STORE_add_lookup(str, X509_LOOKUP_file())); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, caCertFile, + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, caCertFile, SSL_FILETYPE_PEM,NULL), 1); - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, - "certs/server-revoked-cert.pem", + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, + "certs/server-revoked-cert.pem", SSL_FILETYPE_PEM,NULL), 1); if (str) { AssertIntEQ(wolfSSL_CertManagerVerify(str->cm, svrCertFile, WOLFSSL_FILETYPE_PEM), 1); /* since store hasn't yet known the revoked cert*/ - AssertIntEQ(wolfSSL_CertManagerVerify(str->cm, + AssertIntEQ(wolfSSL_CertManagerVerify(str->cm, "certs/server-revoked-cert.pem", WOLFSSL_FILETYPE_PEM), 1); } for (i = 0; pem[i][0] != '\0'; i++) { - AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, pem[i], + AssertIntEQ(X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, pem[i], SSL_FILETYPE_PEM, NULL), 1); } - + if (str) { /* since store knows crl list */ - AssertIntEQ(wolfSSL_CertManagerVerify(str->cm, + AssertIntEQ(wolfSSL_CertManagerVerify(str->cm, "certs/server-revoked-cert.pem", WOLFSSL_FILETYPE_PEM ), CRL_CERT_REVOKED); } - + AssertIntEQ(X509_LOOKUP_ctrl(NULL, 0, NULL, 0, NULL), 0); X509_STORE_free(str); - + #endif @@ -33146,9 +33146,9 @@ static void test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) buf[8]=85;buf[9]=85;buf[10]=102;buf[11]=102; buf[12]=119;buf[13]=119;buf[14]=136;buf[15]=136; AssertIntEQ(X509_VERIFY_PARAM_set1_ip(param, &buf[0], 16), SSL_SUCCESS); - AssertIntEQ(XSTRNCMP(param->ipasc, + AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8:3333:4444:5555:6666:7777:8888", sizeof(param->ipasc)), 0); - + /* test 2001:db8:: */ buf[0]=32;buf[1]=1;buf[2]=13;buf[3]=184; buf[4]=0;buf[5]=0;buf[6]=0;buf[7]=0; @@ -33156,7 +33156,7 @@ static void test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) buf[12]=0;buf[13]=0;buf[14]=0;buf[15]=0; AssertIntEQ(X509_VERIFY_PARAM_set1_ip(param, &buf[0], 16), SSL_SUCCESS); AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8::", sizeof(param->ipasc)), 0); - + /* test ::1234:5678 */ buf[0]=0;buf[1]=0;buf[2]=0;buf[3]=0; buf[4]=0;buf[5]=0;buf[6]=0;buf[7]=0; @@ -33164,17 +33164,17 @@ static void test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) buf[12]=18;buf[13]=52;buf[14]=86;buf[15]=120; AssertIntEQ(X509_VERIFY_PARAM_set1_ip(param, &buf[0], 16), SSL_SUCCESS); AssertIntEQ(XSTRNCMP(param->ipasc, "::1234:5678", sizeof(param->ipasc)), 0); - - + + /* test 2001:db8::1234:5678 */ buf[0]=32;buf[1]=1;buf[2]=13;buf[3]=184; buf[4]=0;buf[5]=0;buf[6]=0;buf[7]=0; buf[8]=0;buf[9]=0;buf[10]=0;buf[11]=0; buf[12]=18;buf[13]=52;buf[14]=86;buf[15]=120; AssertIntEQ(X509_VERIFY_PARAM_set1_ip(param, &buf[0], 16), SSL_SUCCESS); - AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8::1234:5678", + AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8::1234:5678", sizeof(param->ipasc)), 0); - + /* test 2001:0db8:0001:0000:0000:0ab9:c0a8:0102*/ /* 2001:db8:1::ab9:c0a8:102 */ buf[0]=32;buf[1]=1;buf[2]=13;buf[3]=184; @@ -33182,9 +33182,9 @@ static void test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) buf[8]=0;buf[9]=0;buf[10]=10;buf[11]=185; buf[12]=192;buf[13]=168;buf[14]=1;buf[15]=2; AssertIntEQ(X509_VERIFY_PARAM_set1_ip(param, &buf[0], 16), SSL_SUCCESS); - AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8:1::ab9:c0a8:102", + AssertIntEQ(XSTRNCMP(param->ipasc, "2001:db8:1::ab9:c0a8:102", sizeof(param->ipasc)), 0); - + XFREE(param, HEAP_HINT, DYNAMIC_TYPE_OPENSSL); printf(resultFmt, passed); #endif /* OPENSSL_EXTRA */ @@ -34780,7 +34780,7 @@ static void test_wolfSSL_set_options(void) AssertTrue(SSL_set_msg_callback(ssl, msg_cb) == SSL_SUCCESS); SSL_set_msg_callback_arg(ssl, arg); #ifdef WOLFSSL_ERROR_CODE_OPENSSL - AssertTrue(SSL_CTX_set_alpn_protos(ctx, protos, len) == 0); + AssertTrue(SSL_CTX_set_alpn_protos(ctx, protos, len) == 0); #else AssertTrue(SSL_CTX_set_alpn_protos(ctx, protos, len) == SSL_SUCCESS); #endif @@ -36566,7 +36566,7 @@ static void test_wolfSSL_RAND_set_rand_method(void) buf = (byte*)XMALLOC(32 * sizeof(byte), NULL, DYNAMIC_TYPE_TMP_BUFFER); - + AssertIntNE(wolfSSL_RAND_status(), 5432); AssertIntEQ(*was_cleanup_called, 0); RAND_cleanup(); @@ -36604,7 +36604,7 @@ static void test_wolfSSL_RAND_set_rand_method(void) AssertIntEQ(*was_cleanup_called, 0); XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - + printf(resultFmt, passed); #endif /* OPENSSL_EXTRA && !WOLFSSL_NO_OPENSSL_RAND_CB */ } @@ -36623,15 +36623,15 @@ static void test_wolfSSL_RAND_bytes(void) /* sanity check */ AssertIntEQ(RAND_bytes(NULL, 16), 0); AssertIntEQ(RAND_bytes(NULL, 0), 0); - + max_bufsize = size4; my_buf = (byte*)XMALLOC(max_bufsize * sizeof(byte), NULL, DYNAMIC_TYPE_TMP_BUFFER); - + AssertIntEQ(RAND_bytes(my_buf, 0), 1); AssertIntEQ(RAND_bytes(my_buf, -1), 0); - + AssertNotNull(my_buf); XMEMSET(my_buf, 0, max_bufsize); AssertIntEQ(RAND_bytes(my_buf, size1), 1); @@ -36723,7 +36723,7 @@ static void test_wolfSSL_PKCS8_Compat(void) AssertNotNull(bio = BIO_new_mem_buf((void*)pkcs8_buffer, bytes)); AssertNotNull(pt = d2i_PKCS8_PRIV_KEY_INFO_bio(bio, NULL)); -#if defined(OPENSSL_ALL) || defined(WOLFSSL_WPAS_SMALL) +#if defined(OPENSSL_ALL) || defined(WOLFSSL_WPAS_SMALL) AssertNotNull(pkey = EVP_PKCS82PKEY(pt)); AssertIntEQ(EVP_PKEY_type(pkey->type), EVP_PKEY_EC); @@ -38932,7 +38932,7 @@ static void test_wolfSSL_SESSION(void) #else AssertIntEQ(wolfSSL_SESSION_has_ticket(sess), 0); #endif - + wolfSSL_shutdown(ssl); wolfSSL_free(ssl); @@ -39331,13 +39331,13 @@ static void test_wolfSSL_GENERAL_NAME_print(void) ACCESS_DESCRIPTION* ad; const unsigned char v4Addr[] = {192,168,53,1}; - const unsigned char v6Addr[] = + const unsigned char v6Addr[] = {0x20, 0x21, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x77, 0x77}; const unsigned char email[] = {'i', 'n', 'f', 'o', '@', 'w', 'o', 'l', 'f', 's', 's', 'l', '.', 'c', 'o', 'm'}; - + const char* dnsStr = "DNS:example.com"; const char* uriStr = "URI:http://127.0.0.1:22220"; const char* v4addStr = "IP Address:192.168.53.1"; @@ -39346,7 +39346,7 @@ static void test_wolfSSL_GENERAL_NAME_print(void) const char* othrStr = "othername:"; const char* x400Str = "X400Name:"; const char* ediStr = "EdiPartyName:"; - + printf(testingFmt, "test_wolfSSL_GENERAL_NAME_print()"); @@ -39400,7 +39400,7 @@ static void test_wolfSSL_GENERAL_NAME_print(void) XMEMSET(outbuf,0,sizeof(outbuf)); AssertIntGT(BIO_read(out, outbuf, sizeof(outbuf)), 0); AssertIntEQ(XSTRNCMP((const char*)outbuf, uriStr, XSTRLEN(uriStr)), 0); - + wolfSSL_sk_ACCESS_DESCRIPTION_pop_free(aia, NULL); aia = (AUTHORITY_INFO_ACCESS*)wolfSSL_X509V3_EXT_d2i(ext); @@ -39491,7 +39491,7 @@ static void test_wolfSSL_GENERAL_NAME_print(void) GENERAL_NAME_free(gn); BIO_free(out); - + printf(resultFmt, passed); #endif /* OPENSSL_ALL */ } @@ -39598,10 +39598,10 @@ static void test_wolfSSL_RSA(void) !defined(HAVE_INTEL_QA) && !defined(WOLFSSL_NO_RSA_KEY_CHECK) AssertIntEQ(RSA_check_key(rsa), WOLFSSL_SUCCESS); #endif - + /* sanity check */ AssertIntEQ(RSA_bits(NULL), 0); - + /* key */ AssertIntEQ(RSA_bits(rsa), 2048); RSA_get0_key(rsa, &n, &e, &d); @@ -39615,7 +39615,7 @@ static void test_wolfSSL_RSA(void) AssertPtrEq(rsa->n, n); AssertPtrEq(rsa->e, e); AssertPtrEq(rsa->d, d); - + /* crt_params */ RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); AssertPtrEq(rsa->dmp1, dmp1); @@ -39642,7 +39642,7 @@ static void test_wolfSSL_RSA(void) AssertIntEQ(BN_hex2bn(&rsa->n, "1FFFFF"), 1); AssertIntEQ(RSA_bits(rsa), 21); RSA_free(rsa); - + #if !defined(USE_FAST_MATH) || (FP_MAX_BITS >= (3072*2)) AssertNotNull(rsa = RSA_generate_key(3072, 17, NULL, NULL)); AssertIntEQ(RSA_size(rsa), 384); @@ -40353,7 +40353,7 @@ tgZl96bcAGdru8OpQYP7x/rI4h5+rwA/kwIBAg==\n\ /* test_EVP_Cipher_extra, Extra-test on EVP_CipherUpdate/Final. see also test.c */ #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) &&\ - (!defined(NO_AES) && defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)) + (!defined(NO_AES) && defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)) static void binary_dump(void *ptr, int size) { #ifdef WOLFSSL_EVP_PRINT @@ -40381,7 +40381,7 @@ static int last_val = 0x0f; static int check_result(unsigned char *data, int len) { int i; - + for( ; len; ) { last_val = (last_val + 1) % 16; for(i = 0; i < 16; len--, i++, data++) @@ -40430,7 +40430,7 @@ static int test_wolfSSL_EVP_Cipher_extra(void) { #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) &&\ - (!defined(NO_AES) && defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)) + (!defined(NO_AES) && defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)) /* aes128-cbc, keylen=16, ivlen=16 */ byte aes128_cbc_key[] = { @@ -40454,7 +40454,7 @@ static int test_wolfSSL_EVP_Cipher_extra(void) int ret = 0; EVP_CIPHER_CTX *evp = NULL; - int ilen = 0; + int ilen = 0; int klen = 0; int i, j; @@ -40482,7 +40482,7 @@ static int test_wolfSSL_EVP_Cipher_extra(void) set_plain(plain, BUFFSZ * RECORDS); SSL_library_init(); - + AssertNotNull(evp = EVP_CIPHER_CTX_new()); AssertIntNE((ret = EVP_CipherInit(evp, type, NULL, iv, 0)), 0); @@ -42652,7 +42652,7 @@ static void test_wolfSSL_CTX_ctrl(void) AssertNull(SSL_CTX_get_default_passwd_cb(ctx)); AssertNull(SSL_CTX_get_default_passwd_cb_userdata(ctx)); #endif - + /* Test for min/max proto */ #ifndef WOLFSSL_NO_TLS12 AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, @@ -42665,7 +42665,7 @@ static void test_wolfSSL_CTX_ctrl(void) #ifdef WOLFSSL_TLS13 AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, 0, NULL), SSL_SUCCESS); - + AssertIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, TLS1_3_VERSION, NULL), SSL_SUCCESS); AssertIntEQ(wolfSSL_CTX_get_max_proto_version(ctx), TLS1_3_VERSION); @@ -43601,9 +43601,9 @@ static void test_wolfSSL_QT_EVP_PKEY_CTX_free(void) #if defined(OPENSSL_EXTRA) EVP_PKEY* pkey; EVP_PKEY_CTX* ctx; - + printf(testingFmt, "test_wolfSSL_QT_EVP_PKEY_CTX_free"); - + AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); @@ -43615,7 +43615,7 @@ static void test_wolfSSL_QT_EVP_PKEY_CTX_free(void) /* int */ AssertIntEQ(EVP_PKEY_CTX_free(ctx), WOLFSSL_SUCCESS); #endif - + EVP_PKEY_free(pkey); printf(resultFmt, passed); #endif @@ -43629,7 +43629,7 @@ static void test_wolfSSL_EVP_PKEY_param_check(void) DH *setDh = NULL; EVP_PKEY *pkey = NULL; EVP_PKEY_CTX* ctx = NULL; - + FILE* f = NULL; unsigned char buf[512]; const unsigned char* pt = buf; @@ -43651,23 +43651,23 @@ static void test_wolfSSL_EVP_PKEY_param_check(void) AssertIntEQ(DH_check(setDh, &code), WOLFSSL_SUCCESS); AssertIntEQ(code, 0); code = -1; - + pkey = wolfSSL_EVP_PKEY_new(); /* Set DH into PKEY */ AssertIntEQ(EVP_PKEY_set1_DH(pkey, setDh), WOLFSSL_SUCCESS); /* create ctx from pkey */ AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); AssertIntEQ(EVP_PKEY_param_check(ctx), 1/* valid */); - + /* */ /* TO DO invlaid case */ /* */ - + EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); DH_free(setDh); DH_free(dh); - + printf(resultFmt, passed); #endif #endif @@ -44947,7 +44947,7 @@ static void test_wolfSSL_EVP_PBE_scrypt(void) #if !defined(NO_PWDBASED) && !defined(NO_SHA256) int ret; - + const char pwd[] = {'p','a','s','s','w','o','r','d'}; int pwdlen = sizeof(pwd); const byte salt[] = {'N','a','C','l'}; @@ -44964,7 +44964,7 @@ static void test_wolfSSL_EVP_PBE_scrypt(void) 0x5A, 0x99, 0x70, 0x1B, 0x7A, 0x30, 0x4D, 0x46, 0x61, 0x1C, 0x8A, 0xA3, 0x91, 0xE7, 0x99, 0xCE, 0x10, 0xA2, 0x77, 0x53, 0xE7, 0xE9, 0xC0, 0x9A}; - + printf(testingFmt, "wolfSSL_EVP_PBE_scrypt()"); /* N r p mx key keylen */ @@ -50026,9 +50026,9 @@ static void test_wolfSSL_security_level(void) { #if defined(OPENSSL_EXTRA) printf(testingFmt, "test_wolfSSL_security_level()"); - + SSL_CTX *ctx; - + #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); @@ -50037,14 +50037,14 @@ static void test_wolfSSL_security_level(void) #endif SSL_CTX_set_security_level(ctx, 1); AssertTrue(1); - + AssertIntEQ(SSL_CTX_get_security_level(ctx), 0); - + SSL_CTX_free(ctx); #else (void)ctx; #endif - + printf(resultFmt, passed); #endif } @@ -50053,12 +50053,12 @@ static void test_wolfSSL_SSL_in_init(void) { #if defined(OPENSSL_ALL) && !defined(NO_BIO) printf(testingFmt, "test_wolfSSL_SSL_in_init()"); - + SSL_CTX* ctx; SSL* ssl; const char* testCertFile; const char* testKeyFile; - + #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); @@ -50081,11 +50081,11 @@ static void test_wolfSSL_SSL_in_init(void) AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, testKeyFile, SSL_FILETYPE_PEM)); } - + ssl = SSL_new(ctx); AssertNotNull(ssl); AssertIntEQ(SSL_in_init(ssl), 1); - + SSL_CTX_free(ctx); SSL_free(ssl); #else @@ -50094,7 +50094,7 @@ static void test_wolfSSL_SSL_in_init(void) (void)testCertFile; (void)testKeyFile; #endif - + printf(resultFmt, passed); #endif } @@ -50105,12 +50105,12 @@ static void test_wolfSSL_EC_curve(void) printf(testingFmt, "test_wolfSSL_EC_curve()"); int nid = NID_secp160k1; const char* nid_name; - + AssertNotNull(nid_name = EC_curve_nid2nist(nid)); AssertIntEQ(XMEMCMP(nid_name, "K-160", XSTRLEN("K-160")), 0); - + AssertIntEQ(EC_curve_nist2nid(nid_name), nid); - + printf(resultFmt, passed); #endif } @@ -50153,13 +50153,13 @@ static void test_wolfSSL_OpenSSL_version(void) #if defined(OPENSSL_EXTRA) printf(testingFmt, "test_wolfSSL_OpenSSL_version()"); const char* ver; - + #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L AssertNotNull(ver = OpenSSL_version(0)); #else AssertNotNull(ver = OpenSSL_version()); #endif - AssertIntEQ(XMEMCMP(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING, + AssertIntEQ(XMEMCMP(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING, XSTRLEN("wolfSSL " LIBWOLFSSL_VERSION_STRING)), 0); printf(resultFmt, passed); #endif @@ -50169,20 +50169,20 @@ static void test_CONF_CTX_CMDLINE(void) { #if defined(OPENSSL_ALL) printf(testingFmt, "test_CONF_CTX_CMDLINE"); - + SSL_CTX* ctx = NULL; SSL_CONF_CTX* cctx = NULL; - + AssertNotNull(cctx = SSL_CONF_CTX_new()); - + AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); SSL_CONF_CTX_set_ssl_ctx(cctx, ctx); AssertTrue(1); - + /* set flags */ - AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CMDLINE), + AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CMDLINE), WOLFSSL_CONF_FLAG_CMDLINE); - AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CERTIFICATE), + AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CERTIFICATE), WOLFSSL_CONF_FLAG_CMDLINE | WOLFSSL_CONF_FLAG_CERTIFICATE); /* cmd invalid command */ AssertIntEQ(SSL_CONF_cmd(cctx, "foo", "foobar"), -2); @@ -50190,58 +50190,58 @@ static void test_CONF_CTX_CMDLINE(void) AssertIntEQ(SSL_CONF_cmd(cctx, NULL, NULL), WOLFSSL_FAILURE); AssertIntEQ(SSL_CONF_cmd(cctx, NULL, "foobar"), WOLFSSL_FAILURE); AssertIntEQ(SSL_CONF_cmd(NULL, "-curves", "foobar"), WOLFSSL_FAILURE); - + /* cmd Certificate and Private Key*/ { #if !defined(NO_CERTS) && !defined(NO_RSA) const char* ourCert = svrCertFile; const char* ourKey = svrKeyFile; - + AssertIntEQ(SSL_CONF_cmd(cctx, "-cert", NULL), -3); - AssertIntEQ(SSL_CONF_cmd(cctx, "-cert", ourCert), + AssertIntEQ(SSL_CONF_cmd(cctx, "-cert", ourCert), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_cmd(cctx, "-key", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "-key", ourKey), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); #endif } - + /* cmd curves */ { #if defined(HAVE_ECC) const char* curve = "secp256r1"; - + AssertIntEQ(SSL_CONF_cmd(cctx, "-curves", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "-curves", curve), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); #endif } - + /* cmd CipherString */ { char* cipher = wolfSSL_get_cipher_list(0/*top priority*/); - + AssertIntEQ(SSL_CONF_cmd(cctx, "-cipher", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "-cipher", cipher), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); } - + /* cmd DH parameter */ { #if !defined(NO_DH) && !defined(NO_BIO) const char* ourdhcert = "./certs/dh2048.pem"; - - AssertIntEQ(SSL_CONF_cmd(cctx, "-dhparam", NULL), + + AssertIntEQ(SSL_CONF_cmd(cctx, "-dhparam", NULL), -3); - AssertIntEQ(SSL_CONF_cmd(cctx, "-dhparam", ourdhcert), + AssertIntEQ(SSL_CONF_cmd(cctx, "-dhparam", ourdhcert), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); - + #endif } SSL_CTX_free(ctx); SSL_CONF_CTX_free(cctx); - + printf(resultFmt, passed); #endif /* OPENSSL_EXTRA */ } @@ -50250,19 +50250,19 @@ static void test_CONF_CTX_FILE(void) { #if defined(OPENSSL_ALL) printf(testingFmt, "test_CONF_CTX_FILE"); - + SSL_CTX* ctx = NULL; SSL_CONF_CTX* cctx = NULL; - + AssertNotNull(cctx = SSL_CONF_CTX_new()); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); SSL_CONF_CTX_set_ssl_ctx(cctx, ctx); AssertTrue(1); - + /* set flags */ - AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_FILE), + AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_FILE), WOLFSSL_CONF_FLAG_FILE); - AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CERTIFICATE), + AssertIntEQ(SSL_CONF_CTX_set_flags(cctx, WOLFSSL_CONF_FLAG_CERTIFICATE), WOLFSSL_CONF_FLAG_FILE | WOLFSSL_CONF_FLAG_CERTIFICATE); /* sanity check */ AssertIntEQ(SSL_CONF_cmd(cctx, "foo", "foobar"), -2); @@ -50270,58 +50270,58 @@ static void test_CONF_CTX_FILE(void) AssertIntEQ(SSL_CONF_cmd(cctx, NULL, NULL), WOLFSSL_FAILURE); AssertIntEQ(SSL_CONF_cmd(cctx, NULL, "foobar"), WOLFSSL_FAILURE); AssertIntEQ(SSL_CONF_cmd(NULL, "-curves", "foobar"), WOLFSSL_FAILURE); - + /* cmd Certificate and Private Key*/ { #if !defined(NO_CERTS) && !defined(NO_RSA) const char* ourCert = svrCertFile; const char* ourKey = svrKeyFile; - + AssertIntEQ(SSL_CONF_cmd(cctx, "Certificate", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "PrivateKey", NULL), -3); - - AssertIntEQ(SSL_CONF_cmd(cctx, "Certificate", ourCert), + + AssertIntEQ(SSL_CONF_cmd(cctx, "Certificate", ourCert), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_cmd(cctx, "PrivateKey", ourKey), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); #endif } - + /* cmd curves */ { #if defined(HAVE_ECC) const char* curve = "secp256r1"; - + AssertIntEQ(SSL_CONF_cmd(cctx, "Curves", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "Curves", curve), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); #endif } - + /* cmd CipherString */ { char* cipher = wolfSSL_get_cipher_list(0/*top priority*/); - + AssertIntEQ(SSL_CONF_cmd(cctx, "CipherString", NULL), -3); AssertIntEQ(SSL_CONF_cmd(cctx, "CipherString", cipher), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); } - + /* cmd DH parameter */ { #if !defined(NO_DH) && !defined(NO_BIO) && defined(HAVE_FFDHE_3072) const char* ourdhcert = "./certs/dh3072.pem"; - + AssertIntEQ(SSL_CONF_cmd(cctx, "DHParameters", NULL), -3); - AssertIntEQ(SSL_CONF_cmd(cctx, "DHParameters", ourdhcert), + AssertIntEQ(SSL_CONF_cmd(cctx, "DHParameters", ourdhcert), WOLFSSL_SUCCESS); AssertIntEQ(SSL_CONF_CTX_finish(cctx), WOLFSSL_SUCCESS); - + #endif } SSL_CTX_free(ctx); SSL_CONF_CTX_free(cctx); - + printf(resultFmt, passed); #endif /* OPENSSL_EXTRA */ } @@ -50399,7 +50399,7 @@ static void test_wolfSSL_set_psk_use_session_callback(void) SSL* ssl; const char* testCertFile; const char* testKeyFile; - + #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); @@ -50422,14 +50422,14 @@ static void test_wolfSSL_set_psk_use_session_callback(void) AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, testKeyFile, SSL_FILETYPE_PEM)); } - + ssl = SSL_new(ctx); AssertNotNull(ssl); - + SSL_set_psk_use_session_callback(ssl, my_psk_use_session_cb); AssertTrue(1); - + SSL_CTX_free(ctx); SSL_free(ssl); #else @@ -50543,7 +50543,7 @@ static void test_wolfSSL_ERR_strings(void) (void)err2; #if !defined(NO_ERROR_STRINGS) printf(testingFmt, "test_wolfSSL_ERR_strings"); - + #if defined(OPENSSL_EXTRA) err = ERR_reason_error_string(UNSUPPORTED_SUITE); AssertTrue(err != NULL); @@ -50552,7 +50552,7 @@ static void test_wolfSSL_ERR_strings(void) err = ERR_func_error_string(UNSUPPORTED_SUITE); AssertTrue(err != NULL); AssertIntEQ((*err == '\0'), 1); - + err = ERR_lib_error_string(PEM_R_PROBLEMS_GETTING_PASSWORD); AssertTrue(err != NULL); AssertIntEQ(XSTRNCMP(err, err2, XSTRLEN(err2)), 0); @@ -50603,10 +50603,10 @@ static void test_EVP_blake2(void) { #if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)) printf(testingFmt, "test_EVP_blake2"); - + const EVP_MD* md = NULL; (void)md; - + #if defined(HAVE_BLAKE2) md = EVP_blake2b512(); AssertTrue(md != NULL); @@ -50628,13 +50628,13 @@ static void list_md_fn(const EVP_MD* m, const char* from, { const char* mn; BIO *bio; - + (void) from; (void) to; (void) arg; (void) mn; (void) bio; - + if (!m) { /* alias */ AssertNull(m); @@ -50644,14 +50644,14 @@ static void list_md_fn(const EVP_MD* m, const char* from, AssertNotNull(m); AssertNull(to); } - + AssertNotNull(from); #if !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL_VERBOSE) mn = EVP_get_digestbyname(from); /* print to stdout */ AssertNotNull(arg); - + bio = BIO_new(BIO_s_file()); BIO_set_fp(bio, arg, BIO_NOCLOSE); BIO_printf(bio, "Use %s message digest algorithm\n", mn); @@ -50664,16 +50664,16 @@ static void test_EVP_MD_do_all(void) { #if defined(OPENSSL_EXTRA) printf(testingFmt, "test_EVP_MD_do_all"); - + EVP_MD_do_all(NULL, stdout); /* to confirm previous call gives no harm */ AssertTrue(1); - - + + EVP_MD_do_all(list_md_fn, stdout); /* to confirm previous call gives no harm */ AssertTrue(1); - + printf(resultFmt, passed); #endif } @@ -50683,13 +50683,13 @@ static void obj_name_t(const OBJ_NAME* nm, void* arg) { (void)arg; (void)nm; - + AssertIntGT(nm->type, OBJ_NAME_TYPE_UNDEF); - + #if !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL_VERBOSE) /* print to stdout */ AssertNotNull(arg); - + bio = BIO_new(BIO_s_file()); BIO_set_fp(bio, arg, BIO_NOCLOSE); BIO_printf(bio, "%s\n", mn); @@ -50702,15 +50702,15 @@ static void test_OBJ_NAME_do_all(void) { #if defined(OPENSSL_EXTRA) printf(testingFmt, "test_OBJ_NAME_do_all"); - + OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, NULL, NULL); /* to confirm previous call gives no harm */ AssertTrue(1); - + OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, NULL, stdout); /* to confirm previous call gives no harm */ AssertTrue(1); - + OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, obj_name_t, stdout); AssertTrue(1); OBJ_NAME_do_all(OBJ_NAME_TYPE_PKEY_METH, obj_name_t, stdout); @@ -50725,7 +50725,7 @@ static void test_OBJ_NAME_do_all(void) AssertTrue(1); OBJ_NAME_do_all(-1, obj_name_t, stdout); AssertTrue(1); - + printf(resultFmt, passed); #endif } @@ -50734,9 +50734,9 @@ static void test_SSL_CIPHER_get_xxx(void) { #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) - + printf(testingFmt, "test_SSL_CIPHER_get_xxx"); - + const SSL_CIPHER* cipher = NULL; STACK_OF(SSL_CIPHER) *supportedCiphers = NULL; int i, numCiphers = 0; @@ -50745,7 +50745,7 @@ static void test_SSL_CIPHER_get_xxx(void) const char* testCertFile; const char* testKeyFile; char buf[256] = {0}; - + const char* cipher_id = NULL; int expect_nid1 = NID_undef; int expect_nid2 = NID_undef; @@ -50759,7 +50759,7 @@ static void test_SSL_CIPHER_get_xxx(void) int expect_nid23 = NID_undef; int expect_nid24 = NID_undef; int expect_nid25 = 0; - + (void)cipher; (void)supportedCiphers; (void)i; @@ -50792,7 +50792,7 @@ static void test_SSL_CIPHER_get_xxx(void) #else AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #endif - + if (cipher_id) { #ifndef NO_RSA testCertFile = svrCertFile; @@ -50810,16 +50810,16 @@ static void test_SSL_CIPHER_get_xxx(void) AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, testKeyFile, SSL_FILETYPE_PEM)); } - + ssl = SSL_new(ctx); AssertNotNull(ssl); AssertIntEQ(SSL_in_init(ssl), 1); - + supportedCiphers = SSL_get_ciphers(ssl); numCiphers = sk_num(supportedCiphers); - + for (i = 0; i < numCiphers; ++i) { - + if ((cipher = (const WOLFSSL_CIPHER*)sk_value(supportedCiphers, i))) { SSL_CIPHER_description(cipher, buf, sizeof(buf)); } @@ -50836,11 +50836,11 @@ static void test_SSL_CIPHER_get_xxx(void) AssertIntEQ(wolfSSL_CIPHER_get_kx_nid(cipher), expect_nid4); AssertIntEQ(wolfSSL_CIPHER_is_aead(cipher), expect_nid5); } - + if (cipher_id2) { - + for (i = 0; i < numCiphers; ++i) { - + if ((cipher = (const WOLFSSL_CIPHER*)sk_value(supportedCiphers, i))) { SSL_CIPHER_description(cipher, buf, sizeof(buf)); } @@ -50859,12 +50859,12 @@ static void test_SSL_CIPHER_get_xxx(void) } } } - + if (ctx) SSL_CTX_free(ctx); if(ssl) SSL_free(ssl); - + printf(resultFmt, passed); #endif } @@ -50894,7 +50894,7 @@ static int load_pem_key_file_as_der(const char* privKeyFile, DerBuffer** pDer, #ifdef DEBUG_WOLFSSL printf("%s (%d): Loading PEM %s (len %d) to DER (len %d)\n", - (ret == 0) ? "Success" : "Failure", ret, privKeyFile, (int)key_sz, + (ret == 0) ? "Success" : "Failure", ret, privKeyFile, (int)key_sz, (*pDer)->length); #endif @@ -51081,9 +51081,9 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) /* tlsVer: WOLFSSL_TLSV1_2 or WOLFSSL_TLSV1_3 */ static void test_wc_CryptoCb_TLS(int tlsVer, - const char* cliCaPemFile, const char* cliCertPemFile, + const char* cliCaPemFile, const char* cliCertPemFile, const char* cliPrivKeyPemFile, const char* cliPubKeyPemFile, - const char* svrCaPemFile, const char* svrCertPemFile, + const char* svrCaPemFile, const char* svrCertPemFile, const char* svrPrivKeyPemFile, const char* svrPubKeyPemFile) { callback_functions client_cbf; @@ -51221,10 +51221,10 @@ static void test_wc_CryptoCb(void) /* tlsVer: Example: WOLFSSL_TLSV1_2 or WOLFSSL_TLSV1_3 */ static void test_wolfSSL_CTX_StaticMemory_TLS(int tlsVer, - const char* cliCaPemFile, const char* cliCertPemFile, - const char* cliPrivKeyPemFile, + const char* cliCaPemFile, const char* cliCertPemFile, + const char* cliPrivKeyPemFile, const char* svrCaPemFile, const char* svrCertPemFile, - const char* svrPrivKeyPemFile, + const char* svrPrivKeyPemFile, byte* cliMem, word32 cliMemSz, byte* svrMem, word32 svrMemSz) { callback_functions client_cbf; @@ -51777,7 +51777,7 @@ void ApiTest(void) test_wolfssl_EVP_aes_gcm_AAD_2_parts(); test_wolfssl_EVP_aes_gcm(); test_wolfSSL_PKEY_up_ref(); - test_wolfSSL_EVP_Cipher_extra(); + test_wolfSSL_EVP_Cipher_extra(); test_wolfSSL_d2i_and_i2d_PublicKey(); test_wolfSSL_d2i_and_i2d_DSAparams(); test_wolfSSL_i2d_PrivateKey(); @@ -51969,12 +51969,12 @@ void ApiTest(void) test_wolfSSL_CTX_set_timeout(); test_wolfSSL_OpenSSL_version(); test_wolfSSL_set_psk_use_session_callback(); - + test_CONF_CTX_FILE(); test_CONF_CTX_CMDLINE(); test_wolfSSL_CRYPTO_get_ex_new_index(); test_wolfSSL_DH(); - + /*wolfcrypt */ printf("\n-----------------wolfcrypt unit tests------------------\n"); AssertFalse(test_wolfCrypt_Init()); diff --git a/tests/suites.c b/tests/suites.c index 38e0bab74..68755c33b 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -544,7 +544,7 @@ static int execute_test_case(int svr_argc, char** svr_argv, /* verify results */ if ((cliArgs.return_code != 0 && cliTestShouldFail == 0) || (cliArgs.return_code == 0 && cliTestShouldFail != 0)) { - printf("client_test failed %d %s\n", cliArgs.return_code, + printf("client_test failed %d %s\n", cliArgs.return_code, cliTestShouldFail ? "(should fail)" : ""); XEXIT(EXIT_FAILURE); } diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index def3bbfcd..5b16d1bfc 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -153,7 +153,7 @@ int testsuite_test(int argc, char** argv) #ifdef HAVE_STACK_SIZE StackSizeCheck(&server_args, wolfcrypt_test); #else - wolfcrypt_test(&server_args); + wolfcrypt_test(&server_args); #endif if (server_args.return_code != 0) return server_args.return_code; #endif diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 7de61dd6f..8f5719586 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -2509,12 +2509,12 @@ exit: void bench_aesgcm(int doAsync) { #if defined(WOLFSSL_AES_128) && !defined(WOLFSSL_AFALG_XILINX_AES) \ - && !defined(WOLFSSL_XILINX_CRYPT) + && !defined(WOLFSSL_XILINX_CRYPT) bench_aesgcm_internal(doAsync, bench_key, 16, bench_iv, 12, "AES-128-GCM-enc", "AES-128-GCM-dec"); #endif #if defined(WOLFSSL_AES_192) && !defined(WOLFSSL_AFALG_XILINX_AES) \ - && !defined(WOLFSSL_XILINX_CRYPT) + && !defined(WOLFSSL_XILINX_CRYPT) bench_aesgcm_internal(doAsync, bench_key, 24, bench_iv, 12, "AES-192-GCM-enc", "AES-192-GCM-dec"); #endif @@ -2551,17 +2551,17 @@ void bench_gmac(void) XMEMSET(&gmac, 0, sizeof(Gmac)); /* clear context */ (void)wc_AesInit((Aes*)&gmac, HEAP_HINT, INVALID_DEVID); wc_GmacSetKey(&gmac, bench_key, 16); - + bench_stats_start(&count, &start); - do { - ret = wc_GmacUpdate(&gmac, bench_iv, 12, bench_plain, bench_size, + do { + ret = wc_GmacUpdate(&gmac, bench_iv, 12, bench_plain, bench_size, tag, sizeof(tag)); count++; } while (bench_stats_sym_check(start)); wc_AesFree((Aes*)&gmac); - bench_stats_sym_finish(gmacStr, 0, count, bench_size, start, ret); + bench_stats_sym_finish(gmacStr, 0, count, bench_size, start, ret); } #endif /* HAVE_AESGCM */ @@ -4307,10 +4307,10 @@ static void bench_hmac(int doAsync, int type, int digestSz, #ifdef WOLFSSL_ASYNC_CRYPT DECLARE_ARRAY(digest, byte, BENCH_MAX_PENDING, WC_MAX_DIGEST_SIZE, HEAP_HINT); #else - byte digest[BENCH_MAX_PENDING][WC_MAX_DIGEST_SIZE]; + byte digest[BENCH_MAX_PENDING][WC_MAX_DIGEST_SIZE]; #endif - (void)digestSz; + (void)digestSz; /* clear for done cleanup */ XMEMSET(hmac, 0, sizeof(hmac)); @@ -4916,8 +4916,8 @@ void bench_rsa(int doAsync) /* init keys */ for (i = 0; i < BENCH_MAX_PENDING; i++) { /* setup an async context for each key */ - ret = wc_InitRsaKey_ex(&rsaKey[i], HEAP_HINT, - doAsync ? devId : INVALID_DEVID); + ret = wc_InitRsaKey_ex(&rsaKey[i], HEAP_HINT, + doAsync ? devId : INVALID_DEVID); if (ret < 0) { goto exit_bench_rsa; } @@ -5704,7 +5704,7 @@ void bench_curve25519KeyAgree(void) double start; int ret, i, count; byte shared[32]; - const char**desc = bench_desc_words[lng_index]; + const char**desc = bench_desc_words[lng_index]; word32 x = 0; wc_curve25519_init(&genKey); @@ -5861,7 +5861,7 @@ void bench_curve448KeyAgree(void) double start; int ret, i, count; byte shared[56]; - const char**desc = bench_desc_words[lng_index]; + const char**desc = bench_desc_words[lng_index]; word32 x = 0; wc_curve448_init(&genKey); diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 50cd7d4e6..bc161630c 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -2601,9 +2601,9 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) #elif defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT) int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv, int dir) - { + { int ret; - + if (aes == NULL || (keylen != 16 && keylen != 24 && keylen != 32)) { return BAD_FUNC_ARG; } @@ -4734,13 +4734,13 @@ static const __m128i MOD2_128 = M128_INIT(0x1, (long long int)0xc200000000000000UL); -/* See Intel® Carry-Less Multiplication Instruction +/* See Intel Carry-Less Multiplication Instruction * and its Usage for Computing the GCM Mode White Paper * by Shay Gueron, Intel Mobility Group, Israel Development Center; * and Michael E. Kounavis, Intel Labs, Circuits and Systems Research */ -/* Figure 9. AES-GCM – Encrypt With Single Block Ghash at a Time */ +/* Figure 9. AES-GCM - Encrypt With Single Block Ghash at a Time */ static const __m128i ONE = M128_INIT(0x0, 0x1); #ifndef AES_GCM_AESNI_NO_UNROLL @@ -7796,7 +7796,7 @@ static int wc_AesGcmDecrypt_STM32(Aes* aes, byte* out, /* for cases where hardware cannot be used for authTag calculate it */ /* if IV is not 12 calculate GHASH using software */ - if (ivSz != GCM_NONCE_MID_SZ + if (ivSz != GCM_NONCE_MID_SZ #ifndef CRYP_HEADERWIDTHUNIT_BYTE /* or harware that does not support partial block */ || sz == 0 || partial != 0 diff --git a/wolfcrypt/src/aes_asm.S b/wolfcrypt/src/aes_asm.S index 9a31cb6c0..0246c0ffc 100644 --- a/wolfcrypt/src/aes_asm.S +++ b/wolfcrypt/src/aes_asm.S @@ -23,7 +23,7 @@ /* This file is in at&t asm syntax, see .asm for intel syntax */ -/* See Intel® Advanced Encryption Standard (AES) Instructions Set White Paper +/* See Intel Advanced Encryption Standard (AES) Instructions Set White Paper * by Intel Mobility Group, Israel Development Center, Israel Shay Gueron */ diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 6b9a34a3e..0fe8d47cc 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -136,7 +136,7 @@ ASN Options: #endif #ifdef WOLFSSL_QNX_CAAM - #include + #include #endif #ifndef NO_RSA @@ -2701,7 +2701,7 @@ const char* GetSigName(int oid) { * When output is NULL, calculate the header length only. * * @param [in] len Length of INTEGER data in bytes. - * @param [in] firstByte First byte of data, most significant byte of integer, + * @param [in] firstByte First byte of data, most significant byte of integer, * to encode. * @param [out] output Buffer to write into. * @return Number of bytes added to the buffer. @@ -14130,7 +14130,7 @@ static int DecodeGeneralName(const byte* input, word32* inOutIdx, byte tag, } /* test if no ':' char was found and test that the next two - * chars are // to match the pattern "://" */ + * chars are "//" to match the pattern "://" */ if (i >= len - 2 || (input[idx + i + 1] != '/' || input[idx + i + 2] != '/')) { WOLFSSL_MSG("\tAlt Name must be absolute URI"); @@ -14399,7 +14399,7 @@ static int DecodeAltNames(const byte* input, int sz, DecodedCert* cert) } /* test if no ':' char was found and test that the next two - * chars are // to match the pattern "://" */ + * chars are "//" to match the pattern "://" */ if (i >= strLen - 2 || (input[idx + i + 1] != '/' || input[idx + i + 2] != '/')) { WOLFSSL_MSG("\tAlt Name must be absolute URI"); @@ -27557,7 +27557,7 @@ static int DecodeAsymKey(const byte* input, word32* inOutIdx, word32 inSz, const byte* pub; #else DECL_ASNGETDATA(dataASN, edKeyASN_Length); -#endif +#endif if (input == NULL || inOutIdx == NULL || inSz == 0 || privKey == NULL || privKeyLen == NULL) { @@ -27699,7 +27699,7 @@ static int DecodeAsymKeyPublic(const byte* input, word32* inOutIdx, word32 inSz, DECL_ASNGETDATA(dataASN, edPubKeyASN_Length); #endif - if (input == NULL || inSz == 0 || inOutIdx == NULL || + if (input == NULL || inSz == 0 || inOutIdx == NULL || pubKey == NULL || pubKeyLen == NULL) { return BAD_FUNC_ARG; } @@ -27784,7 +27784,7 @@ int wc_Ed25519PrivateKeyDecode(const byte* input, word32* inOutIdx, return BAD_FUNC_ARG; } - ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, + ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, pubKey, &pubKeyLen, ED25519k); if (ret == 0) { if (pubKeyLen == 0) { @@ -27830,7 +27830,7 @@ int wc_Curve25519PrivateKeyDecode(const byte* input, word32* inOutIdx, return BAD_FUNC_ARG; } - ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, + ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, NULL, NULL, X25519k); if (ret == 0) { ret = wc_curve25519_import_private(privKey, privKeyLen, key); @@ -28068,7 +28068,7 @@ int wc_Ed448PrivateKeyDecode(const byte* input, word32* inOutIdx, return BAD_FUNC_ARG; } - ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, + ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, pubKey, &pubKeyLen, ED448k); if (ret == 0) { if (pubKeyLen == 0) { @@ -28184,7 +28184,7 @@ int wc_Curve448PrivateKeyDecode(const byte* input, word32* inOutIdx, return BAD_FUNC_ARG; } - ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, + ret = DecodeAsymKey(input, inOutIdx, inSz, privKey, &privKeyLen, NULL, NULL, X448k); if (ret == 0) { ret = wc_curve448_import_private(privKey, privKeyLen, key); diff --git a/wolfcrypt/src/blake2b.c b/wolfcrypt/src/blake2b.c index 90ab9861f..ca3cac8d4 100644 --- a/wolfcrypt/src/blake2b.c +++ b/wolfcrypt/src/blake2b.c @@ -302,8 +302,8 @@ int blake2b_update( blake2b_state *S, const byte *in, word64 inlen ) blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES ); { - ret = blake2b_compress( S, S->buf, m, v ); - if (ret < 0) break; + ret = blake2b_compress( S, S->buf, m, v ); + if (ret < 0) break; } XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); diff --git a/wolfcrypt/src/camellia.c b/wolfcrypt/src/camellia.c index b20a6c0d2..f9728f2df 100644 --- a/wolfcrypt/src/camellia.c +++ b/wolfcrypt/src/camellia.c @@ -103,17 +103,17 @@ typedef unsigned char u8; #else /* not MS-VC */ -# define GETU32(pt) \ - (((u32)(pt)[0] << 24) \ - ^ ((u32)(pt)[1] << 16) \ - ^ ((u32)(pt)[2] << 8) \ +# define GETU32(pt) \ + (((u32)(pt)[0] << 24) \ + ^ ((u32)(pt)[1] << 16) \ + ^ ((u32)(pt)[2] << 8) \ ^ ((u32)(pt)[3])) -# define PUTU32(ct, st) { \ - (ct)[0] = (u8)((st) >> 24); \ - (ct)[1] = (u8)((st) >> 16); \ - (ct)[2] = (u8)((st) >> 8); \ - (ct)[3] = (u8)(st); } +# define PUTU32(ct, st) { \ + (ct)[0] = (u8)((st) >> 24); \ + (ct)[1] = (u8)((st) >> 16); \ + (ct)[2] = (u8)((st) >> 8); \ + (ct)[3] = (u8)(st); } #endif @@ -127,23 +127,23 @@ typedef unsigned char u8; /* rotation left shift 1byte */ #define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24)) -#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits) \ - do { \ - w0 = ll; \ - ll = (ll << bits) + (lr >> (32 - bits)); \ - lr = (lr << bits) + (rl >> (32 - bits)); \ - rl = (rl << bits) + (rr >> (32 - bits)); \ - rr = (rr << bits) + (w0 >> (32 - bits)); \ +#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits) \ + do { \ + w0 = ll; \ + ll = (ll << bits) + (lr >> (32 - bits)); \ + lr = (lr << bits) + (rl >> (32 - bits)); \ + rl = (rl << bits) + (rr >> (32 - bits)); \ + rr = (rr << bits) + (w0 >> (32 - bits)); \ } while(0) -#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits) \ - do { \ - w0 = ll; \ - w1 = lr; \ - ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \ - lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \ - rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \ - rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \ +#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits) \ + do { \ + w0 = ll; \ + w1 = lr; \ + ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \ + lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \ + rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \ + rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \ } while(0) #define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)]) @@ -151,23 +151,23 @@ typedef unsigned char u8; #define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)]) #define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)]) -#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ - do { \ - il = xl ^ kl; \ - ir = xr ^ kr; \ - t0 = il >> 16; \ - t1 = ir >> 16; \ - yl = CAMELLIA_SP1110(ir & 0xff) \ - ^ CAMELLIA_SP0222((t1 >> 8) & 0xff) \ - ^ CAMELLIA_SP3033(t1 & 0xff) \ - ^ CAMELLIA_SP4404((ir >> 8) & 0xff); \ - yr = CAMELLIA_SP1110((t0 >> 8) & 0xff) \ - ^ CAMELLIA_SP0222(t0 & 0xff) \ - ^ CAMELLIA_SP3033((il >> 8) & 0xff) \ - ^ CAMELLIA_SP4404(il & 0xff); \ - yl ^= yr; \ - yr = CAMELLIA_RR8(yr); \ - yr ^= yl; \ +#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ + do { \ + il = xl ^ kl; \ + ir = xr ^ kr; \ + t0 = il >> 16; \ + t1 = ir >> 16; \ + yl = CAMELLIA_SP1110(ir & 0xff) \ + ^ CAMELLIA_SP0222((t1 >> 8) & 0xff) \ + ^ CAMELLIA_SP3033(t1 & 0xff) \ + ^ CAMELLIA_SP4404((ir >> 8) & 0xff); \ + yr = CAMELLIA_SP1110((t0 >> 8) & 0xff) \ + ^ CAMELLIA_SP0222(t0 & 0xff) \ + ^ CAMELLIA_SP3033((il >> 8) & 0xff) \ + ^ CAMELLIA_SP4404(il & 0xff); \ + yl ^= yr; \ + yr = CAMELLIA_RR8(yr); \ + yr ^= yl; \ } while(0) @@ -176,39 +176,39 @@ typedef unsigned char u8; * */ #define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \ - do { \ - t0 = kll; \ - t0 &= ll; \ - lr ^= CAMELLIA_RL1(t0); \ - t1 = klr; \ - t1 |= lr; \ - ll ^= t1; \ - \ - t2 = krr; \ - t2 |= rr; \ - rl ^= t2; \ - t3 = krl; \ - t3 &= rl; \ - rr ^= CAMELLIA_RL1(t3); \ + do { \ + t0 = kll; \ + t0 &= ll; \ + lr ^= CAMELLIA_RL1(t0); \ + t1 = klr; \ + t1 |= lr; \ + ll ^= t1; \ + \ + t2 = krr; \ + t2 |= rr; \ + rl ^= t2; \ + t3 = krl; \ + t3 &= rl; \ + rr ^= CAMELLIA_RL1(t3); \ } while(0) -#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ - do { \ - ir = CAMELLIA_SP1110(xr & 0xff) \ - ^ CAMELLIA_SP0222((xr >> 24) & 0xff) \ - ^ CAMELLIA_SP3033((xr >> 16) & 0xff) \ - ^ CAMELLIA_SP4404((xr >> 8) & 0xff); \ - il = CAMELLIA_SP1110((xl >> 24) & 0xff) \ - ^ CAMELLIA_SP0222((xl >> 16) & 0xff) \ - ^ CAMELLIA_SP3033((xl >> 8) & 0xff) \ - ^ CAMELLIA_SP4404(xl & 0xff); \ - il ^= kl; \ - ir ^= kr; \ - ir ^= il; \ - il = CAMELLIA_RR8(il); \ - il ^= ir; \ - yl ^= ir; \ - yr ^= il; \ +#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ + do { \ + ir = CAMELLIA_SP1110(xr & 0xff) \ + ^ CAMELLIA_SP0222((xr >> 24) & 0xff) \ + ^ CAMELLIA_SP3033((xr >> 16) & 0xff) \ + ^ CAMELLIA_SP4404((xr >> 8) & 0xff); \ + il = CAMELLIA_SP1110((xl >> 24) & 0xff) \ + ^ CAMELLIA_SP0222((xl >> 16) & 0xff) \ + ^ CAMELLIA_SP3033((xl >> 8) & 0xff) \ + ^ CAMELLIA_SP4404(xl & 0xff); \ + il ^= kl; \ + ir ^= kr; \ + ir ^= il; \ + il = CAMELLIA_RR8(il); \ + il ^= ir; \ + yl ^= ir; \ + yr ^= il; \ } while(0) @@ -545,19 +545,19 @@ static int camellia_setup128(const unsigned char *key, u32 *subkey) kll = subl(0); klr = subr(0); krl = subl(1); krr = subr(1); CAMELLIA_F(kll, klr, - CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, + w0, w1, il, ir, t0, t1); krl ^= w0; krr ^= w1; CAMELLIA_F(krl, krr, - CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, - kll, klr, il, ir, t0, t1); + CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, + kll, klr, il, ir, t0, t1); CAMELLIA_F(kll, klr, - CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, - krl, krr, il, ir, t0, t1); + CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, + krl, krr, il, ir, t0, t1); krl ^= w0; krr ^= w1; CAMELLIA_F(krl, krr, - CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, + w0, w1, il, ir, t0, t1); kll ^= w0; klr ^= w1; /* generate KA dependent subkeys */ @@ -649,7 +649,7 @@ static int camellia_setup128(const unsigned char *key, u32 *subkey) CamelliaSubkeyL(14) = subl(13) ^ subl(15); CamelliaSubkeyR(14) = subr(13) ^ subr(15); tl = subl(18) ^ (subr(18) & ~subr(16)); - dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw); + dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw); CamelliaSubkeyL(15) = subl(14) ^ tl; CamelliaSubkeyR(15) = subr(14) ^ tr; CamelliaSubkeyL(16) = subl(16); @@ -657,7 +657,7 @@ static int camellia_setup128(const unsigned char *key, u32 *subkey) CamelliaSubkeyL(17) = subl(17); CamelliaSubkeyR(17) = subr(17); tl = subl(15) ^ (subr(15) & ~subr(17)); - dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw); + dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw); CamelliaSubkeyL(18) = tl ^ subl(19); CamelliaSubkeyR(18) = tr ^ subr(19); CamelliaSubkeyL(19) = subl(18) ^ subl(20); @@ -793,32 +793,32 @@ static int camellia_setup256(const unsigned char *key, u32 *subkey) kll = subl(0) ^ krll; klr = subr(0) ^ krlr; krl = subl(1) ^ krrl; krr = subr(1) ^ krrr; CAMELLIA_F(kll, klr, - CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, + w0, w1, il, ir, t0, t1); krl ^= w0; krr ^= w1; CAMELLIA_F(krl, krr, - CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, - kll, klr, il, ir, t0, t1); + CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, + kll, klr, il, ir, t0, t1); kll ^= krll; klr ^= krlr; CAMELLIA_F(kll, klr, - CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, - krl, krr, il, ir, t0, t1); + CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, + krl, krr, il, ir, t0, t1); krl ^= w0 ^ krrl; krr ^= w1 ^ krrr; CAMELLIA_F(krl, krr, - CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, + w0, w1, il, ir, t0, t1); kll ^= w0; klr ^= w1; /* generate KB */ krll ^= kll; krlr ^= klr; krrl ^= krl; krrr ^= krr; CAMELLIA_F(krll, krlr, - CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R, + w0, w1, il, ir, t0, t1); krrl ^= w0; krrr ^= w1; CAMELLIA_F(krrl, krrr, - CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R, - w0, w1, il, ir, t0, t1); + CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R, + w0, w1, il, ir, t0, t1); krll ^= w0; krlr ^= w1; /* generate KA dependent subkeys */ @@ -1058,71 +1058,71 @@ static void camellia_encrypt128(const u32 *subkey, u32 *io) /* main iteration */ CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(2),CamelliaSubkeyR(2), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(3),CamelliaSubkeyR(3), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(4),CamelliaSubkeyR(4), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(5),CamelliaSubkeyR(5), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(6),CamelliaSubkeyR(6), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(7),CamelliaSubkeyR(7), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(8),CamelliaSubkeyR(8), - CamelliaSubkeyL(9),CamelliaSubkeyR(9), - t0,t1,il,ir); + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(10),CamelliaSubkeyR(10), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(11),CamelliaSubkeyR(11), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(12),CamelliaSubkeyR(12), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(13),CamelliaSubkeyR(13), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(14),CamelliaSubkeyR(14), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(15),CamelliaSubkeyR(15), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(16),CamelliaSubkeyR(16), - CamelliaSubkeyL(17),CamelliaSubkeyR(17), - t0,t1,il,ir); + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(18),CamelliaSubkeyR(18), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(19),CamelliaSubkeyR(19), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(20),CamelliaSubkeyR(20), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(21),CamelliaSubkeyR(21), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(22),CamelliaSubkeyR(22), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(23),CamelliaSubkeyR(23), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[0],io[1],il,ir,t0,t1); /* post whitening but kw4 */ io[2] ^= CamelliaSubkeyL(24); @@ -1148,71 +1148,71 @@ static void camellia_decrypt128(const u32 *subkey, u32 *io) /* main iteration */ CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(23),CamelliaSubkeyR(23), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(22),CamelliaSubkeyR(22), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(21),CamelliaSubkeyR(21), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(20),CamelliaSubkeyR(20), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(19),CamelliaSubkeyR(19), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(18),CamelliaSubkeyR(18), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(17),CamelliaSubkeyR(17), - CamelliaSubkeyL(16),CamelliaSubkeyR(16), - t0,t1,il,ir); + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(15),CamelliaSubkeyR(15), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(14),CamelliaSubkeyR(14), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(13),CamelliaSubkeyR(13), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(12),CamelliaSubkeyR(12), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(11),CamelliaSubkeyR(11), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(10),CamelliaSubkeyR(10), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(9),CamelliaSubkeyR(9), - CamelliaSubkeyL(8),CamelliaSubkeyR(8), - t0,t1,il,ir); + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(7),CamelliaSubkeyR(7), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(6),CamelliaSubkeyR(6), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(5),CamelliaSubkeyR(5), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(4),CamelliaSubkeyR(4), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(3),CamelliaSubkeyR(3), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(2),CamelliaSubkeyR(2), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[0],io[1],il,ir,t0,t1); /* post whitening but kw4 */ io[2] ^= CamelliaSubkeyL(0); @@ -1241,95 +1241,95 @@ static void camellia_encrypt256(const u32 *subkey, u32 *io) /* main iteration */ CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(2),CamelliaSubkeyR(2), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(3),CamelliaSubkeyR(3), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(4),CamelliaSubkeyR(4), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(5),CamelliaSubkeyR(5), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(6),CamelliaSubkeyR(6), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(7),CamelliaSubkeyR(7), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(8),CamelliaSubkeyR(8), - CamelliaSubkeyL(9),CamelliaSubkeyR(9), - t0,t1,il,ir); + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(10),CamelliaSubkeyR(10), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(11),CamelliaSubkeyR(11), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(12),CamelliaSubkeyR(12), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(13),CamelliaSubkeyR(13), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(14),CamelliaSubkeyR(14), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(15),CamelliaSubkeyR(15), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(16),CamelliaSubkeyR(16), - CamelliaSubkeyL(17),CamelliaSubkeyR(17), - t0,t1,il,ir); + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(18),CamelliaSubkeyR(18), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(19),CamelliaSubkeyR(19), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(20),CamelliaSubkeyR(20), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(21),CamelliaSubkeyR(21), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(22),CamelliaSubkeyR(22), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(23),CamelliaSubkeyR(23), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(24),CamelliaSubkeyR(24), - CamelliaSubkeyL(25),CamelliaSubkeyR(25), - t0,t1,il,ir); + CamelliaSubkeyL(24),CamelliaSubkeyR(24), + CamelliaSubkeyL(25),CamelliaSubkeyR(25), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(26),CamelliaSubkeyR(26), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(26),CamelliaSubkeyR(26), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(27),CamelliaSubkeyR(27), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(27),CamelliaSubkeyR(27), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(28),CamelliaSubkeyR(28), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(28),CamelliaSubkeyR(28), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(29),CamelliaSubkeyR(29), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(29),CamelliaSubkeyR(29), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(30),CamelliaSubkeyR(30), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(30),CamelliaSubkeyR(30), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(31),CamelliaSubkeyR(31), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(31),CamelliaSubkeyR(31), + io[0],io[1],il,ir,t0,t1); /* post whitening but kw4 */ io[2] ^= CamelliaSubkeyL(32); @@ -1355,95 +1355,95 @@ static void camellia_decrypt256(const u32 *subkey, u32 *io) /* main iteration */ CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(31),CamelliaSubkeyR(31), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(31),CamelliaSubkeyR(31), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(30),CamelliaSubkeyR(30), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(30),CamelliaSubkeyR(30), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(29),CamelliaSubkeyR(29), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(29),CamelliaSubkeyR(29), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(28),CamelliaSubkeyR(28), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(28),CamelliaSubkeyR(28), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(27),CamelliaSubkeyR(27), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(27),CamelliaSubkeyR(27), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(26),CamelliaSubkeyR(26), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(26),CamelliaSubkeyR(26), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(25),CamelliaSubkeyR(25), - CamelliaSubkeyL(24),CamelliaSubkeyR(24), - t0,t1,il,ir); + CamelliaSubkeyL(25),CamelliaSubkeyR(25), + CamelliaSubkeyL(24),CamelliaSubkeyR(24), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(23),CamelliaSubkeyR(23), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(22),CamelliaSubkeyR(22), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(21),CamelliaSubkeyR(21), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(20),CamelliaSubkeyR(20), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(19),CamelliaSubkeyR(19), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(18),CamelliaSubkeyR(18), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(17),CamelliaSubkeyR(17), - CamelliaSubkeyL(16),CamelliaSubkeyR(16), - t0,t1,il,ir); + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(15),CamelliaSubkeyR(15), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(14),CamelliaSubkeyR(14), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(13),CamelliaSubkeyR(13), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(12),CamelliaSubkeyR(12), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(11),CamelliaSubkeyR(11), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(10),CamelliaSubkeyR(10), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[0],io[1],il,ir,t0,t1); CAMELLIA_FLS(io[0],io[1],io[2],io[3], - CamelliaSubkeyL(9),CamelliaSubkeyR(9), - CamelliaSubkeyL(8),CamelliaSubkeyR(8), - t0,t1,il,ir); + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + t0,t1,il,ir); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(7),CamelliaSubkeyR(7), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(6),CamelliaSubkeyR(6), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(5),CamelliaSubkeyR(5), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(4),CamelliaSubkeyR(4), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[0],io[1],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[0],io[1], - CamelliaSubkeyL(3),CamelliaSubkeyR(3), - io[2],io[3],il,ir,t0,t1); + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[2],io[3],il,ir,t0,t1); CAMELLIA_ROUNDSM(io[2],io[3], - CamelliaSubkeyL(2),CamelliaSubkeyR(2), - io[0],io[1],il,ir,t0,t1); + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[0],io[1],il,ir,t0,t1); /* post whitening but kw4 */ io[2] ^= CamelliaSubkeyL(0); @@ -1465,9 +1465,9 @@ static void camellia_decrypt256(const u32 *subkey, u32 *io) */ static void Camellia_EncryptBlock(const int keyBitLength, - const unsigned char *plaintext, - const KEY_TABLE_TYPE keyTable, - unsigned char *ciphertext) + const unsigned char *plaintext, + const KEY_TABLE_TYPE keyTable, + unsigned char *ciphertext) { u32 tmp[4]; @@ -1478,15 +1478,15 @@ static void Camellia_EncryptBlock(const int keyBitLength, switch (keyBitLength) { case 128: - camellia_encrypt128(keyTable, tmp); - break; + camellia_encrypt128(keyTable, tmp); + break; case 192: - /* fall through */ + /* fall through */ case 256: - camellia_encrypt256(keyTable, tmp); - break; + camellia_encrypt256(keyTable, tmp); + break; default: - break; + break; } PUTU32(ciphertext, tmp[0]); @@ -1496,9 +1496,9 @@ static void Camellia_EncryptBlock(const int keyBitLength, } static void Camellia_DecryptBlock(const int keyBitLength, - const unsigned char *ciphertext, - const KEY_TABLE_TYPE keyTable, - unsigned char *plaintext) + const unsigned char *ciphertext, + const KEY_TABLE_TYPE keyTable, + unsigned char *plaintext) { u32 tmp[4]; @@ -1509,15 +1509,15 @@ static void Camellia_DecryptBlock(const int keyBitLength, switch (keyBitLength) { case 128: - camellia_decrypt128(keyTable, tmp); - break; + camellia_decrypt128(keyTable, tmp); + break; case 192: - /* fall through */ + /* fall through */ case 256: - camellia_decrypt256(keyTable, tmp); - break; + camellia_decrypt256(keyTable, tmp); + break; default: - break; + break; } PUTU32(plaintext, tmp[0]); PUTU32(plaintext + 4, tmp[1]); @@ -1539,10 +1539,10 @@ int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv switch (len) { case 16: - ret = camellia_setup128(key, cam->key); + ret = camellia_setup128(key, cam->key); break; case 24: - ret = camellia_setup192(key, cam->key); + ret = camellia_setup192(key, cam->key); break; case 32: ret = camellia_setup256(key, cam->key); diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index 8cb9366c7..c677f06f3 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -31,9 +31,7 @@ #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT) -#if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - +#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS @@ -144,7 +142,7 @@ int wc_InitCmac(Cmac* cmac, const byte* key, word32 keySz, int devId = WOLFSSL_CAAM_DEVID; #else int devId = INVALID_DEVID; -#endif +#endif return wc_InitCmac_ex(cmac, key, keySz, type, unused, NULL, devId); } diff --git a/wolfcrypt/src/cryptocb.c b/wolfcrypt/src/cryptocb.c index ee330d1a1..0aac729c3 100644 --- a/wolfcrypt/src/cryptocb.c +++ b/wolfcrypt/src/cryptocb.c @@ -396,7 +396,7 @@ int wc_CryptoCb_Curve25519(curve25519_key* private_key, ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx); } - return wc_CryptoCb_TranslateErrorCode(ret); + return wc_CryptoCb_TranslateErrorCode(ret); } #endif /* HAVE_CURVE25519 */ diff --git a/wolfcrypt/src/curve448.c b/wolfcrypt/src/curve448.c index 3a6389cff..43c8dd83a 100644 --- a/wolfcrypt/src/curve448.c +++ b/wolfcrypt/src/curve448.c @@ -97,7 +97,7 @@ int wc_curve448_make_key(WC_RNG* rng, int keysize, curve448_key* key) /* clamp private */ key->k[0] &= 0xfc; key->k[CURVE448_KEY_SIZE-1] |= 0x80; - + /* compute public */ ret = wc_curve448_make_pub((int)sizeof(key->p), key->p, (int)sizeof(key->k), key->k); diff --git a/wolfcrypt/src/des3.c b/wolfcrypt/src/des3.c index 7e9550005..903f8315d 100644 --- a/wolfcrypt/src/des3.c +++ b/wolfcrypt/src/des3.c @@ -512,7 +512,7 @@ { #ifdef DEBUG_WOLFSSL int ret; int stat1,stat2; - #endif + #endif int size; volatile int v; @@ -604,14 +604,14 @@ int wc_Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz) { wc_Des_Cbc(out, in, sz, (byte *)des3->key, (byte *)des3->reg, SEC_DESC_DES3_CBC_ENCRYPT); - return 0; + return 0; } int wc_Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz) { wc_Des_Cbc(out, in, sz, (byte *)des3->key, (byte *)des3->reg, SEC_DESC_DES3_CBC_DECRYPT); - return 0; + return 0; } static void setParity(byte *buf, int len) @@ -637,7 +637,7 @@ { if(desBuffIn == NULL) { #if defined (HAVE_THREADX) - int s1, s2, s3, s4, s5; + int s1, s2, s3, s4, s5; s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc, sizeof(SECdescriptorType), TX_NO_WAIT); s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn, DES_BUFFER_SIZE, TX_NO_WAIT); @@ -660,7 +660,7 @@ } else { XMEMSET(des->reg, 0x0, DES_IVLEN); } - return 0; + return 0; } int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir) diff --git a/wolfcrypt/src/dh.c b/wolfcrypt/src/dh.c index fc78901ed..38425aaa8 100644 --- a/wolfcrypt/src/dh.c +++ b/wolfcrypt/src/dh.c @@ -2302,9 +2302,9 @@ int wc_DhImportKeyPair(DhKey* key, const byte* priv, word32 privSz, return 0; } -/* Can be used with WOLFSSL_DH_EXTRA when key is loaded with +/* Can be used with WOLFSSL_DH_EXTRA when key is loaded with wc_DhKeyDecode or wc_DhImportKeyPair */ -int wc_DhExportKeyPair(DhKey* key, byte* priv, word32* pPrivSz, +int wc_DhExportKeyPair(DhKey* key, byte* priv, word32* pPrivSz, byte* pub, word32* pPubSz) { int ret = 0; diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index a33e538df..ddce9dfae 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -48,9 +48,9 @@ Possible ECC enable options: * ECC_CACHE_CURVE: Enables cache of curve info to improve performance * default: off * FP_ECC: ECC Fixed Point Cache default: off - * FP cache is not supported for SECP160R1, SECP160R2, + * FP cache is not supported for SECP160R1, SECP160R2, * SECP160K1 and SECP224K1. These do not work with scalars - * that are the length of the order when the order is + * that are the length of the order when the order is * longer than the prime. * USE_ECC_B_PARAM: Enable ECC curve B param default: off * (on for HAVE_COMP_KEY) @@ -112,10 +112,10 @@ ECC Curve Sizes: /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS - #ifdef USE_WINDOWS_API - #pragma code_seg(".fipsA$f") - #pragma const_seg(".fipsB$f") - #endif + #ifdef USE_WINDOWS_API + #pragma code_seg(".fipsA$f") + #pragma const_seg(".fipsB$f") + #endif #endif /* public ASN interface */ @@ -615,7 +615,7 @@ enum { static const ecc_oid_t ecc_oid_secp384r1[] = CODED_SECP384R1; #define CODED_SECP384R1_OID ecc_oid_secp384r1 #else - #define ecc_oid_secp384r1 CODED_SECP384R1 + #define ecc_oid_secp384r1 CODED_SECP384R1 #endif #define ecc_oid_secp384r1_sz CODED_SECP384R1_SZ #endif /* !NO_ECC_SECP */ @@ -6346,7 +6346,7 @@ int wc_ecc_free(ecc_key* key) #ifdef WOLFSSL_QNX_CAAM /* free secure memory */ if (key->blackKey > 0) { - caamFreePart(key->partNum); + caamFreePart(key->partNum); } #endif @@ -8465,7 +8465,7 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv) #endif DECLARE_CURVE_SPECS(curve, 3); #endif /* USE_ECC_B_PARAM */ -#endif /* !WOLFSSL_ATECC508A && !WOLFSSL_ATECC608A && +#endif /* !WOLFSSL_ATECC508A && !WOLFSSL_ATECC608A && !WOLFSSL_CRYPTOCELL && !WOLFSSL_SILABS_SE_ACCEL && !WOLFSSL_SE050 */ #endif /* !WOLFSSL_SP_MATH */ @@ -8500,7 +8500,7 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv) defined(WOLFSSL_CRYPTOCELL) || defined(WOLFSSL_SILABS_SE_ACCEL) || \ defined(WOLFSSL_SE050) - /* consider key check success on HW crypto + /* consider key check success on HW crypto * ex: ATECC508/608A, CryptoCell and Silabs */ err = MP_OKAY; diff --git a/wolfcrypt/src/eccsi.c b/wolfcrypt/src/eccsi.c index 1fed1833f..81c7afdf6 100644 --- a/wolfcrypt/src/eccsi.c +++ b/wolfcrypt/src/eccsi.c @@ -2045,7 +2045,7 @@ static int eccsi_decode_sig_r_pvt(const EccsiKey* key, const byte* sig, err = mp_read_unsigned_bin(r, sig, sz); } if (err == 0) { - /* must free previous public point otherwise wc_ecc_import_point_der + /* must free previous public point otherwise wc_ecc_import_point_der * could leak memory */ mp_clear(pvt->x); mp_clear(pvt->y); diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index f0855504d..a604c7792 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -682,7 +682,7 @@ int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx, return WOLFSSL_FAILURE; } - /* if(inl == 0)wolfSSL_EVP_CipherUpdate_GCM to get tag */ + /* if(inl == 0)wolfSSL_EVP_CipherUpdate_GCM to get tag */ if (inl == 0) { return WOLFSSL_SUCCESS; } @@ -2195,29 +2195,29 @@ static int DH_param_check(WOLFSSL_DH* dh_key) WOLFSSL_BN_CTX* ctx = NULL; WOLFSSL_BIGNUM *num1 = NULL; WOLFSSL_BIGNUM *num2 = NULL; - + WOLFSSL_ENTER("DH_param_check"); - + ctx = wolfSSL_BN_CTX_new(); if (ctx == NULL) { WOLFSSL_MSG("failed to allocate memory"); return WOLFSSL_FAILURE; } - + num1 = wolfSSL_BN_new(); num2 = wolfSSL_BN_new(); if (num1 == NULL || num2 == NULL) { WOLFSSL_MSG("failed to assign big number"); ret = WOLFSSL_FAILURE; } - + /* prime check */ if (ret == WOLFSSL_SUCCESS && wolfSSL_BN_is_odd(dh_key->p) == 0){ WOLFSSL_MSG("dh_key->p is not prime"); ret = WOLFSSL_FAILURE; } /* TODO safe prime check. need BN_rshift1 */ - + /* generator check */ if (ret == WOLFSSL_SUCCESS && (wolfSSL_BN_is_one(dh_key->g) || @@ -2226,13 +2226,13 @@ static int DH_param_check(WOLFSSL_DH* dh_key) WOLFSSL_MSG("dh_key->g is not suitable generator"); ret = WOLFSSL_FAILURE; } - + if (ret == WOLFSSL_SUCCESS && wolfSSL_BN_cmp(dh_key->p, dh_key->g) <= 0) { WOLFSSL_MSG("dh_key->g is not suitable generator"); ret = WOLFSSL_FAILURE; } - + if (ret == WOLFSSL_SUCCESS && dh_key->q != NULL) { @@ -2257,12 +2257,12 @@ static int DH_param_check(WOLFSSL_DH* dh_key) } /* else TODO check q div q - 1. need BN_div */ #endif } - + /* clean up */ wolfSSL_BN_CTX_free(ctx); wolfSSL_BN_free(num1); wolfSSL_BN_free(num2); - + WOLFSSL_LEAVE("DH_param_check", WOLFSSL_SUCCESS); return ret; } @@ -2276,12 +2276,12 @@ int wolfSSL_EVP_PKEY_param_check(WOLFSSL_EVP_PKEY_CTX* ctx) int type; int ret; WOLFSSL_DH* dh_key = NULL; - + /* sanity check */ if (ctx == NULL) { return WOLFSSL_FAILURE; } - + type = wolfSSL_EVP_PKEY_type(wolfSSL_EVP_PKEY_base_id(ctx->pkey)); switch (type) { #if !defined(NO_RSA) @@ -3222,28 +3222,28 @@ int wolfSSL_PKCS5_PBKDF2_HMAC(const char *pass, int passlen, #if defined(HAVE_SCRYPT) && defined(HAVE_PBKDF2) && !defined(NO_PWDBASED) && \ !defined(NO_SHA256) /** - * Derives a key from the specified password and the salt using SCRYPT + * Derives a key from the specified password and the salt using SCRYPT * algorithm. - * + * * Parameters: * - pass :password data. no need to be null-terminated. NULL is accepted. * - passlen :length of the password. Must be 0 when pass is NULL. * - salt :salt. NULL is accepted. * - saltlen :length of the salt. Must be 0 when salt is NULL. - * - N :cost parameter. Must be grater or equal to 2 and be a power of 2. + * - N :cost parameter. Must be grater or equal to 2 and be a power of 2. * - r :block size. Must 1 or greater. - * - p :parallelism + * - p :parallelism * - maxmem :maximum size of buffer used for calculation in definition, * Not referred in this implementation. * - key :derived key. * - keylen :length of the derived key - * + * * Returns: * 1 on success, otherwise 0. */ int wolfSSL_EVP_PBE_scrypt(const char *pass, size_t passlen, const unsigned char *salt, size_t saltlen, - word64 N, word64 r, word64 p, + word64 N, word64 r, word64 p, word64 maxmem, unsigned char *key, size_t keylen) { (void)maxmem; @@ -3256,7 +3256,7 @@ int wolfSSL_EVP_PBE_scrypt(const char *pass, size_t passlen, WOLFSSL_MSG("Doesn't support greater than 32 bit values of r and p"); return WOLFSSL_FAILURE; } - /* N must be a power of 2 and > 2. + /* N must be a power of 2 and > 2. if (N & (N-1)) is zero, it means N is a power of 2. */ if (N < 2 || (N & (N-1)) || r <= 0 || p <= 0) @@ -3265,7 +3265,7 @@ int wolfSSL_EVP_PBE_scrypt(const char *pass, size_t passlen, if (key == NULL) return WOLFSSL_SUCCESS; - /* get exponent of power of 2. Confirmed N is power of 2. */ + /* get exponent of power of 2. Confirmed N is power of 2. */ while (N != 1) { N >>= 1; exp++; @@ -3772,7 +3772,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) WOLFSSL_ENTER("EVP_blake2b512"); return EVP_get_digestbyname("BLAKE2b512"); } - + #endif #ifdef HAVE_BLAKE2S @@ -3853,19 +3853,19 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512_224(void) { WOLFSSL_ENTER("EVP_sha512_224"); - return EVP_get_digestbyname("SHA512_224"); + return EVP_get_digestbyname("SHA512_224"); } -#endif /* !WOLFSSL_NOSHA512_224 */ +#endif /* !WOLFSSL_NOSHA512_224 */ #ifndef WOLFSSL_NOSHA512_224 const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512_256(void) { WOLFSSL_ENTER("EVP_sha512_256"); - return EVP_get_digestbyname("SHA512_256"); + return EVP_get_digestbyname("SHA512_256"); } -#endif /* !WOLFSSL_NOSHA512_224 */ +#endif /* !WOLFSSL_NOSHA512_224 */ #endif /* WOLFSSL_SHA512 */ @@ -4152,33 +4152,33 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) } return (WOLFSSL_EVP_MD *)NULL; } - + /* return alias name if has * @param n message digest type name * @return alias name, otherwise NULL */ - static const char* hasAliasName(const char* n) + static const char* hasAliasName(const char* n) { - + const char* aliasnm = NULL; const struct alias *al; - + for (al = alias_tbl; al->name != NULL; al++) if(XSTRNCMP(n, al->name, XSTRLEN(al->name)+1) == 0) { aliasnm = al->alias; break; } - + return aliasnm; } - - + + struct do_all_md { void *arg; - void (*fn) (const WOLFSSL_EVP_MD *m, + void (*fn) (const WOLFSSL_EVP_MD *m, const char* from, const char* to, void *arg); }; - + /* do all md algorithm * @param nm a pointer to WOLFSSL_OBJ_NAME * @param arg arguments to pass to the callback @@ -4187,14 +4187,14 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) static void md_do_all_func(const WOLFSSL_OBJ_NAME* nm, void* arg) { struct do_all_md *md = (struct do_all_md*)arg; - + const struct s_ent *ent; - + /* sanity check */ if (md == NULL || nm == NULL || md->fn == NULL || nm->type != WOLFSSL_OBJ_NAME_TYPE_MD_METH) return; - + /* loop all md */ for (ent = md_tbl; ent->name != NULL; ent++){ /* check if the md has alias */ @@ -4206,7 +4206,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) } } } - + /* call md_do_all function to do all md algorithm via a callback function * @param fn a callback function to be called with all 'md' * @param args arguments to pass to the callback @@ -4216,31 +4216,31 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) const char* from, const char* to, void* xx), void* args) { struct do_all_md md; - + md.fn = fn; md.arg = args; - + wolfSSL_OBJ_NAME_do_all(WOLFSSL_OBJ_NAME_TYPE_MD_METH, md_do_all_func, &md); } - + /* call "fn" based on OBJ_NAME type * @param type OBJ_NAME type * @param fn a callback function * @param args arguments to pass to the callback * @return none */ - void wolfSSL_OBJ_NAME_do_all(int type, + void wolfSSL_OBJ_NAME_do_all(int type, void (*fn)(const WOLFSSL_OBJ_NAME*, void* arg), void* arg) { WOLFSSL_OBJ_NAME objnm; - + /* sanity check */ if (!fn) return; - + objnm.type = type; - + switch(type) { case WOLFSSL_OBJ_NAME_TYPE_MD_METH: fn(&objnm, arg); @@ -4256,7 +4256,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) break; } } - + #ifndef NO_AES #if defined(HAVE_AES_CBC) || defined(WOLFSSL_AES_DIRECT) @@ -7916,8 +7916,8 @@ static int Indent(WOLFSSL_BIO* out, int indents) } /* PrintHexWithColon dump byte-data specified by "input" to the "out". * Each line has leading white spaces( "indent" gives the number ) plus - * four spaces, then hex coded 15 byte data with separator ":" follow. - * Each line looks like: + * four spaces, then hex coded 15 byte data with separator ":" follow. + * Each line looks like: * " 00:e6:ab: --- 9f:ef:" * Parmeters: * out bio to output dump data @@ -7966,15 +7966,15 @@ static int PrintHexWithColon(WOLFSSL_BIO* out, const byte* input, /* print pub element */ idx = 0; - for (in = 0; in < (word32)inlen && ret == WOLFSSL_SUCCESS; in += + for (in = 0; in < (word32)inlen && ret == WOLFSSL_SUCCESS; in += EVP_PKEY_PRINT_DIGITS_PER_LINE ) { Indent(out, indent); - for (i = 0; (i < EVP_PKEY_PRINT_DIGITS_PER_LINE) && + for (i = 0; (i < EVP_PKEY_PRINT_DIGITS_PER_LINE) && (in + i < (word32)inlen); i++) { - + if (ret == WOLFSSL_SUCCESS) { outSz = sizeof(outHex); - ret = Base16_Encode((const byte*)&data[in + i], 1, + ret = Base16_Encode((const byte*)&data[in + i], 1, outHex, &outSz) == 0; } if (ret == WOLFSSL_SUCCESS) { @@ -8043,7 +8043,7 @@ static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, indent = EVP_PKEY_PRINT_INDENT_MAX; } /* parse key to get modulus and exponent */ - if (wc_RsaPublicKeyDecode_ex(pkey, &inOutIdx, pkeySz, + if (wc_RsaPublicKeyDecode_ex(pkey, &inOutIdx, pkeySz, &n, &nSz, &e, &eSz) != 0) { return WOLFSSL_FAILURE; } @@ -8078,7 +8078,7 @@ static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, return WOLFSSL_FAILURE; } - /* print modulus with leading zero if exists */ + /* print modulus with leading zero if exists */ if (*n & 0x80 && *(n-1) == 0) { n--; nSz++; @@ -8272,7 +8272,7 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, if (res == WOLFSSL_SUCCESS) { res = wolfSSL_BIO_write(out, "\n", 1) > 0; } - + if (pub != NULL) { XFREE(pub, NULL, DYNAMIC_TYPE_ECC_BUFFER); pub = NULL; @@ -8291,7 +8291,7 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, * pkeySz public key data size * indent the number of spaces for indent * bitlen bit size of the given key - * pctx context(not used) + * pctx context(not used) * Returns 1 on success, 0 on failure. */ static int PrintPubKeyDSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, @@ -8671,7 +8671,7 @@ static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, } #endif /* WOLFSSL_DH_EXTRA */ -/* wolfSSL_EVP_PKEY_print_public parses the specified key then +/* wolfSSL_EVP_PKEY_print_public parses the specified key then * outputs public key info in human readable format to the specified BIO. * White spaces of the same number which 'indent" gives, will be added to * each line to output and ignores pctx parameter. @@ -8680,7 +8680,7 @@ static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, * pkey buffer holding public key data * indent the number of spaces for indent * pctx context(not used) - * Returns 1 on success, 0 or negative on error, -2 means specified key + * Returns 1 on success, 0 or negative on error, -2 means specified key * algo is not supported. * Can handle RSA, ECC, DSA and DH public keys. */ @@ -8878,7 +8878,7 @@ int wolfSSL_EVP_get_hashinfo(const WOLFSSL_EVP_MD* evp, return WOLFSSL_SUCCESS; } -/* Base64 encoding APIs */ +/* Base64 encoding APIs */ #if defined(WOLFSSL_BASE64_ENCODE) || defined(WOLFSSL_BASE64_DECODE) /* wolfSSL_EVP_ENCODE_CTX_new allocates WOLFSSL_EVP_ENCODE_CTX @@ -8956,7 +8956,7 @@ int wolfSSL_EVP_EncodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx, if (ctx->remaining >= BASE64_ENCODE_BLOCK_SIZE) { /* Base64_Encode asks the out buff size via the 4th param*/ outsz = BASE64_ENCODE_RESULT_BLOCK_SIZE + 1; - res = Base64_Encode(ctx->data, BASE64_ENCODE_BLOCK_SIZE, out, + res = Base64_Encode(ctx->data, BASE64_ENCODE_BLOCK_SIZE, out, &outsz); if (res == 0) { ctx->remaining = 0; @@ -8971,7 +8971,7 @@ int wolfSSL_EVP_EncodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx, return 1; } } - /* Here, there is no data left in ctx, so try processing the data of + /* Here, there is no data left in ctx, so try processing the data of * the specified input data. */ diff --git a/wolfcrypt/src/fe_low_mem.c b/wolfcrypt/src/fe_low_mem.c index f683cd7d5..45c1b7abb 100644 --- a/wolfcrypt/src/fe_low_mem.c +++ b/wolfcrypt/src/fe_low_mem.c @@ -69,119 +69,119 @@ void fe_init(void) /* Double an X-coordinate */ static void xc_double(byte *x3, byte *z3, - const byte *x1, const byte *z1) + const byte *x1, const byte *z1) { - /* Explicit formulas database: dbl-1987-m - * - * source 1987 Montgomery "Speeding the Pollard and elliptic - * curve methods of factorization", page 261, fourth display - * compute X3 = (X1^2-Z1^2)^2 - * compute Z3 = 4 X1 Z1 (X1^2 + a X1 Z1 + Z1^2) - */ - byte x1sq[F25519_SIZE]; - byte z1sq[F25519_SIZE]; - byte x1z1[F25519_SIZE]; - byte a[F25519_SIZE]; + /* Explicit formulas database: dbl-1987-m + * + * source 1987 Montgomery "Speeding the Pollard and elliptic + * curve methods of factorization", page 261, fourth display + * compute X3 = (X1^2-Z1^2)^2 + * compute Z3 = 4 X1 Z1 (X1^2 + a X1 Z1 + Z1^2) + */ + byte x1sq[F25519_SIZE]; + byte z1sq[F25519_SIZE]; + byte x1z1[F25519_SIZE]; + byte a[F25519_SIZE]; - fe_mul__distinct(x1sq, x1, x1); - fe_mul__distinct(z1sq, z1, z1); - fe_mul__distinct(x1z1, x1, z1); + fe_mul__distinct(x1sq, x1, x1); + fe_mul__distinct(z1sq, z1, z1); + fe_mul__distinct(x1z1, x1, z1); - lm_sub(a, x1sq, z1sq); - fe_mul__distinct(x3, a, a); + lm_sub(a, x1sq, z1sq); + fe_mul__distinct(x3, a, a); - fe_mul_c(a, x1z1, 486662); - lm_add(a, x1sq, a); - lm_add(a, z1sq, a); - fe_mul__distinct(x1sq, x1z1, a); - fe_mul_c(z3, x1sq, 4); + fe_mul_c(a, x1z1, 486662); + lm_add(a, x1sq, a); + lm_add(a, z1sq, a); + fe_mul__distinct(x1sq, x1z1, a); + fe_mul_c(z3, x1sq, 4); } /* Differential addition */ static void xc_diffadd(byte *x5, byte *z5, - const byte *x1, const byte *z1, - const byte *x2, const byte *z2, - const byte *x3, const byte *z3) + const byte *x1, const byte *z1, + const byte *x2, const byte *z2, + const byte *x3, const byte *z3) { - /* Explicit formulas database: dbl-1987-m3 - * - * source 1987 Montgomery "Speeding the Pollard and elliptic curve - * methods of factorization", page 261, fifth display, plus - * common-subexpression elimination - * compute A = X2+Z2 - * compute B = X2-Z2 - * compute C = X3+Z3 - * compute D = X3-Z3 - * compute DA = D A - * compute CB = C B - * compute X5 = Z1(DA+CB)^2 - * compute Z5 = X1(DA-CB)^2 - */ - byte da[F25519_SIZE]; - byte cb[F25519_SIZE]; - byte a[F25519_SIZE]; - byte b[F25519_SIZE]; + /* Explicit formulas database: dbl-1987-m3 + * + * source 1987 Montgomery "Speeding the Pollard and elliptic curve + * methods of factorization", page 261, fifth display, plus + * common-subexpression elimination + * compute A = X2+Z2 + * compute B = X2-Z2 + * compute C = X3+Z3 + * compute D = X3-Z3 + * compute DA = D A + * compute CB = C B + * compute X5 = Z1(DA+CB)^2 + * compute Z5 = X1(DA-CB)^2 + */ + byte da[F25519_SIZE]; + byte cb[F25519_SIZE]; + byte a[F25519_SIZE]; + byte b[F25519_SIZE]; - lm_add(a, x2, z2); - lm_sub(b, x3, z3); /* D */ - fe_mul__distinct(da, a, b); + lm_add(a, x2, z2); + lm_sub(b, x3, z3); /* D */ + fe_mul__distinct(da, a, b); - lm_sub(b, x2, z2); - lm_add(a, x3, z3); /* C */ - fe_mul__distinct(cb, a, b); + lm_sub(b, x2, z2); + lm_add(a, x3, z3); /* C */ + fe_mul__distinct(cb, a, b); - lm_add(a, da, cb); - fe_mul__distinct(b, a, a); - fe_mul__distinct(x5, z1, b); + lm_add(a, da, cb); + fe_mul__distinct(b, a, a); + fe_mul__distinct(x5, z1, b); - lm_sub(a, da, cb); - fe_mul__distinct(b, a, a); - fe_mul__distinct(z5, x1, b); + lm_sub(a, da, cb); + fe_mul__distinct(b, a, a); + fe_mul__distinct(z5, x1, b); } #ifndef FREESCALE_LTC_ECC int curve25519(byte *result, const byte *e, const byte *q) { - /* Current point: P_m */ - byte xm[F25519_SIZE]; - byte zm[F25519_SIZE] = {1}; + /* Current point: P_m */ + byte xm[F25519_SIZE]; + byte zm[F25519_SIZE] = {1}; - /* Predecessor: P_(m-1) */ - byte xm1[F25519_SIZE] = {1}; - byte zm1[F25519_SIZE] = {0}; + /* Predecessor: P_(m-1) */ + byte xm1[F25519_SIZE] = {1}; + byte zm1[F25519_SIZE] = {0}; - int i; + int i; - /* Note: bit 254 is assumed to be 1 */ - lm_copy(xm, q); + /* Note: bit 254 is assumed to be 1 */ + lm_copy(xm, q); - for (i = 253; i >= 0; i--) { - const int bit = (e[i >> 3] >> (i & 7)) & 1; - byte xms[F25519_SIZE]; - byte zms[F25519_SIZE]; + for (i = 253; i >= 0; i--) { + const int bit = (e[i >> 3] >> (i & 7)) & 1; + byte xms[F25519_SIZE]; + byte zms[F25519_SIZE]; - /* From P_m and P_(m-1), compute P_(2m) and P_(2m-1) */ - xc_diffadd(xm1, zm1, q, f25519_one, xm, zm, xm1, zm1); - xc_double(xm, zm, xm, zm); + /* From P_m and P_(m-1), compute P_(2m) and P_(2m-1) */ + xc_diffadd(xm1, zm1, q, f25519_one, xm, zm, xm1, zm1); + xc_double(xm, zm, xm, zm); - /* Compute P_(2m+1) */ - xc_diffadd(xms, zms, xm1, zm1, xm, zm, q, f25519_one); + /* Compute P_(2m+1) */ + xc_diffadd(xms, zms, xm1, zm1, xm, zm, q, f25519_one); - /* Select: - * bit = 1 --> (P_(2m+1), P_(2m)) - * bit = 0 --> (P_(2m), P_(2m-1)) - */ - fe_select(xm1, xm1, xm, bit); - fe_select(zm1, zm1, zm, bit); - fe_select(xm, xm, xms, bit); - fe_select(zm, zm, zms, bit); - } + /* Select: + * bit = 1 --> (P_(2m+1), P_(2m)) + * bit = 0 --> (P_(2m), P_(2m-1)) + */ + fe_select(xm1, xm1, xm, bit); + fe_select(zm1, zm1, zm, bit); + fe_select(xm, xm, xms, bit); + fe_select(zm, zm, zms, bit); + } - /* Freeze out of projective coordinates */ - fe_inv__distinct(zm1, zm); - fe_mul__distinct(result, zm1, xm); - fe_normalize(result); + /* Freeze out of projective coordinates */ + fe_inv__distinct(zm1, zm); + fe_mul__distinct(result, zm1, xm); + fe_normalize(result); return 0; } #endif /* !FREESCALE_LTC_ECC */ @@ -190,30 +190,30 @@ int curve25519(byte *result, const byte *e, const byte *q) static void raw_add(byte *x, const byte *p) { - word16 c = 0; - int i; + word16 c = 0; + int i; - for (i = 0; i < F25519_SIZE; i++) { - c += ((word16)x[i]) + ((word16)p[i]); - x[i] = (byte)c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += ((word16)x[i]) + ((word16)p[i]); + x[i] = (byte)c; + c >>= 8; + } } static void raw_try_sub(byte *x, const byte *p) { - byte minusp[F25519_SIZE]; - word16 c = 0; - int i; + byte minusp[F25519_SIZE]; + word16 c = 0; + int i; - for (i = 0; i < F25519_SIZE; i++) { - c = ((word16)x[i]) - ((word16)p[i]) - c; - minusp[i] = (byte)c; - c = (c >> 8) & 1; - } + for (i = 0; i < F25519_SIZE; i++) { + c = ((word16)x[i]) - ((word16)p[i]) - c; + minusp[i] = (byte)c; + c = (c >> 8) & 1; + } - fprime_select(x, minusp, x, (byte)c); + fprime_select(x, minusp, x, (byte)c); } @@ -224,333 +224,333 @@ static int prime_msb(const byte *p) int shift = 1; int z = F25519_SIZE - 1; - /* + /* Test for any hot bits. As soon as one instance is encountered set shift to 0. */ - for (i = F25519_SIZE - 1; i >= 0; i--) { + for (i = F25519_SIZE - 1; i >= 0; i--) { shift &= ((shift ^ ((-p[i] | p[i]) >> 7)) & 1); z -= shift; } - x = p[z]; - z <<= 3; + x = p[z]; + z <<= 3; shift = 1; for (i = 0; i < 8; i++) { shift &= ((-(x >> i) | (x >> i)) >> (7 - i) & 1); z += shift; } - return z - 1; + return z - 1; } void fprime_select(byte *dst, const byte *zero, const byte *one, byte condition) { - const byte mask = -condition; - int i; + const byte mask = -condition; + int i; - for (i = 0; i < F25519_SIZE; i++) - dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i])); + for (i = 0; i < F25519_SIZE; i++) + dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i])); } void fprime_add(byte *r, const byte *a, const byte *modulus) { - raw_add(r, a); - raw_try_sub(r, modulus); + raw_add(r, a); + raw_try_sub(r, modulus); } void fprime_sub(byte *r, const byte *a, const byte *modulus) { - raw_add(r, modulus); - raw_try_sub(r, a); - raw_try_sub(r, modulus); + raw_add(r, modulus); + raw_try_sub(r, a); + raw_try_sub(r, modulus); } void fprime_mul(byte *r, const byte *a, const byte *b, - const byte *modulus) + const byte *modulus) { - word16 c = 0; - int i,j; + word16 c = 0; + int i,j; - XMEMSET(r, 0, F25519_SIZE); + XMEMSET(r, 0, F25519_SIZE); - for (i = prime_msb(modulus); i >= 0; i--) { - const byte bit = (b[i >> 3] >> (i & 7)) & 1; - byte plusa[F25519_SIZE]; + for (i = prime_msb(modulus); i >= 0; i--) { + const byte bit = (b[i >> 3] >> (i & 7)) & 1; + byte plusa[F25519_SIZE]; - for (j = 0; j < F25519_SIZE; j++) { - c |= ((word16)r[j]) << 1; - r[j] = (byte)c; - c >>= 8; - } - raw_try_sub(r, modulus); + for (j = 0; j < F25519_SIZE; j++) { + c |= ((word16)r[j]) << 1; + r[j] = (byte)c; + c >>= 8; + } + raw_try_sub(r, modulus); - fprime_copy(plusa, r); - fprime_add(plusa, a, modulus); + fprime_copy(plusa, r); + fprime_add(plusa, a, modulus); - fprime_select(r, r, plusa, bit); - } + fprime_select(r, r, plusa, bit); + } } void fe_load(byte *x, word32 c) { - word32 i; + word32 i; - for (i = 0; i < sizeof(c); i++) { - x[i] = c; - c >>= 8; - } + for (i = 0; i < sizeof(c); i++) { + x[i] = c; + c >>= 8; + } - for (; i < F25519_SIZE; i++) - x[i] = 0; + for (; i < F25519_SIZE; i++) + x[i] = 0; } void fe_normalize(byte *x) { - byte minusp[F25519_SIZE]; - word16 c; - int i; + byte minusp[F25519_SIZE]; + word16 c; + int i; - /* Reduce using 2^255 = 19 mod p */ - c = (x[31] >> 7) * 19; - x[31] &= 127; + /* Reduce using 2^255 = 19 mod p */ + c = (x[31] >> 7) * 19; + x[31] &= 127; - for (i = 0; i < F25519_SIZE; i++) { - c += x[i]; - x[i] = (byte)c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += x[i]; + x[i] = (byte)c; + c >>= 8; + } - /* The number is now less than 2^255 + 18, and therefore less than - * 2p. Try subtracting p, and conditionally load the subtracted - * value if underflow did not occur. - */ - c = 19; + /* The number is now less than 2^255 + 18, and therefore less than + * 2p. Try subtracting p, and conditionally load the subtracted + * value if underflow did not occur. + */ + c = 19; - for (i = 0; i + 1 < F25519_SIZE; i++) { - c += x[i]; - minusp[i] = (byte)c; - c >>= 8; - } + for (i = 0; i + 1 < F25519_SIZE; i++) { + c += x[i]; + minusp[i] = (byte)c; + c >>= 8; + } - c += ((word16)x[i]) - 128; - minusp[31] = (byte)c; + c += ((word16)x[i]) - 128; + minusp[31] = (byte)c; - /* Load x-p if no underflow */ - fe_select(x, minusp, x, (c >> 15) & 1); + /* Load x-p if no underflow */ + fe_select(x, minusp, x, (c >> 15) & 1); } void fe_select(byte *dst, - const byte *zero, const byte *one, - byte condition) + const byte *zero, const byte *one, + byte condition) { - const byte mask = -condition; - int i; + const byte mask = -condition; + int i; - for (i = 0; i < F25519_SIZE; i++) - dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i])); + for (i = 0; i < F25519_SIZE; i++) + dst[i] = zero[i] ^ (mask & (one[i] ^ zero[i])); } void lm_add(byte* r, const byte* a, const byte* b) { - word16 c = 0; - int i; + word16 c = 0; + int i; - /* Add */ - for (i = 0; i < F25519_SIZE; i++) { - c >>= 8; - c += ((word16)a[i]) + ((word16)b[i]); - r[i] = (byte)c; - } + /* Add */ + for (i = 0; i < F25519_SIZE; i++) { + c >>= 8; + c += ((word16)a[i]) + ((word16)b[i]); + r[i] = (byte)c; + } - /* Reduce with 2^255 = 19 mod p */ - r[31] &= 127; - c = (c >> 7) * 19; + /* Reduce with 2^255 = 19 mod p */ + r[31] &= 127; + c = (c >> 7) * 19; - for (i = 0; i < F25519_SIZE; i++) { - c += r[i]; - r[i] = (byte)c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += r[i]; + r[i] = (byte)c; + c >>= 8; + } } void lm_sub(byte* r, const byte* a, const byte* b) { - word32 c = 0; - int i; + word32 c = 0; + int i; - /* Calculate a + 2p - b, to avoid underflow */ - c = 218; - for (i = 0; i + 1 < F25519_SIZE; i++) { - c += 65280 + ((word32)a[i]) - ((word32)b[i]); - r[i] = c; - c >>= 8; - } + /* Calculate a + 2p - b, to avoid underflow */ + c = 218; + for (i = 0; i + 1 < F25519_SIZE; i++) { + c += 65280 + ((word32)a[i]) - ((word32)b[i]); + r[i] = c; + c >>= 8; + } - c += ((word32)a[31]) - ((word32)b[31]); - r[31] = c & 127; - c = (c >> 7) * 19; + c += ((word32)a[31]) - ((word32)b[31]); + r[31] = c & 127; + c = (c >> 7) * 19; - for (i = 0; i < F25519_SIZE; i++) { - c += r[i]; - r[i] = c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += r[i]; + r[i] = c; + c >>= 8; + } } void lm_neg(byte* r, const byte* a) { - word32 c = 0; - int i; + word32 c = 0; + int i; - /* Calculate 2p - a, to avoid underflow */ - c = 218; - for (i = 0; i + 1 < F25519_SIZE; i++) { - c += 65280 - ((word32)a[i]); - r[i] = c; - c >>= 8; - } + /* Calculate 2p - a, to avoid underflow */ + c = 218; + for (i = 0; i + 1 < F25519_SIZE; i++) { + c += 65280 - ((word32)a[i]); + r[i] = c; + c >>= 8; + } - c -= ((word32)a[31]); - r[31] = c & 127; - c = (c >> 7) * 19; + c -= ((word32)a[31]); + r[31] = c & 127; + c = (c >> 7) * 19; - for (i = 0; i < F25519_SIZE; i++) { - c += r[i]; - r[i] = c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += r[i]; + r[i] = c; + c >>= 8; + } } void fe_mul__distinct(byte *r, const byte *a, const byte *b) { - word32 c = 0; - int i; + word32 c = 0; + int i; - for (i = 0; i < F25519_SIZE; i++) { - int j; + for (i = 0; i < F25519_SIZE; i++) { + int j; - c >>= 8; - for (j = 0; j <= i; j++) - c += ((word32)a[j]) * ((word32)b[i - j]); + c >>= 8; + for (j = 0; j <= i; j++) + c += ((word32)a[j]) * ((word32)b[i - j]); - for (; j < F25519_SIZE; j++) - c += ((word32)a[j]) * - ((word32)b[i + F25519_SIZE - j]) * 38; + for (; j < F25519_SIZE; j++) + c += ((word32)a[j]) * + ((word32)b[i + F25519_SIZE - j]) * 38; - r[i] = c; - } + r[i] = c; + } - r[31] &= 127; - c = (c >> 7) * 19; + r[31] &= 127; + c = (c >> 7) * 19; - for (i = 0; i < F25519_SIZE; i++) { - c += r[i]; - r[i] = c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += r[i]; + r[i] = c; + c >>= 8; + } } void lm_mul(byte *r, const byte* a, const byte *b) { - byte tmp[F25519_SIZE]; + byte tmp[F25519_SIZE]; - fe_mul__distinct(tmp, a, b); - lm_copy(r, tmp); + fe_mul__distinct(tmp, a, b); + lm_copy(r, tmp); } void fe_mul_c(byte *r, const byte *a, word32 b) { - word32 c = 0; - int i; + word32 c = 0; + int i; - for (i = 0; i < F25519_SIZE; i++) { - c >>= 8; - c += b * ((word32)a[i]); - r[i] = c; - } + for (i = 0; i < F25519_SIZE; i++) { + c >>= 8; + c += b * ((word32)a[i]); + r[i] = c; + } - r[31] &= 127; - c >>= 7; - c *= 19; + r[31] &= 127; + c >>= 7; + c *= 19; - for (i = 0; i < F25519_SIZE; i++) { - c += r[i]; - r[i] = c; - c >>= 8; - } + for (i = 0; i < F25519_SIZE; i++) { + c += r[i]; + r[i] = c; + c >>= 8; + } } void fe_inv__distinct(byte *r, const byte *x) { - byte s[F25519_SIZE]; - int i; + byte s[F25519_SIZE]; + int i; - /* This is a prime field, so by Fermat's little theorem: - * - * x^(p-1) = 1 mod p - * - * Therefore, raise to (p-2) = 2^255-21 to get a multiplicative - * inverse. - * - * This is a 255-bit binary number with the digits: - * - * 11111111... 01011 - * - * We compute the result by the usual binary chain, but - * alternate between keeping the accumulator in r and s, so as - * to avoid copying temporaries. - */ + /* This is a prime field, so by Fermat's little theorem: + * + * x^(p-1) = 1 mod p + * + * Therefore, raise to (p-2) = 2^255-21 to get a multiplicative + * inverse. + * + * This is a 255-bit binary number with the digits: + * + * 11111111... 01011 + * + * We compute the result by the usual binary chain, but + * alternate between keeping the accumulator in r and s, so as + * to avoid copying temporaries. + */ - /* 1 1 */ - fe_mul__distinct(s, x, x); - fe_mul__distinct(r, s, x); + /* 1 1 */ + fe_mul__distinct(s, x, x); + fe_mul__distinct(r, s, x); - /* 1 x 248 */ - for (i = 0; i < 248; i++) { - fe_mul__distinct(s, r, r); - fe_mul__distinct(r, s, x); - } + /* 1 x 248 */ + for (i = 0; i < 248; i++) { + fe_mul__distinct(s, r, r); + fe_mul__distinct(r, s, x); + } - /* 0 */ - fe_mul__distinct(s, r, r); + /* 0 */ + fe_mul__distinct(s, r, r); - /* 1 */ - fe_mul__distinct(r, s, s); - fe_mul__distinct(s, r, x); + /* 1 */ + fe_mul__distinct(r, s, s); + fe_mul__distinct(s, r, x); - /* 0 */ - fe_mul__distinct(r, s, s); + /* 0 */ + fe_mul__distinct(r, s, s); - /* 1 */ - fe_mul__distinct(s, r, r); - fe_mul__distinct(r, s, x); + /* 1 */ + fe_mul__distinct(s, r, r); + fe_mul__distinct(r, s, x); - /* 1 */ - fe_mul__distinct(s, r, r); - fe_mul__distinct(r, s, x); + /* 1 */ + fe_mul__distinct(s, r, r); + fe_mul__distinct(r, s, x); } void lm_invert(byte *r, const byte *x) { - byte tmp[F25519_SIZE]; + byte tmp[F25519_SIZE]; - fe_inv__distinct(tmp, x); - lm_copy(r, tmp); + fe_inv__distinct(tmp, x); + lm_copy(r, tmp); } @@ -559,52 +559,52 @@ void lm_invert(byte *r, const byte *x) */ static void exp2523(byte *r, const byte *x, byte *s) { - int i; + int i; - /* This number is a 252-bit number with the binary expansion: - * - * 111111... 01 - */ + /* This number is a 252-bit number with the binary expansion: + * + * 111111... 01 + */ - /* 1 1 */ - fe_mul__distinct(r, x, x); - fe_mul__distinct(s, r, x); + /* 1 1 */ + fe_mul__distinct(r, x, x); + fe_mul__distinct(s, r, x); - /* 1 x 248 */ - for (i = 0; i < 248; i++) { - fe_mul__distinct(r, s, s); - fe_mul__distinct(s, r, x); - } + /* 1 x 248 */ + for (i = 0; i < 248; i++) { + fe_mul__distinct(r, s, s); + fe_mul__distinct(s, r, x); + } - /* 0 */ - fe_mul__distinct(r, s, s); + /* 0 */ + fe_mul__distinct(r, s, s); - /* 1 */ - fe_mul__distinct(s, r, r); - fe_mul__distinct(r, s, x); + /* 1 */ + fe_mul__distinct(s, r, r); + fe_mul__distinct(r, s, x); } void fe_sqrt(byte *r, const byte *a) { - byte v[F25519_SIZE]; - byte i[F25519_SIZE]; - byte x[F25519_SIZE]; - byte y[F25519_SIZE]; + byte v[F25519_SIZE]; + byte i[F25519_SIZE]; + byte x[F25519_SIZE]; + byte y[F25519_SIZE]; - /* v = (2a)^((p-5)/8) [x = 2a] */ - fe_mul_c(x, a, 2); - exp2523(v, x, y); + /* v = (2a)^((p-5)/8) [x = 2a] */ + fe_mul_c(x, a, 2); + exp2523(v, x, y); - /* i = 2av^2 - 1 */ - fe_mul__distinct(y, v, v); - fe_mul__distinct(i, x, y); - fe_load(y, 1); - lm_sub(i, i, y); + /* i = 2av^2 - 1 */ + fe_mul__distinct(y, v, v); + fe_mul__distinct(i, x, y); + fe_load(y, 1); + lm_sub(i, i, y); - /* r = avi */ - fe_mul__distinct(x, v, a); - fe_mul__distinct(r, x, i); + /* r = avi */ + fe_mul__distinct(x, v, a); + fe_mul__distinct(r, x, i); } #endif /* CURVE25519_SMALL || ED25519_SMALL */ diff --git a/wolfcrypt/src/fe_operations.c b/wolfcrypt/src/fe_operations.c index 9fc299d2c..f11b183aa 100644 --- a/wolfcrypt/src/fe_operations.c +++ b/wolfcrypt/src/fe_operations.c @@ -175,24 +175,24 @@ int curve25519(byte* q, const byte* n, const byte* p) swap = b; /* montgomery */ - fe_sub(tmp0,x3,z3); - fe_sub(tmp1,x2,z2); - fe_add(x2,x2,z2); - fe_add(z2,x3,z3); - fe_mul(z3,tmp0,x2); - fe_mul(z2,z2,tmp1); - fe_sq(tmp0,tmp1); - fe_sq(tmp1,x2); - fe_add(x3,z3,z2); - fe_sub(z2,z3,z2); - fe_mul(x2,tmp1,tmp0); - fe_sub(tmp1,tmp1,tmp0); - fe_sq(z2,z2); - fe_mul121666(z3,tmp1); - fe_sq(x3,x3); - fe_add(tmp0,tmp0,z3); - fe_mul(z3,x1,z2); - fe_mul(z2,tmp1,tmp0); + fe_sub(tmp0,x3,z3); + fe_sub(tmp1,x2,z2); + fe_add(x2,x2,z2); + fe_add(z2,x3,z3); + fe_mul(z3,tmp0,x2); + fe_mul(z2,z2,tmp1); + fe_sq(tmp0,tmp1); + fe_sq(tmp1,x2); + fe_add(x3,z3,z2); + fe_sub(z2,z3,z2); + fe_mul(x2,tmp1,tmp0); + fe_sub(tmp1,tmp1,tmp0); + fe_sq(z2,z2); + fe_mul121666(z3,tmp1); + fe_sq(x3,x3); + fe_add(tmp0,tmp0,z3); + fe_mul(z3,x1,z2); + fe_mul(z2,tmp1,tmp0); } fe_cswap(x2,x3,swap); fe_cswap(z2,z3,swap); diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index f03078683..13b111362 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -4614,7 +4614,7 @@ static int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) if (w >= b) { #ifdef WOLFSSL_LINUXKM t = (mp_digit)w; - /* Linux kernel macro for in-place 64 bit integer division. */ + /* Linux kernel macro for in-place 64 bit integer division. */ do_div(t, b); #else t = (mp_digit)(w / b); diff --git a/wolfcrypt/src/memory.c b/wolfcrypt/src/memory.c index 945f86fbc..1ff7ed6dd 100644 --- a/wolfcrypt/src/memory.c +++ b/wolfcrypt/src/memory.c @@ -143,7 +143,7 @@ void* wolfSSL_Malloc(size_t size) return NULL; } #endif - + res = malloc(size); #else WOLFSSL_MSG("No malloc available"); diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c index 27c75536f..3ec59a0c2 100644 --- a/wolfcrypt/src/misc.c +++ b/wolfcrypt/src/misc.c @@ -139,7 +139,7 @@ WC_STATIC WC_INLINE word16 rotrFixed16(word16 x, word16 y) #endif /* WC_RC2 */ /* This routine performs a byte swap of 32-bit word value. */ -#if defined(__CCRX__) && !defined(NO_INLINE) // shortest version for CC-RX +#if defined(__CCRX__) && !defined(NO_INLINE) /* shortest version for CC-RX */ #define ByteReverseWord32(value) _builtin_revl(value) #else WC_STATIC WC_INLINE word32 ByteReverseWord32(word32 value) @@ -214,14 +214,14 @@ WC_STATIC WC_INLINE word64 ByteReverseWord64(word64 value) #if defined(WOLF_ALLOW_BUILTIN) && defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) return (word64)__builtin_bswap64(value); #elif defined(WOLFCRYPT_SLOW_WORD64) - return (word64)((word64)ByteReverseWord32((word32) value)) << 32 | - (word64)ByteReverseWord32((word32)(value >> 32)); + return (word64)((word64)ByteReverseWord32((word32) value)) << 32 | + (word64)ByteReverseWord32((word32)(value >> 32)); #else - value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) | - ((value & W64LIT(0x00FF00FF00FF00FF)) << 8); - value = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) | - ((value & W64LIT(0x0000FFFF0000FFFF)) << 16); - return rotlFixed64(value, 32U); + value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) | + ((value & W64LIT(0x00FF00FF00FF00FF)) << 8); + value = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) | + ((value & W64LIT(0x0000FFFF0000FFFF)) << 16); + return rotlFixed64(value, 32U); #endif } diff --git a/wolfcrypt/src/pkcs12.c b/wolfcrypt/src/pkcs12.c index 5ea4dec78..bb807f928 100644 --- a/wolfcrypt/src/pkcs12.c +++ b/wolfcrypt/src/pkcs12.c @@ -170,7 +170,7 @@ void wc_PKCS12_free(WC_PKCS12* pkcs12) heap = pkcs12->heap; if (pkcs12->safe != NULL) { - freeSafe(pkcs12->safe, heap); + freeSafe(pkcs12->safe, heap); } /* free mac data */ diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c index 6c4a93622..4ba869452 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c @@ -104,10 +104,10 @@ static uint32_t GetTsipCipherSuite( default: tsipCipher = (uint32_t)WOLFSSL_TSIP_ILLEGAL_CIPHERSUITE; break; - } + } WOLFSSL_MSG( "<< GetTsipCipherSuite"); return tsipCipher; - } + } else if( cipherSuiteFirst == ECC_BYTE ) { tsipCipher = (uint32_t)WOLFSSL_TSIP_ILLEGAL_CIPHERSUITE; @@ -135,7 +135,7 @@ static uint32_t GetTsipCipherSuite( break; } */ } - else{ + else{ tsipCipher = (uint32_t)WOLFSSL_TSIP_ILLEGAL_CIPHERSUITE; } diff --git a/wolfcrypt/src/port/af_alg/afalg_hash.c b/wolfcrypt/src/port/af_alg/afalg_hash.c index 6b2069a34..ca2ef5b98 100644 --- a/wolfcrypt/src/port/af_alg/afalg_hash.c +++ b/wolfcrypt/src/port/af_alg/afalg_hash.c @@ -113,7 +113,7 @@ static int AfalgHashUpdate(wolfssl_AFALG_Hash* hash, const byte* in, word32 sz) DYNAMIC_TYPE_TMP_BUFFER); if (pt == NULL) { return MEMORY_E; - } + } hash->msg = pt; } if (hash->msg == NULL) { diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 1857d5cd3..253528b98 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -1008,10 +1008,10 @@ int wc_RNG_GenerateBlock(WC_RNG* rng, byte* output, word32 sz) ret = wc_RNG_TestSeed(newSeed, SEED_SZ + SEED_BLOCK_SZ); if (ret == DRBG_SUCCESS) - ret = Hash_DRBG_Reseed((DRBG_internal *)rng->drbg, newSeed + SEED_BLOCK_SZ, + ret = Hash_DRBG_Reseed((DRBG_internal *)rng->drbg, newSeed + SEED_BLOCK_SZ, SEED_SZ); if (ret == DRBG_SUCCESS) - ret = Hash_DRBG_Generate((DRBG_internal *)rng->drbg, output, sz); + ret = Hash_DRBG_Generate((DRBG_internal *)rng->drbg, output, sz); ForceZero(newSeed, sizeof(newSeed)); } @@ -1657,14 +1657,14 @@ static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz) int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) { int ret = !SGX_SUCCESS; - int i, read_max = 10; + int i, read_max = 10; - for (i = 0; i < read_max && ret != SGX_SUCCESS; i++) { - ret = sgx_read_rand(output, sz); - } + for (i = 0; i < read_max && ret != SGX_SUCCESS; i++) { + ret = sgx_read_rand(output, sz); + } - (void)os; - return (ret == SGX_SUCCESS) ? 0 : 1; + (void)os; + return (ret == SGX_SUCCESS) ? 0 : 1; } #elif defined(USE_WINDOWS_API) @@ -1777,7 +1777,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) RNGPOLY2 = _CP0_GET_COUNT(); RNGNUMGEN2 = _CP0_GET_COUNT(); #else - // All others can be seeded from the TRNG + /* All others can be seeded from the TRNG */ RNGCONbits.TRNGMODE = 1; RNGCONbits.TRNGEN = 1; while (RNGCNT < 64); @@ -2602,12 +2602,12 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) } #elif defined(WOLFSSL_SE050) #include - + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz){ int ret = 0; - + (void)os; - + if (output == NULL) { return BUFFER_E; } diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 86195d1f8..2849cfe57 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -4369,10 +4369,10 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng) tmp3 = (mp_int *)XMALLOC(sizeof *tmp3, key->heap, DYNAMIC_TYPE_RSA); if ((p == NULL) || - (q == NULL) || - (tmp1 == NULL) || - (tmp2 == NULL) || - (tmp3 == NULL)) { + (q == NULL) || + (tmp1 == NULL) || + (tmp2 == NULL) || + (tmp3 == NULL)) { err = MEMORY_E; goto out; } diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index cf94def92..e0e2b1531 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -28,9 +28,7 @@ #if !defined(NO_SHA) -#if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - +#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index 0aa3ff75c..60684f59d 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -55,9 +55,7 @@ where 0 <= L < 2^64. #if !defined(NO_SHA256) && !defined(WOLFSSL_ARMASM) -#if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - +#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS @@ -604,7 +602,7 @@ static int InitSha256(wc_Sha256* sha256) } int wc_Sha256Final(wc_Sha256* sha256, byte* hash) - { + { int ret = 0; ret = se050_hash_final(&sha256->se050Ctx, hash, WC_SHA256_DIGEST_SIZE, kAlgorithm_SSS_SHA256); @@ -614,7 +612,7 @@ static int InitSha256(wc_Sha256* sha256) int wc_Sha256FinalRaw(wc_Sha256* sha256, byte* hash) { int ret = 0; - ret = se050_hash_final(&sha256->se050Ctx, hash, WC_SHA256_DIGEST_SIZE, + ret = se050_hash_final(&sha256->se050Ctx, hash, WC_SHA256_DIGEST_SIZE, kAlgorithm_SSS_SHA256); (void)wc_InitSha256(sha256); return ret; @@ -1420,7 +1418,7 @@ static int InitSha256(wc_Sha256* sha256) return BAD_FUNC_ARG; } (void)devId; - + return se050_hash_init(&sha224->se050Ctx, heap); } @@ -1431,7 +1429,7 @@ static int InitSha256(wc_Sha256* sha256) int wc_Sha224Final(wc_Sha224* sha224, byte* hash) { - int ret = 0; + int ret = 0; ret = se050_hash_final(&sha224->se050Ctx, hash, WC_SHA224_DIGEST_SIZE, kAlgorithm_SSS_SHA224); (void)wc_InitSha224(sha224); diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index 531460e3e..6142adbae 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -29,9 +29,7 @@ #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_XILINX_CRYPT) && \ !defined(WOLFSSL_AFALG_XILINX_SHA3) -#if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - +#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS diff --git a/wolfcrypt/src/sha512.c b/wolfcrypt/src/sha512.c index 77b472241..88e9bf96a 100644 --- a/wolfcrypt/src/sha512.c +++ b/wolfcrypt/src/sha512.c @@ -28,9 +28,7 @@ #if (defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)) && !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PSOC6_CRYPTO) -#if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - +#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */ #define FIPS_NO_WRAPPERS @@ -1240,7 +1238,7 @@ int wc_Sha512Transform(wc_Sha512* sha, const unsigned char* data) int wc_Sha384Update(wc_Sha384* sha384, const byte* data, word32 len) { return se050_hash_update(&sha384->se050Ctx, data, len); - + } int wc_Sha384Final(wc_Sha384* sha384, byte* hash) { diff --git a/wolfcrypt/src/signature.c b/wolfcrypt/src/signature.c index 948d17c33..a9496cbb7 100644 --- a/wolfcrypt/src/signature.c +++ b/wolfcrypt/src/signature.c @@ -212,9 +212,9 @@ int wc_SignatureVerifyHash( if (plain_len <= sizeof(plain_data)) #endif { - byte* plain_ptr = NULL; - XMEMSET(plain_data, 0, plain_len); - XMEMCPY(plain_data, sig, sig_len); + byte* plain_ptr = NULL; + XMEMSET(plain_data, 0, plain_len); + XMEMCPY(plain_data, sig, sig_len); /* Perform verification of signature using provided RSA key */ do { #ifdef WOLFSSL_ASYNC_CRYPT @@ -222,7 +222,7 @@ int wc_SignatureVerifyHash( WC_ASYNC_FLAG_CALL_AGAIN); #endif if (ret >= 0) - ret = wc_RsaSSL_VerifyInline(plain_data, sig_len, &plain_ptr, (RsaKey*)key); + ret = wc_RsaSSL_VerifyInline(plain_data, sig_len, &plain_ptr, (RsaKey*)key); } while (ret == WC_PENDING_E); if (ret >= 0 && plain_ptr) { if ((word32)ret == hash_len && diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index b5a25a905..49aea4cb4 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -497,7 +497,7 @@ WC_INLINE static int fp_mul_comba_mulx(fp_int *A, fp_int *B, fp_int *C) #else fp_int *tmp; #endif - + /* Variables used but not seen by cppcheck. */ (void)ix; (void)iy; (void)iz; @@ -604,7 +604,7 @@ int fp_mul_comba(fp_int *A, fp_int *B, fp_int *C) dst->sign = A->sign ^ B->sign; fp_clamp(dst); fp_copy(dst, C); - + /* Variables used but not seen by cppcheck. */ (void)c0; (void)c1; (void)c2; @@ -3230,7 +3230,7 @@ int fp_sqr_comba(fp_int *A, fp_int *B) #ifdef TFM_ISO (void)tt; #endif - + #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT); #endif @@ -4746,7 +4746,7 @@ static int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) if (w >= b) { #ifdef WOLFSSL_LINUXKM t = (fp_digit)w; - /* Linux kernel macro for in-place 64 bit integer division. */ + /* Linux kernel macro for in-place 64 bit integer division. */ do_div(t, b); #else t = (fp_digit)(w / b); diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 5d27ebd1e..30de50f63 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -243,7 +243,7 @@ int wolfCrypt_Init(void) #endif #ifdef WOLFSSL_AFALG - WOLFSSL_MSG("Using AF_ALG for crypto acceleration"); + WOLFSSL_MSG("Using AF_ALG for crypto acceleration"); #endif #if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA) @@ -296,7 +296,7 @@ int wolfCrypt_Init(void) #endif #if defined(WOLFSSL_DSP) && !defined(WOLFSSL_DSP_BUILD) - if ((ret = wolfSSL_InitHandle()) != 0) { + if ((ret = wolfSSL_InitHandle()) != 0) { return ret; } rpcmem_init(); @@ -384,7 +384,7 @@ int wolfCrypt_Cleanup(void) #ifndef NO_FILESYSTEM /* Helpful function to load file into allocated buffer */ -int wc_FileLoad(const char* fname, unsigned char** buf, size_t* bufLen, +int wc_FileLoad(const char* fname, unsigned char** buf, size_t* bufLen, void* heap) { int ret; @@ -834,7 +834,7 @@ int z_fs_close(XFILE file) #endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */ -#if !defined(WOLFSSL_USER_MUTEX) +#if !defined(WOLFSSL_USER_MUTEX) wolfSSL_Mutex* wc_InitAndAllocMutex(void) { wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL, @@ -1918,8 +1918,8 @@ int wolfSSL_CryptHwMutexUnLock(void) del = DeleteRtSemaphore( *m /* handle for RT semaphore */ ); - if (del != TRUE) - ret = BAD_MUTEX_E; + if (del != TRUE) + ret = BAD_MUTEX_E; return ret; } @@ -1957,8 +1957,8 @@ int wolfSSL_CryptHwMutexUnLock(void) *m, /* handle for RT semaphore */ 1 /* number of units to release to semaphore */ ); - if (rel != TRUE) - ret = BAD_MUTEX_E; + if (rel != TRUE) + ret = BAD_MUTEX_E; return ret; } @@ -2107,7 +2107,7 @@ int wolfSSL_CryptHwMutexUnLock(void) #elif defined(WOLFSSL_USER_MUTEX) /* Use user own mutex */ - + /* int wc_InitMutex(wolfSSL_Mutex* m) { ... } int wc_FreeMutex(wolfSSL_Mutex *m) { ... } @@ -2595,15 +2595,15 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n) return ptr; } #endif /* ! __PIE__ */ - } + } - nptr = kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE); - if (nptr != NULL) { + nptr = kvmalloc_node(newsize, GFP_KERNEL, NUMA_NO_NODE); + if (nptr != NULL) { memcpy(nptr, ptr, oldsize); kvfree(ptr); - } + } - return nptr; + return nptr; } #endif /* WOLFSSL_LINUXKM && HAVE_KVMALLOC */ diff --git a/wolfcrypt/src/wolfmath.c b/wolfcrypt/src/wolfmath.c index 9ed023468..4b0b88840 100644 --- a/wolfcrypt/src/wolfmath.c +++ b/wolfcrypt/src/wolfmath.c @@ -227,7 +227,7 @@ int wc_export_int(mp_int* mp, byte* buf, word32* len, word32 keySz, } *len = (word32)size; err = mp_tohex(mp, (char*)buf); - } + } #else err = NOT_COMPILED_IN; #endif diff --git a/wolfcrypt/user-crypto/src/rsa.c b/wolfcrypt/user-crypto/src/rsa.c index ae5218d54..838b3dbf3 100644 --- a/wolfcrypt/user-crypto/src/rsa.c +++ b/wolfcrypt/user-crypto/src/rsa.c @@ -2769,7 +2769,7 @@ int wc_RsaKeyToPublicDer(RsaKey* key, byte* output, word32 inLen) return SetRsaPublicKey(output, key, inLen, 1); } -/* Returns public DER version of the RSA key. If with_header is 0 then only a +/* Returns public DER version of the RSA key. If with_header is 0 then only a * seq + n + e is returned in ASN.1 DER format */ int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen, int with_header) diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 744cf5037..c6639e30b 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -1359,7 +1359,7 @@ enum Misc { /* max size of buffer for exporting state */ FINISHED_LABEL_SZ = 15, /* TLS finished label size */ TLS_FINISHED_SZ = 12, /* TLS has a shorter size */ - TLS_FINISHED_SZ_MAX = WC_MAX_DIGEST_SIZE, + TLS_FINISHED_SZ_MAX = WC_MAX_DIGEST_SIZE, /* longest message digest size is SHA512, 64 */ EXT_MASTER_LABEL_SZ = 22, /* TLS extended master secret label sz */ MASTER_LABEL_SZ = 13, /* TLS master secret label sz */ @@ -1658,13 +1658,13 @@ enum states { SERVER_CERT_VERIFY_COMPLETE, SERVER_KEYEXCHANGE_COMPLETE, SERVER_HELLODONE_COMPLETE, - SERVER_CHANGECIPHERSPEC_COMPLETE, + SERVER_CHANGECIPHERSPEC_COMPLETE, SERVER_FINISHED_COMPLETE, CLIENT_HELLO_RETRY, CLIENT_HELLO_COMPLETE, CLIENT_KEYEXCHANGE_COMPLETE, - CLIENT_CHANGECIPHERSPEC_COMPLETE, + CLIENT_CHANGECIPHERSPEC_COMPLETE, CLIENT_FINISHED_COMPLETE, HANDSHAKE_DONE @@ -4902,7 +4902,7 @@ WOLFSSL_LOCAL const char* GetCipherNameInternal(const byte cipherSuite0, const b #define MAX_SEGMENTS 5 #define MAX_SEGMENT_SZ 20 WOLFSSL_LOCAL int wolfSSL_sk_CIPHER_description(WOLFSSL_CIPHER*); -WOLFSSL_LOCAL const char* GetCipherSegment(const WOLFSSL_CIPHER* cipher, +WOLFSSL_LOCAL const char* GetCipherSegment(const WOLFSSL_CIPHER* cipher, char n[][MAX_SEGMENT_SZ]); WOLFSSL_LOCAL const char* GetCipherProtocol(const byte minor); WOLFSSL_LOCAL const char* GetCipherKeaStr(char n[][MAX_SEGMENT_SZ]); @@ -4990,7 +4990,7 @@ WOLFSSL_LOCAL void FreeKey(WOLFSSL* ssl, int type, void** pKey); #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) -WOLFSSL_LOCAL int LoadCertByIssuer(WOLFSSL_X509_STORE* store, +WOLFSSL_LOCAL int LoadCertByIssuer(WOLFSSL_X509_STORE* store, X509_NAME* issuer, int Type); #endif #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) diff --git a/wolfssl/openssl/dh.h b/wolfssl/openssl/dh.h index cf89067fc..751024f81 100644 --- a/wolfssl/openssl/dh.h +++ b/wolfssl/openssl/dh.h @@ -70,7 +70,7 @@ WOLFSSL_API int wolfSSL_DH_LoadDer(WOLFSSL_DH*, const unsigned char*, int sz); WOLFSSL_API int wolfSSL_DH_set_length(WOLFSSL_DH*, long); WOLFSSL_API int wolfSSL_DH_set0_pqg(WOLFSSL_DH*, WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*); - + #define DH_new wolfSSL_DH_new #define DH_free wolfSSL_DH_free diff --git a/wolfssl/openssl/dsa.h b/wolfssl/openssl/dsa.h index b0ff4f70e..7312e389a 100644 --- a/wolfssl/openssl/dsa.h +++ b/wolfssl/openssl/dsa.h @@ -146,7 +146,7 @@ WOLFSSL_API WOLFSSL_DSA* wolfSSL_d2i_DSAparams(WOLFSSL_DSA**, #define DSA_SIG WOLFSSL_DSA_SIG #ifdef __cplusplus - } /* extern "C" */ + } /* extern "C" */ #endif #endif /* header */ diff --git a/wolfssl/openssl/evp.h b/wolfssl/openssl/evp.h index 985e00b16..871fcf8bc 100644 --- a/wolfssl/openssl/evp.h +++ b/wolfssl/openssl/evp.h @@ -351,7 +351,7 @@ enum { NID_kx_srp = 1044, NID_kx_gost = 1045, NID_kx_any = 1063, - + /* server authentication */ NID_auth_rsa = 1046, NID_auth_ecdsa = 1047, @@ -360,7 +360,7 @@ enum { NID_auth_srp = 1052, NID_auth_null = 1054, NID_auth_any = 1055 - + }; #define NID_X9_62_id_ecPublicKey EVP_PKEY_EC @@ -724,7 +724,7 @@ WOLFSSL_API int wolfSSL_PKCS5_PBKDF2_HMAC(const char *pass, int passlen, !defined(NO_SHA) WOLFSSL_API int wolfSSL_EVP_PBE_scrypt(const char *pass, size_t passlen, const unsigned char *salt, size_t saltlen, - word64 N, word64 r, word64 p, + word64 N, word64 r, word64 p, word64 maxmem, unsigned char *key, size_t keylen); #endif /* HAVE_SCRYPT && HAVE_PBKDF2 && !NO_PWDBASED && !NO_SHA */ @@ -734,7 +734,7 @@ WOLFSSL_LOCAL int wolfSSL_EVP_get_hashinfo(const WOLFSSL_EVP_MD* evp, WOLFSSL_API void wolfSSL_EVP_MD_do_all(void (*fn) (const WOLFSSL_EVP_MD *md, const char* from, const char* to, void* xx), void* args); - + #define EVP_CIPH_STREAM_CIPHER WOLFSSL_EVP_CIPH_STREAM_CIPHER #define EVP_CIPH_ECB_MODE WOLFSSL_EVP_CIPH_ECB_MODE #define EVP_CIPH_CBC_MODE WOLFSSL_EVP_CIPH_CBC_MODE diff --git a/wolfssl/openssl/opensslv.h b/wolfssl/openssl/opensslv.h index 9ae42413d..38ef42ef9 100644 --- a/wolfssl/openssl/opensslv.h +++ b/wolfssl/openssl/opensslv.h @@ -28,7 +28,7 @@ /* api version compatibility */ #if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x0090810fL) ||\ defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x10100000L) ||\ - defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x10001040L) + defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x10001040L) /* valid version */ #elif defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIBEST) || \ defined(WOLFSSL_BIND) || defined(WOLFSSL_NGINX) || \ diff --git a/wolfssl/openssl/pem.h b/wolfssl/openssl/pem.h index 6cc8990c7..4a585c8ca 100644 --- a/wolfssl/openssl/pem.h +++ b/wolfssl/openssl/pem.h @@ -259,7 +259,7 @@ int wolfSSL_PEM_write_DHparams(XFILE fp, WOLFSSL_DH* dh); #define PEM_write_bio_PUBKEY wolfSSL_PEM_write_bio_PUBKEY #ifdef __cplusplus - } /* extern "C" */ + } /* extern "C" */ #endif #endif /* WOLFSSL_PEM_H_ */ diff --git a/wolfssl/openssl/ripemd.h b/wolfssl/openssl/ripemd.h index f7dea2879..5af54e51b 100644 --- a/wolfssl/openssl/ripemd.h +++ b/wolfssl/openssl/ripemd.h @@ -50,7 +50,7 @@ typedef WOLFSSL_RIPEMD_CTX RIPEMD_CTX; #ifdef __cplusplus - } /* extern "C" */ + } /* extern "C" */ #endif diff --git a/wolfssl/openssl/rsa.h b/wolfssl/openssl/rsa.h index b8c3d1af8..35afd617a 100644 --- a/wolfssl/openssl/rsa.h +++ b/wolfssl/openssl/rsa.h @@ -111,9 +111,9 @@ WOLFSSL_API int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA*, int bits, WOLFSSL_BIGN WOLFSSL_API int wolfSSL_RSA_blinding_on(WOLFSSL_RSA*, WOLFSSL_BN_CTX*); WOLFSSL_API int wolfSSL_RSA_check_key(const WOLFSSL_RSA*); WOLFSSL_API int wolfSSL_RSA_public_encrypt(int len, const unsigned char* fr, - unsigned char* to, WOLFSSL_RSA*, int padding); + unsigned char* to, WOLFSSL_RSA*, int padding); WOLFSSL_API int wolfSSL_RSA_private_decrypt(int len, const unsigned char* fr, - unsigned char* to, WOLFSSL_RSA*, int padding); + unsigned char* to, WOLFSSL_RSA*, int padding); WOLFSSL_API int wolfSSL_RSA_private_encrypt(int len, const unsigned char* in, unsigned char* out, WOLFSSL_RSA* rsa, int padding); diff --git a/wolfssl/openssl/sha.h b/wolfssl/openssl/sha.h index cd46e43ff..bafafe89b 100644 --- a/wolfssl/openssl/sha.h +++ b/wolfssl/openssl/sha.h @@ -52,13 +52,13 @@ typedef struct WOLFSSL_SHA_CTX { WOLFSSL_API int wolfSSL_SHA_Init(WOLFSSL_SHA_CTX*); WOLFSSL_API int wolfSSL_SHA_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA_Final(unsigned char*, WOLFSSL_SHA_CTX*); -WOLFSSL_API int wolfSSL_SHA_Transform(WOLFSSL_SHA_CTX*, +WOLFSSL_API int wolfSSL_SHA_Transform(WOLFSSL_SHA_CTX*, const unsigned char *data); /* SHA1 points to above, shouldn't use SHA0 ever */ WOLFSSL_API int wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX*); WOLFSSL_API int wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA1_Final(unsigned char*, WOLFSSL_SHA_CTX*); -WOLFSSL_API int wolfSSL_SHA1_Transform(WOLFSSL_SHA_CTX*, +WOLFSSL_API int wolfSSL_SHA1_Transform(WOLFSSL_SHA_CTX*, const unsigned char *data); enum { SHA_DIGEST_LENGTH = 20 @@ -75,7 +75,7 @@ typedef WOLFSSL_SHA_CTX SHA_CTX; #if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_SELFTEST) && \ (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION > 2)) - /* SHA is only available in non-fips mode or fips version > 2 mode + /* SHA is only available in non-fips mode or fips version > 2 mode * because of SHA enum in FIPS build. */ #define SHA wolfSSL_SHA1 #endif @@ -97,7 +97,7 @@ typedef struct WOLFSSL_SHA224_CTX { WOLFSSL_API int wolfSSL_SHA224_Init(WOLFSSL_SHA224_CTX*); WOLFSSL_API int wolfSSL_SHA224_Update(WOLFSSL_SHA224_CTX*, const void*, - unsigned long); + unsigned long); WOLFSSL_API int wolfSSL_SHA224_Final(unsigned char*, WOLFSSL_SHA224_CTX*); enum { @@ -113,7 +113,7 @@ typedef WOLFSSL_SHA224_CTX SHA224_CTX; #if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_SELFTEST) && \ (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION > 2)) - /* SHA224 is only available in non-fips mode or fips version > 2 mode + /* SHA224 is only available in non-fips mode or fips version > 2 mode * because of SHA224 enum in FIPS build. */ #define SHA224 wolfSSL_SHA224 #endif @@ -133,7 +133,7 @@ WOLFSSL_API int wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX*); WOLFSSL_API int wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA256_Final(unsigned char*, WOLFSSL_SHA256_CTX*); -WOLFSSL_API int wolfSSL_SHA256_Transform(WOLFSSL_SHA256_CTX*, +WOLFSSL_API int wolfSSL_SHA256_Transform(WOLFSSL_SHA256_CTX*, const unsigned char *data); enum { SHA256_DIGEST_LENGTH = 32 @@ -174,7 +174,7 @@ typedef struct WOLFSSL_SHA384_CTX { WOLFSSL_API int wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX*); WOLFSSL_API int wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX*, const void*, - unsigned long); + unsigned long); WOLFSSL_API int wolfSSL_SHA384_Final(unsigned char*, WOLFSSL_SHA384_CTX*); enum { @@ -205,7 +205,7 @@ WOLFSSL_API int wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX*); WOLFSSL_API int wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA512_Final(unsigned char*, WOLFSSL_SHA512_CTX*); -WOLFSSL_API int wolfSSL_SHA512_Transform(WOLFSSL_SHA512_CTX*, +WOLFSSL_API int wolfSSL_SHA512_Transform(WOLFSSL_SHA512_CTX*, const unsigned char*); enum { SHA512_DIGEST_LENGTH = 64 @@ -232,7 +232,7 @@ WOLFSSL_API int wolfSSL_SHA512_224_Init(WOLFSSL_SHA512_CTX*); WOLFSSL_API int wolfSSL_SHA512_224_Update(WOLFSSL_SHA512_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA512_224_Final(unsigned char*, WOLFSSL_SHA512_CTX*); -WOLFSSL_API int wolfSSL_SHA512_224_Transform(WOLFSSL_SHA512_CTX*, +WOLFSSL_API int wolfSSL_SHA512_224_Transform(WOLFSSL_SHA512_CTX*, const unsigned char*); @@ -254,7 +254,7 @@ WOLFSSL_API int wolfSSL_SHA512_256_Init(WOLFSSL_SHA512_CTX*); WOLFSSL_API int wolfSSL_SHA512_256_Update(WOLFSSL_SHA512_CTX*, const void*, unsigned long); WOLFSSL_API int wolfSSL_SHA512_256_Final(unsigned char*, WOLFSSL_SHA512_CTX*); -WOLFSSL_API int wolfSSL_SHA512_256_Transform(WOLFSSL_SHA512_CTX*, +WOLFSSL_API int wolfSSL_SHA512_256_Transform(WOLFSSL_SHA512_CTX*, const unsigned char*); #define SHA512_256_Init wolfSSL_SHA512_256_Init diff --git a/wolfssl/openssl/sha3.h b/wolfssl/openssl/sha3.h index 1887382e9..4a8050100 100644 --- a/wolfssl/openssl/sha3.h +++ b/wolfssl/openssl/sha3.h @@ -96,7 +96,7 @@ typedef struct WOLFSSL_SHA3_CTX WOLFSSL_SHA3_384_CTX; WOLFSSL_API int wolfSSL_SHA3_384_Init(WOLFSSL_SHA3_384_CTX*); WOLFSSL_API int wolfSSL_SHA3_384_Update(WOLFSSL_SHA3_384_CTX*, const void*, - unsigned long); + unsigned long); WOLFSSL_API int wolfSSL_SHA3_384_Final(unsigned char*, WOLFSSL_SHA3_384_CTX*); enum { @@ -119,7 +119,7 @@ typedef struct WOLFSSL_SHA3_CTX WOLFSSL_SHA3_512_CTX; WOLFSSL_API int wolfSSL_SHA3_512_Init(WOLFSSL_SHA3_512_CTX*); WOLFSSL_API int wolfSSL_SHA3_512_Update(WOLFSSL_SHA3_512_CTX*, const void*, - unsigned long); + unsigned long); WOLFSSL_API int wolfSSL_SHA3_512_Final(unsigned char*, WOLFSSL_SHA3_512_CTX*); enum { diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index 114e8a7fb..9941c433a 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -1465,7 +1465,7 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_ #define SSL_OP_SINGLE_ECDH_USE WOLFSSL_OP_SINGLE_ECDH_USE #define SSL_OP_CIPHER_SERVER_PREFERENCE WOLFSSL_OP_CIPHER_SERVER_PREFERENCE -#define OPENSSL_config wolfSSL_OPENSSL_config +#define OPENSSL_config wolfSSL_OPENSSL_config #define OPENSSL_memdup wolfSSL_OPENSSL_memdup #define OPENSSL_cleanse wolfSSL_OPENSSL_cleanse #define SSL_CTX_get_timeout wolfSSL_SSL_CTX_get_timeout diff --git a/wolfssl/sniffer.h b/wolfssl/sniffer.h index 6ba569faf..95503a6bf 100644 --- a/wolfssl/sniffer.h +++ b/wolfssl/sniffer.h @@ -52,8 +52,8 @@ SSL_SNIFFER_API int ssl_SetPrivateKey(const char* address, int port, WOLFSSL_API SSL_SNIFFER_API int ssl_SetPrivateKeyBuffer(const char* address, int port, - const char* keyBuf, int keySz, - int typeK, const char* password, + const char* keyBuf, int keySz, + int typeK, const char* password, char* error); @@ -66,31 +66,31 @@ SSL_SNIFFER_API int ssl_SetNamedPrivateKey(const char* name, WOLFSSL_API SSL_SNIFFER_API int ssl_SetNamedPrivateKeyBuffer(const char* name, const char* address, int port, - const char* keyBuf, int keySz, - int typeK, const char* password, + const char* keyBuf, int keySz, + int typeK, const char* password, char* error); -WOLFSSL_API -SSL_SNIFFER_API int ssl_SetEphemeralKey(const char* address, int port, - const char* keyFile, int typeKey, +WOLFSSL_API +SSL_SNIFFER_API int ssl_SetEphemeralKey(const char* address, int port, + const char* keyFile, int typeKey, const char* password, char* error); -WOLFSSL_API -SSL_SNIFFER_API int ssl_SetEphemeralKeyBuffer(const char* address, int port, - const char* keyBuf, int keySz, int typeKey, +WOLFSSL_API +SSL_SNIFFER_API int ssl_SetEphemeralKeyBuffer(const char* address, int port, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error); -WOLFSSL_API +WOLFSSL_API SSL_SNIFFER_API int ssl_SetNamedEphemeralKey(const char* name, const char* address, int port, const char* keyFile, int typeKey, const char* password, char* error); -WOLFSSL_API +WOLFSSL_API SSL_SNIFFER_API int ssl_SetNamedEphemeralKeyBuffer(const char* name, const char* address, int port, - const char* keyBuf, int keySz, int typeKey, + const char* keyBuf, int keySz, int typeKey, const char* password, char* error); WOLFSSL_API @@ -206,7 +206,7 @@ typedef int (*SSLKeyCb)(void* vSniffer, int namedGroup, const unsigned char* cliPub, unsigned int cliPubSz, DerBuffer* privKey, void* cbCtx, char* error); -WOLFSSL_API +WOLFSSL_API SSL_SNIFFER_API int ssl_SetKeyCallback(SSLKeyCb cb, void* cbCtx); #endif diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index cd99c5252..7a1cd35c6 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -770,7 +770,7 @@ enum SNICbReturn { /* WS_RETURN_CODE macro * Some OpenSSL APIs specify "0" as the return value when an error occurs. - * However, some corresponding wolfSSL APIs return negative values. Such + * However, some corresponding wolfSSL APIs return negative values. Such * functions should use this macro to fill this gap. Users who want them * to return the same return value as OpenSSL can define * WOLFSSL_ERR_CODE_OPENSSL. @@ -1365,7 +1365,7 @@ WOLFSSL_API void wolfSSL_sk_GENERAL_NAME_pop_free(WOLFSSL_STACK* sk, void (*f) (WOLFSSL_GENERAL_NAME*)); WOLFSSL_API void wolfSSL_sk_GENERAL_NAME_free(WOLFSSL_STACK* sk); WOLFSSL_API void wolfSSL_GENERAL_NAMES_free(WOLFSSL_GENERAL_NAMES* name); -WOLFSSL_API int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out, +WOLFSSL_API int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out, WOLFSSL_GENERAL_NAME* name); WOLFSSL_API WOLFSSL_DIST_POINT* wolfSSL_DIST_POINT_new(void); @@ -1431,7 +1431,7 @@ WOLFSSL_API int wolfSSL_SESSION_up_ref(WOLFSSL_SESSION* session); WOLFSSL_API WOLFSSL_SESSION* wolfSSL_SESSION_dup(WOLFSSL_SESSION* session); WOLFSSL_API WOLFSSL_SESSION* wolfSSL_SESSION_new(void); WOLFSSL_API void wolfSSL_SESSION_free(WOLFSSL_SESSION* session); -WOLFSSL_API int wolfSSL_SESSION_set_cipher(WOLFSSL_SESSION* session, +WOLFSSL_API int wolfSSL_SESSION_set_cipher(WOLFSSL_SESSION* session, const WOLFSSL_CIPHER* cipher); WOLFSSL_API int wolfSSL_is_init_finished(WOLFSSL*); @@ -1624,7 +1624,7 @@ WOLFSSL_API void wolfSSL_X509_STORE_set_verify_cb(WOLFSSL_X509_STORE *st, WOLFSSL_X509_STORE_CTX_verify_cb verify_cb); WOLFSSL_API int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* n, unsigned char** out); -WOLFSSL_API int wolfSSL_i2d_X509_NAME_canon(WOLFSSL_X509_NAME* name, +WOLFSSL_API int wolfSSL_i2d_X509_NAME_canon(WOLFSSL_X509_NAME* name, unsigned char** out); WOLFSSL_API WOLFSSL_X509_NAME *wolfSSL_d2i_X509_NAME(WOLFSSL_X509_NAME **name, unsigned char **in, long length); @@ -1715,7 +1715,7 @@ WOLFSSL_API unsigned char* wolfSSL_ASN1_STRING_data(WOLFSSL_ASN1_STRING*); WOLFSSL_API const unsigned char* wolfSSL_ASN1_STRING_get0_data( const WOLFSSL_ASN1_STRING*); WOLFSSL_API int wolfSSL_ASN1_STRING_length(WOLFSSL_ASN1_STRING*); -WOLFSSL_API int wolfSSL_ASN1_STRING_copy(WOLFSSL_ASN1_STRING* dst, +WOLFSSL_API int wolfSSL_ASN1_STRING_copy(WOLFSSL_ASN1_STRING* dst, const WOLFSSL_ASN1_STRING* src); WOLFSSL_API int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX*); WOLFSSL_API const char* wolfSSL_X509_verify_cert_error_string(long); @@ -1825,7 +1825,7 @@ WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1_ip( WOLFSSL_X509_VERIFY_PARAM* param, const unsigned char* ip, size_t iplen); WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1(WOLFSSL_X509_VERIFY_PARAM* to, const WOLFSSL_X509_VERIFY_PARAM* from); -WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx, +WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx, const char *file, int type); WOLFSSL_API int wolfSSL_X509_load_cert_crl_file(WOLFSSL_X509_LOOKUP *ctx, const char *file, int type); @@ -2359,10 +2359,10 @@ enum { /* ssl Constants */ WOLFSSL_API void wolfSSL_set_psk_client_callback(WOLFSSL*, wc_psk_client_callback); #ifdef OPENSSL_EXTRA - typedef int (*wc_psk_use_session_cb_func)(WOLFSSL* ssl, + typedef int (*wc_psk_use_session_cb_func)(WOLFSSL* ssl, const WOLFSSL_EVP_MD* md, const unsigned char **id, size_t* idlen, WOLFSSL_SESSION **sess); - WOLFSSL_API void wolfSSL_set_psk_use_session_callback(WOLFSSL* ssl, + WOLFSSL_API void wolfSSL_set_psk_use_session_callback(WOLFSSL* ssl, wc_psk_use_session_cb_func cb); #endif #ifdef WOLFSSL_TLS13 @@ -2636,7 +2636,7 @@ WOLFSSL_API WOLFSSL_X509* WOLFSSL_API int wolfSSL_i2d_X509(WOLFSSL_X509* x509, unsigned char** out); WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL(WOLFSSL_X509_CRL **crl, const unsigned char *in, int len); -WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_bio(WOLFSSL_BIO *bp, +WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_bio(WOLFSSL_BIO *bp, WOLFSSL_X509_CRL **crl); #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_fp(XFILE file, WOLFSSL_X509_CRL **crl); @@ -3583,7 +3583,7 @@ enum { * algorithms have LEVEL2 and LEVEL4 because none of these submissions * included them. */ - WOLFSSL_OQS_MIN = 532, + WOLFSSL_OQS_MIN = 532, WOLFSSL_OQS_SIMPLE_MIN = 532, WOLFSSL_NTRU_HPS_LEVEL1 = 532, /* NTRU_HPS2048509 */ WOLFSSL_NTRU_HPS_LEVEL3 = 533, /* NTRU_HPS2048677 */ @@ -3859,7 +3859,7 @@ WOLFSSL_LOCAL int NIDToEccEnum(int n); #define WOLFSSL_OBJ_NAME_TYPE_NUM 0x05 #define WOLFSSL_OBJ_NAME_ALIAS 0x8000 -WOLFSSL_API void wolfSSL_OBJ_NAME_do_all(int type, +WOLFSSL_API void wolfSSL_OBJ_NAME_do_all(int type, void (*fn) (const WOLFSSL_OBJ_NAME* , void *arg), void* arg); /* end of object functions */ @@ -4716,9 +4716,9 @@ WOLFSSL_API int wolfSSL_set_ephemeral_key(WOLFSSL* ssl, int keyAlgo, const char* key, unsigned int keySz, int format); /* returns pointer to loaded key as ASN.1/DER */ -WOLFSSL_API int wolfSSL_CTX_get_ephemeral_key(WOLFSSL_CTX* ctx, int keyAlgo, +WOLFSSL_API int wolfSSL_CTX_get_ephemeral_key(WOLFSSL_CTX* ctx, int keyAlgo, const unsigned char** key, unsigned int* keySz); -WOLFSSL_API int wolfSSL_get_ephemeral_key(WOLFSSL* ssl, int keyAlgo, +WOLFSSL_API int wolfSSL_get_ephemeral_key(WOLFSSL* ssl, int keyAlgo, const unsigned char** key, unsigned int* keySz); #endif diff --git a/wolfssl/test.h b/wolfssl/test.h index 8302ddb84..3b726afbb 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -2255,7 +2255,7 @@ static WC_INLINE unsigned int my_psk_server_tls13_cb(WOLFSSL* ssl, !defined(NO_FILESYSTEM) static unsigned char local_psk[32]; #endif -static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, +static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, const WOLFSSL_EVP_MD* md, const unsigned char **id, size_t* idlen, WOLFSSL_SESSION **sess) { @@ -2271,9 +2271,9 @@ static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, int numCiphers = 0; (void)ssl; (void)md; - + printf("use psk session callback \n"); - + lsess = wolfSSL_SESSION_new(); if (lsess == NULL) { return 0; @@ -2282,16 +2282,16 @@ static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, numCiphers = sk_num(supportedCiphers); for (i = 0; i < numCiphers; ++i) { - + if ((cipher = (const WOLFSSL_CIPHER*)sk_value(supportedCiphers, i))) { SSL_CIPHER_description(cipher, buf, sizeof(buf)); } - + if (XMEMCMP(cipher_id, buf, XSTRLEN(cipher_id)) == 0) { break; } } - + if (i != numCiphers) { SSL_SESSION_set_cipher(lsess, cipher); for (i = 0; i < 32; i++, b += 0x22) { @@ -2299,11 +2299,11 @@ static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, b = 0x01; local_psk[i] = b; } - + *id = local_psk; *idlen = 32; *sess = lsess; - + return 1; } else { @@ -2318,7 +2318,7 @@ static WC_INLINE int my_psk_use_session_cb(WOLFSSL* ssl, (void)id; (void)idlen; (void)sess; - + return 0; #endif } @@ -2706,7 +2706,7 @@ static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store) return 0; /* test failure case */ } - if (myVerifyAction == VERIFY_OVERRIDE_DATE_ERR && + if (myVerifyAction == VERIFY_OVERRIDE_DATE_ERR && (store->error == ASN_BEFORE_DATE_E || store->error == ASN_AFTER_DATE_E)) { printf("Overriding cert date error as example for bad clock testing\n"); return 1; @@ -4901,7 +4901,7 @@ static WC_INLINE const char* mymktemp(char *tempfn, int len, int num) } wc_AesFree(&aes); #endif - + if (ret != 0) return WOLFSSL_TICKET_RET_REJECT; *outLen = inLen; /* no padding in this mode */ } @@ -4975,9 +4975,9 @@ static WC_INLINE void EarlyDataStatus(WOLFSSL* ssl) earlyData_status = wolfSSL_get_early_data_status(ssl); #endif if (earlyData_status < 0) return; - + printf("Early Data was "); - + switch(earlyData_status) { case WOLFSSL_EARLY_DATA_NOT_SENT: printf("not sent.\n"); diff --git a/wolfssl/wolfcrypt/arc4.h b/wolfssl/wolfcrypt/arc4.h index 2d21f5ced..3b02ad6bb 100644 --- a/wolfssl/wolfcrypt/arc4.h +++ b/wolfssl/wolfcrypt/arc4.h @@ -37,9 +37,9 @@ #endif enum { - ARC4_ENC_TYPE = 4, /* cipher unique type */ + ARC4_ENC_TYPE = 4, /* cipher unique type */ ARC4_STATE_SIZE = 256, - RC4_KEY_SIZE = 16, /* always 128bit */ + RC4_KEY_SIZE = 16, /* always 128bit */ }; /* ARC4 encryption and decryption */ diff --git a/wolfssl/wolfcrypt/chacha.h b/wolfssl/wolfcrypt/chacha.h index 0d84c5b42..25e8bfabf 100644 --- a/wolfssl/wolfcrypt/chacha.h +++ b/wolfssl/wolfcrypt/chacha.h @@ -71,7 +71,7 @@ Block counter is located at index 12. #endif enum { - CHACHA_ENC_TYPE = WC_CIPHER_CHACHA, /* cipher unique type */ + CHACHA_ENC_TYPE = WC_CIPHER_CHACHA, /* cipher unique type */ CHACHA_MAX_KEY_SZ = 32, }; @@ -102,8 +102,8 @@ WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz); #ifdef HAVE_XCHACHA WOLFSSL_API int wc_XChacha_SetKey(ChaCha *ctx, const byte *key, word32 keySz, - const byte *nonce, word32 nonceSz, - word32 counter); + const byte *nonce, word32 nonceSz, + word32 counter); #endif #ifdef __cplusplus diff --git a/wolfssl/wolfcrypt/ecc.h b/wolfssl/wolfcrypt/ecc.h index ac2c7636b..fa97b11fc 100644 --- a/wolfssl/wolfcrypt/ecc.h +++ b/wolfssl/wolfcrypt/ecc.h @@ -329,12 +329,12 @@ typedef struct ecc_set_type { * mp_ints for the components of the point. With ALT_ECC_SIZE, the components * of the point are pointers that are set to each of a three item array of * alt_fp_ints. While an mp_int will have 4096 bits of digit inside the - * structure, the alt_fp_int will only have 512 bits for ECC 256-bit and - * 1056-bits for ECC 521-bit. A size value was added in the ALT case, as well, - * and is set by mp_init() and alt_fp_init(). The functions fp_zero() and - * fp_copy() use the size parameter. An int needs to be initialized before - * using it instead of just fp_zeroing it, the init will call zero. The - * FP_MAX_BITS_ECC defaults to calculating based on MAX_ECC_BITS, but + * structure, the alt_fp_int will only have 512 bits for ECC 256-bit and + * 1056-bits for ECC 521-bit. A size value was added in the ALT case, as well, + * and is set by mp_init() and alt_fp_init(). The functions fp_zero() and + * fp_copy() use the size parameter. An int needs to be initialized before + * using it instead of just fp_zeroing it, the init will call zero. The + * FP_MAX_BITS_ECC defaults to calculating based on MAX_ECC_BITS, but * can be set to change the number of bits used in the alternate FP_INT. * * The ALT_ECC_SIZE option only applies to stack based fast math USE_FAST_MATH. diff --git a/wolfssl/wolfcrypt/error-crypt.h b/wolfssl/wolfcrypt/error-crypt.h index 134ba080e..c22989b86 100644 --- a/wolfssl/wolfcrypt/error-crypt.h +++ b/wolfssl/wolfcrypt/error-crypt.h @@ -35,7 +35,7 @@ the error status. #if defined(HAVE_FIPS) && \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) - #include + #include #endif /* HAVE_FIPS V1 */ #ifdef __cplusplus diff --git a/wolfssl/wolfcrypt/fe_operations.h b/wolfssl/wolfcrypt/fe_operations.h index 03d3afa3a..5b10d8110 100644 --- a/wolfssl/wolfcrypt/fe_operations.h +++ b/wolfssl/wolfcrypt/fe_operations.h @@ -164,7 +164,7 @@ WOLFSSL_LOCAL void fe_inv__distinct(byte *r, const byte *x); * undefined behavior. */ WOLFSSL_LOCAL void fe_select(byte *dst, const byte *zero, const byte *one, - byte condition); + byte condition); /* Multiply a point by a small constant. The two pointers are not * required to be distinct. @@ -188,11 +188,11 @@ WOLFSSL_LOCAL void fe_sqrt(byte *r, const byte *x); * undefined behavior. */ WOLFSSL_LOCAL void fprime_select(byte *dst, const byte *zero, const byte *one, - byte condition); + byte condition); WOLFSSL_LOCAL void fprime_add(byte *r, const byte *a, const byte *modulus); WOLFSSL_LOCAL void fprime_sub(byte *r, const byte *a, const byte *modulus); WOLFSSL_LOCAL void fprime_mul(byte *r, const byte *a, const byte *b, - const byte *modulus); + const byte *modulus); WOLFSSL_LOCAL void fprime_copy(byte *x, const byte *a); #endif /* CURVE25519_SMALL || ED25519_SMALL */ diff --git a/wolfssl/wolfcrypt/hc128.h b/wolfssl/wolfcrypt/hc128.h index 2b93a2407..910d18e74 100644 --- a/wolfssl/wolfcrypt/hc128.h +++ b/wolfssl/wolfcrypt/hc128.h @@ -36,7 +36,7 @@ #endif enum { - HC128_ENC_TYPE = WC_CIPHER_HC128, /* cipher unique type */ + HC128_ENC_TYPE = WC_CIPHER_HC128, /* cipher unique type */ }; /* HC-128 stream cipher */ diff --git a/wolfssl/wolfcrypt/hmac.h b/wolfssl/wolfcrypt/hmac.h index 21d77cff6..a51a17d2f 100644 --- a/wolfssl/wolfcrypt/hmac.h +++ b/wolfssl/wolfcrypt/hmac.h @@ -31,7 +31,7 @@ #include #if defined(HAVE_FIPS) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) /* for fips @wc_fips */ #include #define WC_HMAC_BLOCK_SIZE HMAC_BLOCK_SIZE @@ -39,8 +39,8 @@ #if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) - #include + defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) + #include #endif #ifdef __cplusplus diff --git a/wolfssl/wolfcrypt/mem_track.h b/wolfssl/wolfcrypt/mem_track.h index e76d72083..67dcd0f3b 100644 --- a/wolfssl/wolfcrypt/mem_track.h +++ b/wolfssl/wolfcrypt/mem_track.h @@ -131,15 +131,15 @@ /* if defined to not using inline then declare function prototypes */ #ifdef NO_INLINE #define WC_STATIC - #ifdef WOLFSSL_DEBUG_MEMORY - WOLFSSL_LOCAL void* TrackMalloc(size_t sz, const char* func, unsigned int line); - WOLFSSL_LOCAL void TrackFree(void* ptr, const char* func, unsigned int line); - WOLFSSL_LOCAL void* TrackRealloc(void* ptr, size_t sz, const char* func, unsigned int line); - #else - WOLFSSL_LOCAL void* TrackMalloc(size_t sz); - WOLFSSL_LOCAL void TrackFree(void* ptr); - WOLFSSL_LOCAL void* TrackRealloc(void* ptr, size_t sz); - #endif + #ifdef WOLFSSL_DEBUG_MEMORY + WOLFSSL_LOCAL void* TrackMalloc(size_t sz, const char* func, unsigned int line); + WOLFSSL_LOCAL void TrackFree(void* ptr, const char* func, unsigned int line); + WOLFSSL_LOCAL void* TrackRealloc(void* ptr, size_t sz, const char* func, unsigned int line); + #else + WOLFSSL_LOCAL void* TrackMalloc(size_t sz); + WOLFSSL_LOCAL void TrackFree(void* ptr); + WOLFSSL_LOCAL void* TrackRealloc(void* ptr, size_t sz); + #endif WOLFSSL_LOCAL int InitMemoryTracker(void); WOLFSSL_LOCAL void ShowMemoryTracker(void); #else @@ -238,7 +238,7 @@ sz = header->thisSize; #ifdef DO_MEM_LIST - if (pthread_mutex_lock(&memLock) == 0) + if (pthread_mutex_lock(&memLock) == 0) { #endif diff --git a/wolfssl/wolfcrypt/pkcs11.h b/wolfssl/wolfcrypt/pkcs11.h index a3e9cf003..5dd130939 100644 --- a/wolfssl/wolfcrypt/pkcs11.h +++ b/wolfssl/wolfcrypt/pkcs11.h @@ -368,7 +368,7 @@ struct CK_FUNCTION_LIST { CK_MECHANISM_INFO_PTR pInfo); CK_RV (*C_InitToken)(CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen, CK_UTF8CHAR_PTR pLabel); - CK_RV (*C_InitPIN)(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pPin, + CK_RV (*C_InitPIN)(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen); CK_RV (*C_SetPIN)(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pOldPin, CK_ULONG ulOldLen, CK_UTF8CHAR_PTR pNewPin, diff --git a/wolfssl/wolfcrypt/poly1305.h b/wolfssl/wolfcrypt/poly1305.h index a0e0b3abf..a272c2a41 100644 --- a/wolfssl/wolfcrypt/poly1305.h +++ b/wolfssl/wolfcrypt/poly1305.h @@ -84,8 +84,8 @@ typedef struct Poly1305 { #else #if defined(WOLFSSL_ARMASM) && defined(__aarch64__) ALIGN128 word32 r[5]; - ALIGN128 word32 r_2[5]; // r^2 - ALIGN128 word32 r_4[5]; // r^4 + ALIGN128 word32 r_2[5]; /* r^2 */ + ALIGN128 word32 r_4[5]; /* r^4 */ ALIGN128 word32 h[5]; word32 pad[4]; word64 leftover; diff --git a/wolfssl/wolfcrypt/pwdbased.h b/wolfssl/wolfcrypt/pwdbased.h index e142adb98..ff52ea091 100644 --- a/wolfssl/wolfcrypt/pwdbased.h +++ b/wolfssl/wolfcrypt/pwdbased.h @@ -40,8 +40,8 @@ * wolfssl/wolfcrypt/asn.h line 173 in enum Oid_Types */ WOLFSSL_API int wc_PBKDF1_ex(byte* key, int keyLen, byte* iv, int ivLen, - const byte* passwd, int passwdLen, - const byte* salt, int saltLen, int iterations, + const byte* passwd, int passwdLen, + const byte* salt, int saltLen, int iterations, int hashType, void* heap); WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt, int sLen, int iterations, int kLen, diff --git a/wolfssl/wolfcrypt/rabbit.h b/wolfssl/wolfcrypt/rabbit.h index 836b73705..2bd4abde5 100644 --- a/wolfssl/wolfcrypt/rabbit.h +++ b/wolfssl/wolfcrypt/rabbit.h @@ -37,7 +37,7 @@ enum { - RABBIT_ENC_TYPE = 5 /* cipher unique type */ + RABBIT_ENC_TYPE = 5 /* cipher unique type */ }; diff --git a/wolfssl/wolfcrypt/rsa.h b/wolfssl/wolfcrypt/rsa.h index d89660bc7..d557c09f7 100644 --- a/wolfssl/wolfcrypt/rsa.h +++ b/wolfssl/wolfcrypt/rsa.h @@ -64,7 +64,7 @@ RSA keys can be used to encrypt, decrypt, sign and verify data. #else #if defined(HAVE_FIPS) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) /* for fips @wc_fips */ #include #if defined(CYASSL_KEY_GEN) && !defined(WOLFSSL_KEY_GEN) @@ -75,7 +75,7 @@ RSA keys can be used to encrypt, decrypt, sign and verify data. #include #endif /* HAVE_FIPS && HAVE_FIPS_VERION 1 */ #if defined(HAVE_FIPS) && \ - defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) + defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) #include #endif @@ -300,7 +300,7 @@ WOLFSSL_API int wc_RsaPSS_VerifyCheck(byte* in, word32 inLen, WOLFSSL_API int wc_RsaEncryptSize(const RsaKey* key); #if !defined(HAVE_FIPS) || \ - (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) + (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) /* to avoid asn duplicate symbols @wc_fips */ WOLFSSL_API int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*, word32); diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index bcd77fdb7..9252f7111 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -1044,7 +1044,7 @@ extern void uITRON4_free(void *p) ; #define XFREE(p, h, type) vPortFree((p)) #endif - //#define USER_TICKS + /* #define USER_TICKS */ /* Allows use of DH with fixed points if uncommented and NO_DH is removed */ /* WOLFSSL_DH_CONST */ #define WOLFSSL_LWIP @@ -1370,8 +1370,8 @@ extern void uITRON4_free(void *p) ; #include "stm32f1xx.h" #endif #endif /* WOLFSSL_STM32_CUBEMX */ -#endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32L4 || - WOLFSSL_STM32L5 || WOLFSSL_STM32F7 || WOLFSSL_STMWB || +#endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32L4 || + WOLFSSL_STM32L5 || WOLFSSL_STM32F7 || WOLFSSL_STMWB || WOLFSSL_STM32H7 || WOLFSSL_STM32G0 */ #ifdef WOLFSSL_DEOS #include @@ -1692,7 +1692,7 @@ extern void uITRON4_free(void *p) ; #undef HAVE_AES_ECB #define HAVE_AES_ECB - //@TODO used for now until plugging in caam aes use with qnx + /* @TODO used for now until plugging in caam aes use with qnx */ #undef WOLFSSL_AES_DIRECT #define WOLFSSL_AES_DIRECT #endif @@ -2541,15 +2541,15 @@ extern void uITRON4_free(void *p) ; #endif /* Note: "--enable-renegotiation-indication" ("HAVE_RENEGOTIATION_INDICATION") - * only sends the secure renegotiation extension, but is not actually supported. - * This was added because some TLS peers required it even if not used, so we call + * only sends the secure renegotiation extension, but is not actually supported. + * This was added because some TLS peers required it even if not used, so we call * this "(FAKE Secure Renegotiation)" */ #endif /* Crypto callbacks should enable hash flag support */ #if defined(WOLF_CRYPTO_CB) && !defined(WOLFSSL_HASH_FLAGS) - /* FIPS v1 and v2 do not support hash flags, so do not allow it with + /* FIPS v1 and v2 do not support hash flags, so do not allow it with * crypto callbacks */ #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS) && \ defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 3) diff --git a/wolfssl/wolfcrypt/sha.h b/wolfssl/wolfcrypt/sha.h index 8338264d2..0456c2d8d 100644 --- a/wolfssl/wolfcrypt/sha.h +++ b/wolfssl/wolfcrypt/sha.h @@ -37,7 +37,7 @@ #endif /* HAVE_FIPS_VERSION >= 2 */ #if defined(HAVE_FIPS) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) #define wc_Sha Sha #define WC_SHA SHA #define WC_SHA_BLOCK_SIZE SHA_BLOCK_SIZE @@ -53,7 +53,7 @@ #endif #ifdef WOLFSSL_IMXRT_DCP - #include "fsl_dcp.h" + #include "fsl_dcp.h" #endif #ifdef __cplusplus diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index 13ddea2da..fed65f126 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -38,7 +38,7 @@ #endif /* HAVE_FIPS_VERSION >= 2 */ #if defined(HAVE_FIPS) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) #define wc_Sha256 Sha256 #define WC_SHA256 SHA256 #define WC_SHA256_BLOCK_SIZE SHA256_BLOCK_SIZE @@ -62,7 +62,7 @@ #endif #ifdef WOLFSSL_IMXRT_DCP - #include "fsl_dcp.h" + #include "fsl_dcp.h" #endif #if defined(WOLFSSL_PSOC6_CRYPTO) diff --git a/wolfssl/wolfcrypt/sha512.h b/wolfssl/wolfcrypt/sha512.h index c5f55e179..5fe2c1455 100644 --- a/wolfssl/wolfcrypt/sha512.h +++ b/wolfssl/wolfcrypt/sha512.h @@ -38,7 +38,7 @@ #endif /* HAVE_FIPS_VERSION >= 2 */ #if defined(HAVE_FIPS) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) #ifdef WOLFSSL_SHA512 #define wc_Sha512 Sha512 #define WC_SHA512 SHA512 @@ -60,7 +60,7 @@ #if defined(WOLFSSL_SHA384) #define CYASSL_SHA384 #endif - /* for fips @wc_fips */ + /* for fips @wc_fips */ #include #endif @@ -239,7 +239,7 @@ WOLFSSL_API int wc_Sha512_224Copy(wc_Sha512* src, wc_Sha512* dst); #endif #if defined(OPENSSL_EXTRA) -WOLFSSL_API int wc_Sha512_224Transform(wc_Sha512* sha, +WOLFSSL_API int wc_Sha512_224Transform(wc_Sha512* sha, const unsigned char* data); #endif #endif /* !WOLFSSL_NOSHA512_224 */ @@ -259,7 +259,7 @@ WOLFSSL_API int wc_Sha512_256Copy(wc_Sha512* src, wc_Sha512* dst); #endif #if defined(OPENSSL_EXTRA) -WOLFSSL_API int wc_Sha512_256Transform(wc_Sha512* sha, +WOLFSSL_API int wc_Sha512_256Transform(wc_Sha512* sha, const unsigned char* data); #endif #endif /* !WOLFSSL_NOSHA512_256 */ diff --git a/wolfssl/wolfcrypt/tfm.h b/wolfssl/wolfcrypt/tfm.h index b128548e2..6ca36ebc5 100644 --- a/wolfssl/wolfcrypt/tfm.h +++ b/wolfssl/wolfcrypt/tfm.h @@ -302,7 +302,7 @@ #define FP_OKAY 0 #define FP_VAL -1 #define FP_MEM -2 -#define FP_NOT_INF -3 +#define FP_NOT_INF -3 #define FP_WOULDBLOCK -4 /* equalities */ diff --git a/wolfssl/wolfcrypt/visibility.h b/wolfssl/wolfcrypt/visibility.h index 46a31a444..69db36370 100644 --- a/wolfssl/wolfcrypt/visibility.h +++ b/wolfssl/wolfcrypt/visibility.h @@ -33,7 +33,7 @@ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) #include #define WOLFSSL_API CYASSL_API - #define WOLFSSL_LOCAL CYASSL_LOCAL + #define WOLFSSL_LOCAL CYASSL_LOCAL #else /* WOLFSSL_API is used for the public API symbols. diff --git a/wolfssl/wolfcrypt/wc_encrypt.h b/wolfssl/wolfcrypt/wc_encrypt.h index 56d921507..86c3afdcb 100644 --- a/wolfssl/wolfcrypt/wc_encrypt.h +++ b/wolfssl/wolfcrypt/wc_encrypt.h @@ -64,7 +64,7 @@ (HAVE_FIPS_VERSION <= 2)) || (defined(HAVE_SELFTEST) && \ (!defined(HAVE_SELFTEST_VERSION) || (HAVE_SELFTEST_VERSION < 2))) /* In FIPS cert 3389 and CAVP selftest v1 build, these enums are - * not in aes.h. Define them here outside the fips boundary. + * not in aes.h. Define them here outside the fips boundary. */ #ifndef GCM_NONCE_MID_SZ /* The usual default nonce size for AES-GCM. */ @@ -113,7 +113,7 @@ WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out, #endif /* WOLFSSL_ENCRYPTED_KEYS */ #ifndef NO_PWDBASED - WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, + WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, byte* salt, int saltSz, int iterations, int id, byte* input, int length, int version, byte* cbcIv, int enc, int shaOid); #endif diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index d3a927674..b9c43f678 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -541,7 +541,9 @@ /* remove this multifariously conflicting macro, picked up from * Linux arch//include/asm/current.h. */ - #undef current + #ifndef WOLFSSL_NEED_LINUX_CURRENT + #undef current + #endif /* prevent gcc's mm_malloc.h from being included, since it unconditionally * includes stdlib.h, which is kernel-incompatible. @@ -741,7 +743,7 @@ #elif defined(FREERTOS_TCP) #include "FreeRTOS.h" #include "semphr.h" - typedef SemaphoreHandle_t wolfSSL_Mutex; + typedef SemaphoreHandle_t wolfSSL_Mutex; #elif defined (RTTHREAD) #include "rtthread.h" typedef rt_mutex_t wolfSSL_Mutex; @@ -1053,7 +1055,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define opendir FCL_OPENDIR #define closedir FCL_CLOSEDIR #define readdir FCL_READDIR - #define dirent fclDirent + #define dirent fclDirent #define strncasecmp FCL_STRNCASECMP /* FUSION SPECIFIC ERROR CODE */ @@ -1130,7 +1132,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define MAX_PATH 256 #endif - WOLFSSL_LOCAL int wc_FileLoad(const char* fname, unsigned char** buf, + WOLFSSL_LOCAL int wc_FileLoad(const char* fname, unsigned char** buf, size_t* bufLen, void* heap); #if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) && \