From fbfc3ba8c2d674177833f92a7b3d32db8c94ec8e Mon Sep 17 00:00:00 2001 From: Tesfa Mael Date: Fri, 6 Mar 2026 08:47:22 -0800 Subject: [PATCH] Fix formatting --- tests/api/test_ecc.c | 4 +-- wolfcrypt/benchmark/benchmark.c | 6 ++-- wolfcrypt/src/ecc.c | 8 +++-- wolfcrypt/src/port/atmel/atmel.c | 60 ++++++++++++++++++++------------ wolfcrypt/src/rsa.c | 3 +- wolfcrypt/test/test.c | 5 +-- 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/tests/api/test_ecc.c b/tests/api/test_ecc.c index f2d73a7b34..88d1ece7fc 100644 --- a/tests/api/test_ecc.c +++ b/tests/api/test_ecc.c @@ -1423,7 +1423,7 @@ int test_wc_ecc_pointFns(void) #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && \ !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) && \ !defined(WOLFSSL_ATECC608A) && !defined(WOLF_CRYPTO_CB_ONLY_ECC) && \ - !defined(WOLFSSL_MICROCHIP_TA100) + !defined(WOLFSSL_MICROCHIP_TA100) ecc_key key; WC_RNG rng; int ret; @@ -1527,7 +1527,7 @@ int test_wc_ecc_shared_secret_ssh(void) !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) && \ !defined(WOLFSSL_ATECC608A) && !defined(PLUTON_CRYPTO_ECC) && \ !defined(WOLFSSL_CRYPTOCELL) && !defined(WOLF_CRYPTO_CB_ONLY_ECC) && \ - !defined(WOLFSSL_MICROCHIP_TA100) + !defined(WOLFSSL_MICROCHIP_TA100) ecc_key key; ecc_key key2; WC_RNG rng; diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 66bb72fef0..7a3a280066 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -2112,7 +2112,8 @@ static const char* bench_result_words2[][6] = { static volatile int g_threadCount; #endif -#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_CAAM) || defined(WC_USE_DEVID) || \ +#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_CAAM) || \ + defined(WC_USE_DEVID) || \ defined(WOLFSSL_MICROCHIP_TA100) #ifndef NO_HW_BENCH #define BENCH_DEVID @@ -10576,7 +10577,8 @@ exit_rsa_sign: #if !defined(WOLFSSL_RSA_VERIFY_INLINE) && \ !defined(WOLFSSL_RSA_PUBLIC_ONLY) #if defined(WOLFSSL_MICROCHIP_TA100) - ret = wc_RsaSSL_Verify(message, len, enc[i], rsaKeySz/8, rsaKey[i]); + ret = wc_RsaSSL_Verify(message, len, + enc[i], rsaKeySz/8, rsaKey[i]); #else ret = wc_RsaSSL_Verify(enc[i], idx, out[i], rsaKeySz/8, rsaKey[i]); diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 80f4ee85fc..d250720af1 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -5769,7 +5769,8 @@ static int _ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, key->dp->id == ECC_SECP224R1 || key->dp->id == ECC_SECP384R1 || key->dp->id == ECC_SECP256K1 || - key->dp->id == ECC_BRAINPOOLP256R1) { /* supports more than ECC256R1 curve */ + key->dp->id == ECC_BRAINPOOLP256R1) { + /* supports more than ECC256R1 curve */ #else if (key->dp->id == ECC_SECP256R1 || key->dp->id == ECC_SECP224R1 || @@ -9018,7 +9019,8 @@ static int ecc_verify_hash_sp(mp_int *r, mp_int *s, const byte* hash, return NOT_COMPILED_IN; } -#if !defined(WOLFSSL_MICROCHIP) && (!defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)) +#if !defined(WOLFSSL_MICROCHIP) && \ + (!defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)) static int ecc_verify_hash(mp_int *r, mp_int *s, const byte* hash, word32 hashlen, int* res, ecc_key* key, ecc_curve_spec* curve) { @@ -10703,7 +10705,7 @@ int wc_ecc_get_generator(ecc_point* ecp, int curve_idx) static int _ecc_validate_public_key(ecc_key* key, int partial, int priv) { int err = MP_OKAY; -#if defined(HAVE_ECC_CHECK_PUBKEY_ORDER) && !defined(WOLFSSL_SP_MATH) +#if defined(HAVE_ECC_CHECK_PUBKEY_ORDER) && !defined(WOLFSSL_SP_MATH) mp_int* b = NULL; DECLARE_CURVE_SPECS(4); #endif diff --git a/wolfcrypt/src/port/atmel/atmel.c b/wolfcrypt/src/port/atmel/atmel.c index 84f391c7c9..7565b3b2ae 100644 --- a/wolfcrypt/src/port/atmel/atmel.c +++ b/wolfcrypt/src/port/atmel/atmel.c @@ -177,12 +177,14 @@ static ATCAIfaceCfg* gCfg = &config_atmel_device[WOLFSSL_ATCA_DEVICE_NO]; #endif #endif - /* Helper function to fix property field endianness after talib_handle_init_* - * functions populate the ta_element_attributes_t structure. + /* Helper function to fix property field endianness after + * talib_handle_init_* functions populate the + * ta_element_attributes_t structure. * The talib functions build the property value in host byte order, but * the TA100 device expects little-endian format. */ - static WC_INLINE void ta100_fix_property_endian(ta_element_attributes_t* attr) + static WC_INLINE void ta100_fix_property_endian( + ta_element_attributes_t* attr) { #ifdef BIG_ENDIAN_ORDER if (attr != NULL) { @@ -689,8 +691,10 @@ int atmel_ecc_create_key(int slotId, int curve_id, byte* peerKey) /* generate new ephemeral key on device */ #ifdef WOLFSSL_MICROCHIP_TA100 #if defined(TA100_ECC_TRACE) - printf("[TA100] atmel_ecc_create_key: slot=%d curve_id=%d curve_size=%d curve_type=%d\r\n", - slotId, curve_id, getCurveSizeBytes(curve_id), getCurveType(curve_id)); + printf("[TA100] atmel_ecc_create_key: slot=%d curve_id=%d " + "curve_size=%d curve_type=%d\r\n", + slotId, curve_id, getCurveSizeBytes(curve_id), + getCurveType(curve_id)); #endif { ATCA_STATUS status; @@ -727,7 +731,8 @@ int atmel_ecc_create_key(int slotId, int curve_id, byte* peerKey) status = talib_genkey_base(atcab_get_device(), TA_KEYGEN_MODE_NEWKEY, (uint32_t)MAP_TO_HANDLE(slotId), peerKey, &pubkey_len); #if defined(TA100_ECC_TRACE) - printf("[TA100] atmel_ecc_create_key: genkey status=%d pubkey_len=%u\r\n", + printf("[TA100] atmel_ecc_create_key: " + "genkey status=%d pubkey_len=%u\r\n", status, (unsigned)pubkey_len); #endif return atmel_ecc_translate_err(status); @@ -970,8 +975,8 @@ int wc_Microchip_rsa_decrypt(const byte* in, word32 inLen, byte* out, } -int wc_Microchip_rsa_sign(const byte* in, word32 inLen, byte* out, word32 outLen, - RsaKey* key) +int wc_Microchip_rsa_sign(const byte* in, word32 inLen, + byte* out, word32 outLen, RsaKey* key) { int ret; uint16_t sign_size = (uint16_t)outLen; @@ -1000,7 +1005,8 @@ int wc_Microchip_rsa_sign(const byte* in, word32 inLen, byte* out, word32 outLen } -int wc_Microchip_rsa_verify(const byte* in, word32 inLen, byte* sig, word32 sigLen, +int wc_Microchip_rsa_verify(const byte* in, word32 inLen, + byte* sig, word32 sigLen, RsaKey* key, int* pVerified) { int ret; @@ -1850,9 +1856,11 @@ static int ta100_is_aes_handle(uint16_t handle) } handle_class = info[0] & TA_HANDLE_INFO_CLASS_MASK; - key_type = (info[0] & TA_HANDLE_INFO_KEY_TYPE_MASK) >> TA_HANDLE_INFO_KEY_TYPE_SHIFT; + key_type = (info[0] & TA_HANDLE_INFO_KEY_TYPE_MASK) >> + TA_HANDLE_INFO_KEY_TYPE_SHIFT; - return (handle_class == TA_CLASS_SYMMETRIC_KEY && key_type == TA_KEY_TYPE_AES128); + return (handle_class == TA_CLASS_SYMMETRIC_KEY && + key_type == TA_KEY_TYPE_AES128); } int wc_Microchip_aes_set_key(Aes* aes, const byte* key, word32 keylen, @@ -1878,20 +1886,22 @@ int wc_Microchip_aes_set_key(Aes* aes, const byte* key, word32 keylen, /* Create AES handle if not already created */ if (!ta100_aes_handle_created) { - status = talib_is_handle_valid(atcab_get_device(), (uint32_t)aes->key_id, + status = talib_is_handle_valid(atcab_get_device(), + (uint32_t)aes->key_id, &is_handle_valid); if (status != ATCA_SUCCESS) { return WC_HW_E; } if (is_handle_valid == 0) { - status = talib_handle_init_symmetric_key(&attr, TA_KEY_TYPE_AES128, - TA_PROP_SYMM_KEY_USAGE_ANY); + status = talib_handle_init_symmetric_key(&attr, + TA_KEY_TYPE_AES128, TA_PROP_SYMM_KEY_USAGE_ANY); if (status != ATCA_SUCCESS) { return WC_HW_E; } - (void)talib_handle_set_permissions(&attr, TA_PERM_ALWAYS, TA_PERM_ALWAYS, - TA_PERM_ALWAYS, TA_PERM_ALWAYS); + (void)talib_handle_set_permissions(&attr, + TA_PERM_ALWAYS, TA_PERM_ALWAYS, + TA_PERM_ALWAYS, TA_PERM_ALWAYS); ta100_fix_property_endian(&attr); status = talib_create_element_with_handle(atcab_get_device(), @@ -1907,7 +1917,8 @@ int wc_Microchip_aes_set_key(Aes* aes, const byte* key, word32 keylen, ta100_aes_handle_created = 1; } - status = talib_is_handle_locked(atcab_get_device(), aes->key_id, &is_locked); + status = talib_is_handle_locked(atcab_get_device(), + aes->key_id, &is_locked); if (status == ATCA_SUCCESS && is_locked) { return WC_HW_E; } @@ -1956,7 +1967,8 @@ static int wc_Microchip_AesGcmCommon(Aes* aes, byte* out, const byte* in, if (ivSz != TA_AES_GCM_IV_LENGTH) { return BAD_FUNC_ARG; } - if (authTag == NULL || authTagSz == 0 || authTagSz > TA_AES_GCM_TAG_LENGTH) { + if (authTag == NULL || authTagSz == 0 || + authTagSz > TA_AES_GCM_TAG_LENGTH) { return BAD_FUNC_ARG; } @@ -1964,7 +1976,8 @@ static int wc_Microchip_AesGcmCommon(Aes* aes, byte* out, const byte* in, /* Note: talib API takes non-const iv */ if (authTagSz != TA_AES_GCM_TAG_LENGTH) { status = talib_aes_gcm_encrypt(atcab_get_device(), authIn, - authInSz, (uint8_t*)iv, in, sz, out, tag_buf); + authInSz, (uint8_t*)iv, + in, sz, out, tag_buf); if (status == ATCA_SUCCESS) { copy_sz = authTagSz; XMEMCPY(authTag, tag_buf, copy_sz); @@ -1972,7 +1985,8 @@ static int wc_Microchip_AesGcmCommon(Aes* aes, byte* out, const byte* in, } else { status = talib_aes_gcm_encrypt(atcab_get_device(), authIn, - authInSz, (uint8_t*)iv, in, sz, out, authTag); + authInSz, (uint8_t*)iv, + in, sz, out, authTag); } } else { @@ -1981,7 +1995,8 @@ static int wc_Microchip_AesGcmCommon(Aes* aes, byte* out, const byte* in, return NOT_COMPILED_IN; } status = talib_aes_gcm_encrypt(atcab_get_device(), authIn, - authInSz, (uint8_t*)iv, in, sz, out, tag_buf); + authInSz, (uint8_t*)iv, + in, sz, out, tag_buf); if (status == ATCA_SUCCESS) { copy_sz = authTagSz; if (XMEMCMP(tag_buf, authTag, copy_sz) != 0) { @@ -1991,7 +2006,8 @@ static int wc_Microchip_AesGcmCommon(Aes* aes, byte* out, const byte* in, } else { status = talib_aes_gcm_decrypt(atcab_get_device(), authIn, - authInSz, (uint8_t*)iv, authTag, in, sz, out); + authInSz, (uint8_t*)iv, + authTag, in, sz, out); } } diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 996540dc2b..062e050b2d 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -3844,7 +3844,8 @@ static int RsaPrivateDecryptEx(const byte* in, word32 inLen, byte* out, return WC_HW_E; } int tmp; - return wc_Microchip_rsa_verify(in, inLen, out, outLen, key, &tmp); + return wc_Microchip_rsa_verify(in, inLen, + out, outLen, key, &tmp); } return WC_HW_E; } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index e23fc4c3e1..0016dd9079 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -23115,7 +23115,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #endif /* !NO_RSA */ #if !defined(NO_RSA) || !defined(NO_DSA) - #if defined(WOLFSSL_KEY_GEN) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && !defined(WOLFSSL_MICROCHIP) + #if defined(WOLFSSL_KEY_GEN) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \ + !defined(WOLFSSL_MICROCHIP) static const char* keyDerFile = CERT_WRITE_TEMP_DIR "key.der"; static const char* keyPemFile = CERT_WRITE_TEMP_DIR "key.pem"; #endif @@ -24204,7 +24205,7 @@ static wc_test_ret_t rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG /* RNG is handled by hardware */ if (ret != 0) #elif defined(WOLFSSL_MICROCHIP_TA100) - /* TA100 path doesn't require RNG, but may report BAD_FUNC_ARG on NULL RNG. */ + /* TA100 path doesn't require RNG, may report BAD_FUNC_ARG. */ if (ret != 0 && ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) #else if (ret != WC_NO_ERR_TRACE(MISSING_RNG_E))