From d5f7beefd4cd7268ef1b02cda4c1fad87ba9c4bd Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Mon, 9 May 2022 16:50:56 -0600 Subject: [PATCH 1/4] Address issues ID'd by new windows multi-config test --- src/internal.c | 2 +- src/ssl.c | 10 ++++----- src/tls.c | 2 +- src/x509.c | 2 +- wolfcrypt/src/aes.c | 2 +- wolfcrypt/src/asn.c | 2 +- wolfcrypt/src/evp.c | 2 +- wolfcrypt/src/sha3.c | 4 ++-- wolfcrypt/src/sp_c32.c | 50 +++++++++++++++++++++--------------------- wolfcrypt/src/sp_int.c | 15 +++++++------ 10 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/internal.c b/src/internal.c index 2745ce123..dec859ddd 100644 --- a/src/internal.c +++ b/src/internal.c @@ -30764,7 +30764,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, #ifndef NO_ASN_TIME c32toa(LowResTimer(), (byte*)&it.timestamp); #endif - it.haveEMS = ssl->options.haveEMS; + it.haveEMS = (byte) ssl->options.haveEMS; } else { #ifdef WOLFSSL_TLS13 diff --git a/src/ssl.c b/src/ssl.c index 8d5801157..b50fb7a69 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -13504,7 +13504,7 @@ int AddSessionToCache(WOLFSSL_SESSION* addSession, const byte* id, byte idSz, cacheTicBuff = cacheSession->ticket; ticBuffUsed = 1; cacheSession->ticket = ticBuff; - cacheSession->ticketLenAlloc = ticLen; + cacheSession->ticketLenAlloc = (word16) ticLen; } #endif #ifdef SESSION_CERTS @@ -19834,7 +19834,7 @@ int wolfSSL_DupSession(const WOLFSSL_SESSION* input, WOLFSSL_SESSION* output, WOLFSSL_MSG("Failed to allocate memory for ticket when avoiding" " syscalls"); output->ticket = ticBuff; - output->ticketLenAlloc = ticLenAlloc; + output->ticketLenAlloc = (word16) ticLenAlloc; output->ticketLen = 0; ret = WOLFSSL_FAILURE; } @@ -19858,7 +19858,7 @@ int wolfSSL_DupSession(const WOLFSSL_SESSION* input, WOLFSSL_SESSION* output, if (ticBuff != NULL && ret == WOLFSSL_SUCCESS) { XMEMCPY(ticBuff, input->ticket, input->ticketLen); output->ticket = ticBuff; - output->ticketLenAlloc = ticLenAlloc; + output->ticketLenAlloc = (word16) ticLenAlloc; } } else { @@ -19876,7 +19876,7 @@ int wolfSSL_DupSession(const WOLFSSL_SESSION* input, WOLFSSL_SESSION* output, "avoiding system calls"); ret = WOLFSSL_FAILURE; output->ticket = ticBuff; - output->ticketLenAlloc = ticLenAlloc; + output->ticketLenAlloc = (word16) ticLenAlloc; output->ticketLen = 0; } } @@ -42293,7 +42293,7 @@ int wolfSSL_set_alpn_protos(WOLFSSL* ssl, TLSX_Remove(&ssl->extensions, TLSX_APPLICATION_LAYER_PROTOCOL, ssl->heap); if ((sz = wolfSSL_BIO_get_mem_data(bio, &pt)) > 0) { - wolfSSL_UseALPN(ssl, pt, sz, alpn_opt); + wolfSSL_UseALPN(ssl, pt, sz, (byte) alpn_opt); } wolfSSL_BIO_free(bio); #if defined(WOLFSSL_ERROR_CODE_OPENSSL) diff --git a/src/tls.c b/src/tls.c index f2f62dc69..b57325f2d 100644 --- a/src/tls.c +++ b/src/tls.c @@ -6699,7 +6699,7 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse) int ret = 0; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) word32 keySize = 0; - word16 curveId = ECC_CURVE_INVALID; + word16 curveId = (word16) ECC_CURVE_INVALID; ecc_key* eccKey = (ecc_key*)kse->key; /* TODO: [TLS13] The key sizes should come from wolfcrypt. */ diff --git a/src/x509.c b/src/x509.c index 9cd2a3874..0f8acc2db 100644 --- a/src/x509.c +++ b/src/x509.c @@ -8182,7 +8182,7 @@ WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_X509_chain_up_ref( return BUFFER_E; } - out[0] = t->type; + out[0] = (byte) t->type; sz = SetLength(t->length, out + 1) + 1; /* gen tag */ for (i = 0; i < t->length; i++) { out[sz + i] = t->data[i]; diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 9febd9408..f8d6cd5db 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -4582,7 +4582,7 @@ static WC_INLINE void RIGHTSHIFTX(byte* x) for (i = 0; i < AES_BLOCK_SIZE; i++) { int carryOut = (x[i] & 0x01) << 7; - x[i] = (x[i] >> 1) | carryIn; + x[i] = (byte) ((x[i] >> 1) | carryIn); carryIn = carryOut; } x[0] ^= borrow; diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index f9b92fcc5..22a357996 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -22572,7 +22572,7 @@ int FlattenAltNames(byte* output, word32 outputSz, const DNS_entry* names) idx = i - curName->len - len - 1; i = idx; #endif - output[idx] = ASN_CONTEXT_SPECIFIC | curName->type; + output[idx] = (byte) (ASN_CONTEXT_SPECIFIC | curName->type); if (curName->type == ASN_DIR_TYPE) { output[idx] |= ASN_CONSTRUCTED; } diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 03aba277b..db7ff9f43 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -6381,7 +6381,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) ctx->authTagSz = CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE; ctx->ivSz = CHACHA20_POLY1305_AEAD_IV_SIZE; if (enc == 0 || enc == 1) { - ctx->enc = enc; + ctx->enc = (byte) enc; } if (key != NULL && iv != NULL && wc_ChaCha20Poly1305_Init( diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index 8548ae579..9007b28bc 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -621,7 +621,7 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p) t[i] = data[i]; data += i; len -= i; - sha3->i += i; + sha3->i += (byte) i; if (sha3->i == p * 8) { for (i = 0; i < p; i++) @@ -639,7 +639,7 @@ static int Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p) } for (i = 0; i < len; i++) sha3->t[i] = data[i]; - sha3->i += i; + sha3->i += (byte) i; return 0; } diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index b674a53c9..e729bf8e7 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -1926,8 +1926,8 @@ static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -2993,8 +2993,8 @@ static WC_INLINE sp_digit sp_2048_div_word_72(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -3525,7 +3525,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -5618,8 +5618,8 @@ static WC_INLINE sp_digit sp_3072_div_word_53(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -6462,8 +6462,8 @@ static WC_INLINE sp_digit sp_3072_div_word_106(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -6990,7 +6990,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -9651,8 +9651,8 @@ static WC_INLINE sp_digit sp_3072_div_word_56(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 28; - sp_digit t0 = (sp_digit)d & 0xfffffff; + sp_digit t1 = (sp_digit) (d >> 28); + sp_digit t0 = (sp_digit) (d & 0xfffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -10574,8 +10574,8 @@ static WC_INLINE sp_digit sp_3072_div_word_112(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 28; - sp_digit t0 = (sp_digit)d & 0xfffffff; + sp_digit t1 = (sp_digit) (d >> 28); + sp_digit t0 = (sp_digit) (d & 0xfffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -13281,8 +13281,8 @@ static WC_INLINE sp_digit sp_4096_div_word_71(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -14126,8 +14126,8 @@ static WC_INLINE sp_digit sp_4096_div_word_142(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 29; - sp_digit t0 = (sp_digit)d & 0x1fffffff; + sp_digit t1 = (sp_digit) (d >> 29); + sp_digit t0 = (sp_digit) (d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -14654,7 +14654,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -17194,8 +17194,8 @@ static WC_INLINE sp_digit sp_4096_div_word_81(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 26; - sp_digit t0 = (sp_digit)d & 0x3ffffff; + sp_digit t1 = (sp_digit) (d >> 26); + sp_digit t0 = (sp_digit) (d & 0x3ffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -18103,8 +18103,8 @@ static WC_INLINE sp_digit sp_4096_div_word_162(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 26; - sp_digit t0 = (sp_digit)d & 0x3ffffff; + sp_digit t1 = (sp_digit) (d >> 26); + sp_digit t0 = (sp_digit) (d & 0x3ffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -41067,8 +41067,8 @@ static WC_INLINE sp_digit sp_521_div_word_21(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 25) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 25; - sp_digit t0 = (sp_digit)d & 0x1ffffff; + sp_digit t1 = (sp_digit) (d >> 25); + sp_digit t0 = (sp_digit) (d & 0x1ffffff); sp_digit t2; sp_digit sign; sp_digit r; diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 1317df0ad..f08af1bfc 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -14527,8 +14527,9 @@ int sp_mont_setup(sp_int* m, sp_int_digit* rho) #endif /* SP_WORD_SIZE >= 32 */ #endif /* SP_WORD_SIZE >= 16 */ - /* rho = -1/m mod b */ - *rho = -x; + /* rho = -1/m mod b, subtract x (unsigned) from 0 (MP_ZPOS) and + * assign negative result */ + *rho = (sp_int_digit) (MP_ZPOS - x); } return err; @@ -14757,7 +14758,7 @@ int sp_to_unsigned_bin_len(sp_int* a, byte* out, int outSz) for (i = 0; (j >= 0) && (i < a->used); i++) { int b; for (b = 0; b < SP_WORD_SIZE; b += 8) { - out[j--] = a->dp[i] >> b; + out[j--] = (byte) (a->dp[i] >> b); if (j < 0) { break; } @@ -15039,11 +15040,11 @@ int sp_tohex(sp_int* a, char* str) #endif /* WC_DISABLE_RADIX_ZERO_PAD */ /* Most-significant word. */ for (; j >= 0; j -= 4) { - *(str++) = ByteToHex(a->dp[i] >> j); + *(str++) = ByteToHex((byte) (a->dp[i] >> j)); } for (--i; i >= 0; i--) { for (j = SP_WORD_SIZE - 4; j >= 0; j -= 4) { - *(str++) = ByteToHex(a->dp[i] >> j); + *(str++) = (byte) ByteToHex((byte) (a->dp[i] >> j)); } } *str = '\0'; @@ -15103,14 +15104,14 @@ int sp_todecimal(sp_int* a, char* str) i = 0; while (!sp_iszero(t)) { sp_div_d(t, 10, t, &d); - str[i++] = '0' + d; + str[i++] = (char) ('0' + d); } str[i] = '\0'; for (j = 0; j <= (i - 1) / 2; j++) { int c = (unsigned char)str[j]; str[j] = str[i - 1 - j]; - str[i - 1 - j] = c; + str[i - 1 - j] = (char) c; } } From cb6a138caff27a82e8e58eeb7e779dd8d5e63088 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 10 May 2022 08:43:18 -0600 Subject: [PATCH 2/4] Implement peer review feedback --- wolfcrypt/src/sp_int.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index f08af1bfc..b9980fdcc 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -14527,9 +14527,8 @@ int sp_mont_setup(sp_int* m, sp_int_digit* rho) #endif /* SP_WORD_SIZE >= 32 */ #endif /* SP_WORD_SIZE >= 16 */ - /* rho = -1/m mod b, subtract x (unsigned) from 0 (MP_ZPOS) and - * assign negative result */ - *rho = (sp_int_digit) (MP_ZPOS - x); + /* rho = -1/m mod b, subtract x (unsigned) from 0, assign negative */ + *rho = (sp_int_digit) ((sp_int_digit)0 - (sp_int_digit)x); } return err; From dca71d36f62ff161a716d82ed9d7f80fb9df3b85 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Wed, 11 May 2022 10:51:19 +1000 Subject: [PATCH 3/4] SP: Script changed, generated result update --- wolfcrypt/src/sp_c32.c | 52 ++++++++++++++++---------------- wolfcrypt/src/sp_c64.c | 68 +++++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index e729bf8e7..6617476ab 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -1926,8 +1926,8 @@ static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -2993,8 +2993,8 @@ static WC_INLINE sp_digit sp_2048_div_word_72(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -5618,8 +5618,8 @@ static WC_INLINE sp_digit sp_3072_div_word_53(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -6462,8 +6462,8 @@ static WC_INLINE sp_digit sp_3072_div_word_106(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -9651,8 +9651,8 @@ static WC_INLINE sp_digit sp_3072_div_word_56(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 28); - sp_digit t0 = (sp_digit) (d & 0xfffffff); + sp_digit t1 = (sp_digit)(d >> 28); + sp_digit t0 = (sp_digit)(d & 0xfffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -10574,8 +10574,8 @@ static WC_INLINE sp_digit sp_3072_div_word_112(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 28); - sp_digit t0 = (sp_digit) (d & 0xfffffff); + sp_digit t1 = (sp_digit)(d >> 28); + sp_digit t0 = (sp_digit)(d & 0xfffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -11107,7 +11107,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -13281,8 +13281,8 @@ static WC_INLINE sp_digit sp_4096_div_word_71(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -14126,8 +14126,8 @@ static WC_INLINE sp_digit sp_4096_div_word_142(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 29); - sp_digit t0 = (sp_digit) (d & 0x1fffffff); + sp_digit t1 = (sp_digit)(d >> 29); + sp_digit t0 = (sp_digit)(d & 0x1fffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -17194,8 +17194,8 @@ static WC_INLINE sp_digit sp_4096_div_word_81(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 26); - sp_digit t0 = (sp_digit) (d & 0x3ffffff); + sp_digit t1 = (sp_digit)(d >> 26); + sp_digit t0 = (sp_digit)(d & 0x3ffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -18103,8 +18103,8 @@ static WC_INLINE sp_digit sp_4096_div_word_162(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 26); - sp_digit t0 = (sp_digit) (d & 0x3ffffff); + sp_digit t1 = (sp_digit)(d >> 26); + sp_digit t0 = (sp_digit)(d & 0x3ffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -18638,7 +18638,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -41067,8 +41067,8 @@ static WC_INLINE sp_digit sp_521_div_word_21(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 25) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit) (d >> 25); - sp_digit t0 = (sp_digit) (d & 0x1ffffff); + sp_digit t1 = (sp_digit)(d >> 25); + sp_digit t0 = (sp_digit)(d & 0x1ffffff); sp_digit t2; sp_digit sign; sp_digit r; @@ -43730,8 +43730,8 @@ static WC_INLINE sp_digit sp_1024_div_word_42(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 25) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 25; - sp_digit t0 = (sp_digit)d & 0x1ffffff; + sp_digit t1 = (sp_digit)(d >> 25); + sp_digit t0 = (sp_digit)(d & 0x1ffffff); sp_digit t2; sp_digit sign; sp_digit r; diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index bf99db658..8f2569078 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -846,8 +846,8 @@ static WC_INLINE sp_digit sp_2048_div_word_17(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 61) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 61; - sp_digit t0 = (sp_digit)d & 0x1fffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 61); + sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -1676,8 +1676,8 @@ static WC_INLINE sp_digit sp_2048_div_word_34(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 61) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 61; - sp_digit t0 = (sp_digit)d & 0x1fffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 61); + sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -2204,7 +2204,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -4380,8 +4380,8 @@ static WC_INLINE sp_digit sp_2048_div_word_18(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 57; - sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 57); + sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -5271,8 +5271,8 @@ static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 57; - sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 57); + sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -5803,7 +5803,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -7729,8 +7729,8 @@ static WC_INLINE sp_digit sp_3072_div_word_26(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 60) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 60; - sp_digit t0 = (sp_digit)d & 0xfffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 60); + sp_digit t0 = (sp_digit)(d & 0xfffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -8565,8 +8565,8 @@ static WC_INLINE sp_digit sp_3072_div_word_52(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 60) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 60; - sp_digit t0 = (sp_digit)d & 0xfffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 60); + sp_digit t0 = (sp_digit)(d & 0xfffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -9093,7 +9093,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -11407,8 +11407,8 @@ static WC_INLINE sp_digit sp_3072_div_word_27(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 57; - sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 57); + sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -12309,8 +12309,8 @@ static WC_INLINE sp_digit sp_3072_div_word_54(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 57; - sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 57); + sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -12841,7 +12841,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -14809,8 +14809,8 @@ static WC_INLINE sp_digit sp_4096_div_word_35(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 59) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 59; - sp_digit t0 = (sp_digit)d & 0x7ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 59); + sp_digit t0 = (sp_digit)(d & 0x7ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -15640,8 +15640,8 @@ static WC_INLINE sp_digit sp_4096_div_word_70(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 59) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 59; - sp_digit t0 = (sp_digit)d & 0x7ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 59); + sp_digit t0 = (sp_digit)(d & 0x7ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -16168,7 +16168,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -18537,8 +18537,8 @@ static WC_INLINE sp_digit sp_4096_div_word_39(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 53) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 53; - sp_digit t0 = (sp_digit)d & 0x1fffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 53); + sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -19440,8 +19440,8 @@ static WC_INLINE sp_digit sp_4096_div_word_78(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 53) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 53; - sp_digit t0 = (sp_digit)d & 0x1fffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 53); + sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -19972,7 +19972,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp; + sp_digit mp = 0; int i; int err = MP_OKAY; @@ -40728,8 +40728,8 @@ static WC_INLINE sp_digit sp_521_div_word_9(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 58) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 58; - sp_digit t0 = (sp_digit)d & 0x3ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 58); + sp_digit t0 = (sp_digit)(d & 0x3ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; @@ -43250,8 +43250,8 @@ static WC_INLINE sp_digit sp_1024_div_word_18(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = d >> 57; - sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; + sp_digit t1 = (sp_digit)(d >> 57); + sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); sp_digit t2; sp_digit sign; sp_digit r; From eb6f9152db56674533f53c1ed05f6fd5a5db8360 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Wed, 11 May 2022 07:27:16 -0600 Subject: [PATCH 4/4] Revert modifications addressed by wolfSSL/scripts PR #235 --- wolfcrypt/src/sp_c32.c | 58 +++++++++++++++++------------------ wolfcrypt/src/sp_c64.c | 68 +++++++++++++++++++++--------------------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 6617476ab..b674a53c9 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -1926,8 +1926,8 @@ static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -2993,8 +2993,8 @@ static WC_INLINE sp_digit sp_2048_div_word_72(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -3525,7 +3525,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -5618,8 +5618,8 @@ static WC_INLINE sp_digit sp_3072_div_word_53(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -6462,8 +6462,8 @@ static WC_INLINE sp_digit sp_3072_div_word_106(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -6990,7 +6990,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -9651,8 +9651,8 @@ static WC_INLINE sp_digit sp_3072_div_word_56(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 28); - sp_digit t0 = (sp_digit)(d & 0xfffffff); + sp_digit t1 = d >> 28; + sp_digit t0 = (sp_digit)d & 0xfffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -10574,8 +10574,8 @@ static WC_INLINE sp_digit sp_3072_div_word_112(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 28) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 28); - sp_digit t0 = (sp_digit)(d & 0xfffffff); + sp_digit t1 = d >> 28; + sp_digit t0 = (sp_digit)d & 0xfffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -11107,7 +11107,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -13281,8 +13281,8 @@ static WC_INLINE sp_digit sp_4096_div_word_71(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -14126,8 +14126,8 @@ static WC_INLINE sp_digit sp_4096_div_word_142(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 29) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 29); - sp_digit t0 = (sp_digit)(d & 0x1fffffff); + sp_digit t1 = d >> 29; + sp_digit t0 = (sp_digit)d & 0x1fffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -14654,7 +14654,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -17194,8 +17194,8 @@ static WC_INLINE sp_digit sp_4096_div_word_81(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 26); - sp_digit t0 = (sp_digit)(d & 0x3ffffff); + sp_digit t1 = d >> 26; + sp_digit t0 = (sp_digit)d & 0x3ffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -18103,8 +18103,8 @@ static WC_INLINE sp_digit sp_4096_div_word_162(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 26) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 26); - sp_digit t0 = (sp_digit)(d & 0x3ffffff); + sp_digit t1 = d >> 26; + sp_digit t0 = (sp_digit)d & 0x3ffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -18638,7 +18638,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -41067,8 +41067,8 @@ static WC_INLINE sp_digit sp_521_div_word_21(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 25) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 25); - sp_digit t0 = (sp_digit)(d & 0x1ffffff); + sp_digit t1 = d >> 25; + sp_digit t0 = (sp_digit)d & 0x1ffffff; sp_digit t2; sp_digit sign; sp_digit r; @@ -43730,8 +43730,8 @@ static WC_INLINE sp_digit sp_1024_div_word_42(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int64 d = ((sp_int64)d1 << 25) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 25); - sp_digit t0 = (sp_digit)(d & 0x1ffffff); + sp_digit t1 = d >> 25; + sp_digit t0 = (sp_digit)d & 0x1ffffff; sp_digit t2; sp_digit sign; sp_digit r; diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 8f2569078..bf99db658 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -846,8 +846,8 @@ static WC_INLINE sp_digit sp_2048_div_word_17(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 61) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 61); - sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffffL); + sp_digit t1 = d >> 61; + sp_digit t0 = (sp_digit)d & 0x1fffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -1676,8 +1676,8 @@ static WC_INLINE sp_digit sp_2048_div_word_34(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 61) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 61); - sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffffL); + sp_digit t1 = d >> 61; + sp_digit t0 = (sp_digit)d & 0x1fffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -2204,7 +2204,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -4380,8 +4380,8 @@ static WC_INLINE sp_digit sp_2048_div_word_18(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 57); - sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); + sp_digit t1 = d >> 57; + sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -5271,8 +5271,8 @@ static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 57); - sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); + sp_digit t1 = d >> 57; + sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -5803,7 +5803,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -7729,8 +7729,8 @@ static WC_INLINE sp_digit sp_3072_div_word_26(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 60) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 60); - sp_digit t0 = (sp_digit)(d & 0xfffffffffffffffL); + sp_digit t1 = d >> 60; + sp_digit t0 = (sp_digit)d & 0xfffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -8565,8 +8565,8 @@ static WC_INLINE sp_digit sp_3072_div_word_52(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 60) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 60); - sp_digit t0 = (sp_digit)(d & 0xfffffffffffffffL); + sp_digit t1 = d >> 60; + sp_digit t0 = (sp_digit)d & 0xfffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -9093,7 +9093,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -11407,8 +11407,8 @@ static WC_INLINE sp_digit sp_3072_div_word_27(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 57); - sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); + sp_digit t1 = d >> 57; + sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -12309,8 +12309,8 @@ static WC_INLINE sp_digit sp_3072_div_word_54(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 57); - sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); + sp_digit t1 = d >> 57; + sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -12841,7 +12841,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -14809,8 +14809,8 @@ static WC_INLINE sp_digit sp_4096_div_word_35(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 59) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 59); - sp_digit t0 = (sp_digit)(d & 0x7ffffffffffffffL); + sp_digit t1 = d >> 59; + sp_digit t0 = (sp_digit)d & 0x7ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -15640,8 +15640,8 @@ static WC_INLINE sp_digit sp_4096_div_word_70(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 59) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 59); - sp_digit t0 = (sp_digit)(d & 0x7ffffffffffffffL); + sp_digit t1 = d >> 59; + sp_digit t0 = (sp_digit)d & 0x7ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -16168,7 +16168,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -18537,8 +18537,8 @@ static WC_INLINE sp_digit sp_4096_div_word_39(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 53) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 53); - sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffL); + sp_digit t1 = d >> 53; + sp_digit t0 = (sp_digit)d & 0x1fffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -19440,8 +19440,8 @@ static WC_INLINE sp_digit sp_4096_div_word_78(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 53) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 53); - sp_digit t0 = (sp_digit)(d & 0x1fffffffffffffL); + sp_digit t1 = d >> 53; + sp_digit t0 = (sp_digit)d & 0x1fffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -19972,7 +19972,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em, sp_digit* r = NULL; sp_digit* norm = NULL; sp_digit e[1] = {0}; - sp_digit mp = 0; + sp_digit mp; int i; int err = MP_OKAY; @@ -40728,8 +40728,8 @@ static WC_INLINE sp_digit sp_521_div_word_9(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 58) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 58); - sp_digit t0 = (sp_digit)(d & 0x3ffffffffffffffL); + sp_digit t1 = d >> 58; + sp_digit t0 = (sp_digit)d & 0x3ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r; @@ -43250,8 +43250,8 @@ static WC_INLINE sp_digit sp_1024_div_word_18(sp_digit d1, sp_digit d0, #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV) sp_int128 d = ((sp_int128)d1 << 57) + d0; sp_digit dv = (div >> 1) + 1; - sp_digit t1 = (sp_digit)(d >> 57); - sp_digit t0 = (sp_digit)(d & 0x1ffffffffffffffL); + sp_digit t1 = d >> 57; + sp_digit t0 = (sp_digit)d & 0x1ffffffffffffffL; sp_digit t2; sp_digit sign; sp_digit r;