From 5530336617d855482f12a0379cda8359551bf990 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 20 Aug 2019 08:50:57 +1000 Subject: [PATCH] SP Mod exp cast fix --- wolfcrypt/src/sp_arm32.c | 20 ++++++++++---------- wolfcrypt/src/sp_arm64.c | 20 ++++++++++---------- wolfcrypt/src/sp_armthumb.c | 20 ++++++++++---------- wolfcrypt/src/sp_cortexm.c | 20 ++++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 0e3f0293d..e33223770 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -4870,7 +4870,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=4; ) { @@ -5014,7 +5014,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=5; ) { @@ -7118,7 +7118,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=4; ) { @@ -7262,7 +7262,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=5; ) { @@ -8118,7 +8118,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_2048_lshift_64(r, norm, y); for (; i>=0 || c>=5; ) { @@ -15267,7 +15267,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=4; ) { @@ -15411,7 +15411,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=5; ) { @@ -18315,7 +18315,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=4; ) { @@ -18459,7 +18459,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=5; ) { @@ -19507,7 +19507,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_3072_lshift_96(r, norm, y); for (; i>=0 || c>=5; ) { diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index f052de33f..0f90efba0 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -3107,7 +3107,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 64) c = 60; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 16); for (; i>=0 || c>=4; ) { @@ -3251,7 +3251,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 64) c = 59; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 16); for (; i>=0 || c>=5; ) { @@ -4475,7 +4475,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 64) c = 60; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=4; ) { @@ -4619,7 +4619,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 64) c = 59; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=5; ) { @@ -5281,7 +5281,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, sp_digit* e, int bits, c -= bits % 6; if (c == 64) c = 58; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; sp_2048_lshift_32(r, norm, y); for (; i>=0 || c>=6; ) { @@ -10100,7 +10100,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 64) c = 60; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 24); for (; i>=0 || c>=4; ) { @@ -10244,7 +10244,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 64) c = 59; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 24); for (; i>=0 || c>=5; ) { @@ -11836,7 +11836,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 64) c = 60; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=4; ) { @@ -11980,7 +11980,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 64) c = 59; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=5; ) { @@ -12738,7 +12738,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, sp_digit* e, int bits, c -= bits % 6; if (c == 64) c = 58; - y = n >> c; + y = (int)(n >> c); n <<= 64 - c; sp_3072_lshift_48(r, norm, y); for (; i>=0 || c>=6; ) { diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 952a36084..e4a5fe4bf 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -3168,7 +3168,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=4; ) { @@ -3312,7 +3312,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=5; ) { @@ -3991,7 +3991,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=4; ) { @@ -4135,7 +4135,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=5; ) { @@ -4997,7 +4997,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_2048_lshift_64(r, norm, y); for (; i>=0 || c>=5; ) { @@ -8779,7 +8779,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=4; ) { @@ -8923,7 +8923,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=5; ) { @@ -9608,7 +9608,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=4; ) { @@ -9752,7 +9752,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=5; ) { @@ -10812,7 +10812,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_3072_lshift_96(r, norm, y); for (; i>=0 || c>=5; ) { diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index c9f1217c0..832bfea12 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -3473,7 +3473,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=4; ) { @@ -3617,7 +3617,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 32); for (; i>=0 || c>=5; ) { @@ -4154,7 +4154,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=4; ) { @@ -4298,7 +4298,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 64); for (; i>=0 || c>=5; ) { @@ -5160,7 +5160,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_2048_lshift_64(r, norm, y); for (; i>=0 || c>=5; ) { @@ -8510,7 +8510,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=4; ) { @@ -8654,7 +8654,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 48); for (; i>=0 || c>=5; ) { @@ -9197,7 +9197,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 4; if (c == 32) c = 28; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=4; ) { @@ -9341,7 +9341,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; XMEMCPY(r, t[y], sizeof(sp_digit) * 96); for (; i>=0 || c>=5; ) { @@ -10399,7 +10399,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, sp_digit* e, int bits, c -= bits % 5; if (c == 32) c = 27; - y = n >> c; + y = (int)(n >> c); n <<= 32 - c; sp_3072_lshift_96(r, norm, y); for (; i>=0 || c>=5; ) {