Fixes for several implicit cast warnings. ZD 10848.

This commit is contained in:
David Garske
2020-08-27 13:51:55 -07:00
parent d077efcbb3
commit 0d2e37cc42
5 changed files with 132 additions and 133 deletions

View File

@@ -335,67 +335,67 @@ WC_STATIC WC_INLINE word32 btoi(byte b)
/* Constant time - mask set when a > b. */
WC_STATIC WC_INLINE byte ctMaskGT(int a, int b)
{
return ((byte)(((word32)a - b - 1) >> 31) - 1);
return (byte)((((word32)a - b - 1) >> 31) - 1);
}
/* Constant time - mask set when a >= b. */
WC_STATIC WC_INLINE byte ctMaskGTE(int a, int b)
{
return (((word32)a - b ) >> 31) - 1;
return (byte)((((word32)a - b ) >> 31) - 1);
}
/* Constant time - mask set when a >= b. */
WC_STATIC WC_INLINE int ctMaskIntGTE(int a, int b)
{
return (((word32)a - b ) >> 31) - 1;
return (int)((((word32)a - b ) >> 31) - 1);
}
/* Constant time - mask set when a < b. */
WC_STATIC WC_INLINE byte ctMaskLT(int a, int b)
{
return (((word32)b - a - 1) >> 31) - 1;
return (byte)((((word32)b - a - 1) >> 31) - 1);
}
/* Constant time - mask set when a <= b. */
WC_STATIC WC_INLINE byte ctMaskLTE(int a, int b)
{
return (((word32)b - a ) >> 31) - 1;
return (byte)((((word32)b - a ) >> 31) - 1);
}
/* Constant time - mask set when a == b. */
WC_STATIC WC_INLINE byte ctMaskEq(int a, int b)
{
return (~ctMaskGT(a, b)) & (~ctMaskLT(a, b));
return (byte)(~ctMaskGT(a, b)) & (byte)(~ctMaskLT(a, b));
}
/* Constant time - sets 16 bit integer mask when a > b */
WC_STATIC WC_INLINE word16 ctMask16GT(int a, int b)
{
return (((word32)a - b - 1) >> 31) - 1;
return (word16)((((word32)a - b - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a < b. */
WC_STATIC WC_INLINE word16 ctMask16LT(int a, int b)
{
return (((word32)b - a - 1) >> 31) - 1;
return (word16)((((word32)b - a - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a == b. */
WC_STATIC WC_INLINE word16 ctMask16Eq(int a, int b)
{
return (~ctMask16GT(a, b)) & (~ctMask16LT(a, b));
return (word16)(~ctMask16GT(a, b)) & (word16)(~ctMask16LT(a, b));
}
/* Constant time - mask set when a != b. */
WC_STATIC WC_INLINE byte ctMaskNotEq(int a, int b)
{
return ctMaskGT(a, b) | ctMaskLT(a, b);
return (byte)ctMaskGT(a, b) | (byte)ctMaskLT(a, b);
}
/* Constant time - select a when mask is set and b otherwise. */
WC_STATIC WC_INLINE byte ctMaskSel(byte m, byte a, byte b)
{
return (b & ((byte)~(word32)m)) | (a & m);
return (byte)((b & ((byte)~(word32)m)) | (a & m));
}
/* Constant time - select integer a when mask is set and integer b otherwise. */
@@ -408,7 +408,7 @@ WC_STATIC WC_INLINE int ctMaskSelInt(byte m, int a, int b)
/* Constant time - bit set when a <= b. */
WC_STATIC WC_INLINE byte ctSetLTE(int a, int b)
{
return ((word32)a - b - 1) >> 31;
return (byte)(((word32)a - b - 1) >> 31);
}
#endif

View File

@@ -537,15 +537,14 @@ static WC_INLINE void array_add(byte* d, word32 dLen, const byte* s, word32 sLen
if (dLen > 0 && sLen > 0 && dLen >= sLen) {
int sIdx, dIdx;
for (sIdx = sLen - 1, dIdx = dLen - 1; sIdx >= 0; dIdx--, sIdx--)
{
carry += d[dIdx] + s[sIdx];
for (sIdx = sLen - 1, dIdx = dLen - 1; sIdx >= 0; dIdx--, sIdx--) {
carry += (word16)d[dIdx] + (word16)s[sIdx];
d[dIdx] = (byte)carry;
carry >>= 8;
}
for (; carry != 0 && dIdx >= 0; dIdx--) {
carry += d[dIdx];
carry += (word16)d[dIdx];
d[dIdx] = (byte)carry;
carry >>= 8;
}

View File

@@ -1029,8 +1029,8 @@ SP_NOINLINE static void sp_2048_mul_90(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -1065,8 +1065,8 @@ SP_NOINLINE static void sp_2048_sqr_90(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -1172,8 +1172,8 @@ SP_NOINLINE static void sp_2048_mul_45(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -1208,8 +1208,8 @@ SP_NOINLINE static void sp_2048_sqr_45(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -1427,7 +1427,7 @@ SP_NOINLINE static void sp_2048_mul_add_45(sp_digit* r, const sp_digit* a,
r[i] = t & 0x7fffff;
t >>= 23;
}
r[45] += t;
r[45] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -2353,7 +2353,7 @@ SP_NOINLINE static void sp_2048_mul_add_90(sp_digit* r, const sp_digit* a,
r[i] = t & 0x7fffff;
t >>= 23;
}
r[90] += t;
r[90] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -4914,8 +4914,8 @@ SP_NOINLINE static void sp_3072_mul_134(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -4950,8 +4950,8 @@ SP_NOINLINE static void sp_3072_sqr_134(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -5055,8 +5055,8 @@ SP_NOINLINE static void sp_3072_mul_67(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -5091,8 +5091,8 @@ SP_NOINLINE static void sp_3072_sqr_67(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 46;
r[k + 1] = (c >> 23) & 0x7fffff;
r[k + 2] += (sp_digit)(c >> 46);
r[k + 1] = (sp_digit)((c >> 23) & 0x7fffff);
c = (c & 0x7fffff) << 23;
}
r[0] = (sp_digit)(c >> 23);
@@ -5312,7 +5312,7 @@ SP_NOINLINE static void sp_3072_mul_add_67(sp_digit* r, const sp_digit* a,
r[i] = t & 0x7fffff;
t >>= 23;
}
r[67] += t;
r[67] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -6206,7 +6206,7 @@ SP_NOINLINE static void sp_3072_mul_add_134(sp_digit* r, const sp_digit* a,
r[i] = t & 0x7fffff;
t >>= 23;
}
r[134] += t;
r[134] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -8971,8 +8971,8 @@ SP_NOINLINE static void sp_4096_mul_196(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 42;
r[k + 1] = (c >> 21) & 0x1fffff;
r[k + 2] += (sp_digit)(c >> 42);
r[k + 1] = (sp_digit)((c >> 21) & 0x1fffff);
c = (c & 0x1fffff) << 21;
}
r[0] = (sp_digit)(c >> 21);
@@ -9007,8 +9007,8 @@ SP_NOINLINE static void sp_4096_sqr_196(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 42;
r[k + 1] = (c >> 21) & 0x1fffff;
r[k + 2] += (sp_digit)(c >> 42);
r[k + 1] = (sp_digit)((c >> 21) & 0x1fffff);
c = (c & 0x1fffff) << 21;
}
r[0] = (sp_digit)(c >> 21);
@@ -9084,8 +9084,8 @@ SP_NOINLINE static void sp_4096_mul_98(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 42;
r[k + 1] = (c >> 21) & 0x1fffff;
r[k + 2] += (sp_digit)(c >> 42);
r[k + 1] = (sp_digit)((c >> 21) & 0x1fffff);
c = (c & 0x1fffff) << 21;
}
r[0] = (sp_digit)(c >> 21);
@@ -9120,8 +9120,8 @@ SP_NOINLINE static void sp_4096_sqr_98(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 42;
r[k + 1] = (c >> 21) & 0x1fffff;
r[k + 2] += (sp_digit)(c >> 42);
r[k + 1] = (sp_digit)((c >> 21) & 0x1fffff);
c = (c & 0x1fffff) << 21;
}
r[0] = (sp_digit)(c >> 21);
@@ -9336,7 +9336,7 @@ SP_NOINLINE static void sp_4096_mul_add_98(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1fffff;
t >>= 21;
}
r[98] += t;
r[98] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -10265,7 +10265,7 @@ SP_NOINLINE static void sp_4096_mul_add_196(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1fffff;
t >>= 21;
}
r[196] += t;
r[196] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[8];
@@ -12718,26 +12718,26 @@ static int sp_256_mod_mul_norm_10(sp_digit* r, const sp_digit* a, const sp_digit
r[0] = (sp_digit)(t[0]) & 0x3ffffffL;
r[1] = (sp_digit)(t[0] >> 26U);
r[1] |= t[1] << 6U;
r[1] |= (sp_digit)t[1] << 6U;
r[1] &= 0x3ffffffL;
r[2] = (sp_digit)(t[1] >> 20U);
r[2] |= t[2] << 12U;
r[2] |= (sp_digit)t[2] << 12U;
r[2] &= 0x3ffffffL;
r[3] = (sp_digit)(t[2] >> 14U);
r[3] |= t[3] << 18U;
r[3] |= (sp_digit)t[3] << 18U;
r[3] &= 0x3ffffffL;
r[4] = (sp_digit)(t[3] >> 8U);
r[4] |= t[4] << 24U;
r[4] |= (sp_digit)t[4] << 24U;
r[4] &= 0x3ffffffL;
r[5] = (sp_digit)(t[4] >> 2U) & 0x3ffffffL;
r[6] = (sp_digit)(t[4] >> 28U);
r[6] |= t[5] << 4U;
r[6] |= (sp_digit)t[5] << 4U;
r[6] &= 0x3ffffffL;
r[7] = (sp_digit)(t[5] >> 22U);
r[7] |= t[6] << 10U;
r[7] |= (sp_digit)t[6] << 10U;
r[7] &= 0x3ffffffL;
r[8] = (sp_digit)(t[6] >> 16U);
r[8] |= t[7] << 16U;
r[8] |= (sp_digit)t[7] << 16U;
r[8] &= 0x3ffffffL;
r[9] = (sp_digit)(t[7] >> 10U);
}
@@ -12963,8 +12963,8 @@ SP_NOINLINE static void sp_256_mul_10(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 52;
r[k + 1] = (c >> 26) & 0x3ffffff;
r[k + 2] += (sp_digit)(c >> 52);
r[k + 1] = (sp_digit)((c >> 26) & 0x3ffffff);
c = (c & 0x3ffffff) << 26;
}
r[0] = (sp_digit)(c >> 26);
@@ -13188,7 +13188,7 @@ SP_NOINLINE static void sp_256_mul_add_10(sp_digit* r, const sp_digit* a,
r[i] = t & 0x3ffffff;
t >>= 26;
}
r[10] += t;
r[10] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[10];
@@ -13376,8 +13376,8 @@ SP_NOINLINE static void sp_256_sqr_10(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 52;
r[k + 1] = (c >> 26) & 0x3ffffff;
r[k + 2] += (sp_digit)(c >> 52);
r[k + 1] = (sp_digit)((c >> 26) & 0x3ffffff);
c = (c & 0x3ffffff) << 26;
}
r[0] = (sp_digit)(c >> 26);
@@ -19221,39 +19221,39 @@ static int sp_384_mod_mul_norm_15(sp_digit* r, const sp_digit* a, const sp_digit
r[0] = (sp_digit)(t[0]) & 0x3ffffffL;
r[1] = (sp_digit)(t[0] >> 26U);
r[1] |= t[1] << 6U;
r[1] |= (sp_digit)t[1] << 6U;
r[1] &= 0x3ffffffL;
r[2] = (sp_digit)(t[1] >> 20U);
r[2] |= t[2] << 12U;
r[2] |= (sp_digit)t[2] << 12U;
r[2] &= 0x3ffffffL;
r[3] = (sp_digit)(t[2] >> 14U);
r[3] |= t[3] << 18U;
r[3] |= (sp_digit)t[3] << 18U;
r[3] &= 0x3ffffffL;
r[4] = (sp_digit)(t[3] >> 8U);
r[4] |= t[4] << 24U;
r[4] |= (sp_digit)t[4] << 24U;
r[4] &= 0x3ffffffL;
r[5] = (sp_digit)(t[4] >> 2U) & 0x3ffffffL;
r[6] = (sp_digit)(t[4] >> 28U);
r[6] |= t[5] << 4U;
r[6] |= (sp_digit)t[5] << 4U;
r[6] &= 0x3ffffffL;
r[7] = (sp_digit)(t[5] >> 22U);
r[7] |= t[6] << 10U;
r[7] |= (sp_digit)t[6] << 10U;
r[7] &= 0x3ffffffL;
r[8] = (sp_digit)(t[6] >> 16U);
r[8] |= t[7] << 16U;
r[8] |= (sp_digit)t[7] << 16U;
r[8] &= 0x3ffffffL;
r[9] = (sp_digit)(t[7] >> 10U);
r[9] |= t[8] << 22U;
r[9] |= (sp_digit)t[8] << 22U;
r[9] &= 0x3ffffffL;
r[10] = (sp_digit)(t[8] >> 4U) & 0x3ffffffL;
r[11] = (sp_digit)(t[8] >> 30U);
r[11] |= t[9] << 2U;
r[11] |= (sp_digit)t[9] << 2U;
r[11] &= 0x3ffffffL;
r[12] = (sp_digit)(t[9] >> 24U);
r[12] |= t[10] << 8U;
r[12] |= (sp_digit)t[10] << 8U;
r[12] &= 0x3ffffffL;
r[13] = (sp_digit)(t[10] >> 18U);
r[13] |= t[11] << 14U;
r[13] |= (sp_digit)t[11] << 14U;
r[13] &= 0x3ffffffL;
r[14] = (sp_digit)(t[11] >> 12U);
}
@@ -19478,8 +19478,8 @@ SP_NOINLINE static void sp_384_mul_15(sp_digit* r, const sp_digit* a,
c += ((int64_t)a[i]) * b[j];
}
r[k + 2] += c >> 52;
r[k + 1] = (c >> 26) & 0x3ffffff;
r[k + 2] += (sp_digit)(c >> 52);
r[k + 1] = (sp_digit)((c >> 26) & 0x3ffffff);
c = (c & 0x3ffffff) << 26;
}
r[0] = (sp_digit)(c >> 26);
@@ -19848,7 +19848,7 @@ SP_NOINLINE static void sp_384_mul_add_15(sp_digit* r, const sp_digit* a,
r[i] = t & 0x3ffffff;
t >>= 26;
}
r[15] += t;
r[15] += (sp_digit)t;
#else
int64_t tb = b;
int64_t t[15];
@@ -20032,8 +20032,8 @@ SP_NOINLINE static void sp_384_sqr_15(sp_digit* r, const sp_digit* a)
c += ((int64_t)a[i]) * a[i];
}
r[k + 2] += c >> 52;
r[k + 1] = (c >> 26) & 0x3ffffff;
r[k + 2] += (sp_digit)(c >> 52);
r[k + 1] = (sp_digit)((c >> 26) & 0x3ffffff);
c = (c & 0x3ffffff) << 26;
}
r[0] = (sp_digit)(c >> 26);

View File

@@ -698,8 +698,8 @@ SP_NOINLINE static void sp_2048_mul_36(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -734,8 +734,8 @@ SP_NOINLINE static void sp_2048_sqr_36(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -810,8 +810,8 @@ SP_NOINLINE static void sp_2048_mul_18(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -846,8 +846,8 @@ SP_NOINLINE static void sp_2048_sqr_18(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -1061,7 +1061,7 @@ SP_NOINLINE static void sp_2048_mul_add_18(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1ffffffffffffffL;
t >>= 57;
}
r[18] += t;
r[18] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -2007,7 +2007,7 @@ SP_NOINLINE static void sp_2048_mul_add_36(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1ffffffffffffffL;
t >>= 57;
}
r[36] += t;
r[36] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -4782,8 +4782,8 @@ SP_NOINLINE static void sp_3072_mul_54(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -4818,8 +4818,8 @@ SP_NOINLINE static void sp_3072_sqr_54(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -4952,8 +4952,8 @@ SP_NOINLINE static void sp_3072_mul_27(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -5016,8 +5016,8 @@ SP_NOINLINE static void sp_3072_sqr_27(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 114;
r[k + 1] = (c >> 57) & 0x1ffffffffffffffL;
r[k + 2] += (sp_digit)(c >> 114);
r[k + 1] = (sp_digit)((c >> 57) & 0x1ffffffffffffffL);
c = (c & 0x1ffffffffffffffL) << 57;
}
r[0] = (sp_digit)(c >> 57);
@@ -5263,7 +5263,7 @@ SP_NOINLINE static void sp_3072_mul_add_27(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1ffffffffffffffL;
t >>= 57;
}
r[27] += t;
r[27] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -6194,7 +6194,7 @@ SP_NOINLINE static void sp_3072_mul_add_54(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1ffffffffffffffL;
t >>= 57;
}
r[54] += t;
r[54] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -9095,8 +9095,8 @@ SP_NOINLINE static void sp_4096_mul_78(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 106;
r[k + 1] = (c >> 53) & 0x1fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 106);
r[k + 1] = (sp_digit)((c >> 53) & 0x1fffffffffffffL);
c = (c & 0x1fffffffffffffL) << 53;
}
r[0] = (sp_digit)(c >> 53);
@@ -9131,8 +9131,8 @@ SP_NOINLINE static void sp_4096_sqr_78(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 106;
r[k + 1] = (c >> 53) & 0x1fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 106);
r[k + 1] = (sp_digit)((c >> 53) & 0x1fffffffffffffL);
c = (c & 0x1fffffffffffffL) << 53;
}
r[0] = (sp_digit)(c >> 53);
@@ -9241,8 +9241,8 @@ SP_NOINLINE static void sp_4096_mul_39(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 106;
r[k + 1] = (c >> 53) & 0x1fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 106);
r[k + 1] = (sp_digit)((c >> 53) & 0x1fffffffffffffL);
c = (c & 0x1fffffffffffffL) << 53;
}
r[0] = (sp_digit)(c >> 53);
@@ -9277,8 +9277,8 @@ SP_NOINLINE static void sp_4096_sqr_39(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 106;
r[k + 1] = (c >> 53) & 0x1fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 106);
r[k + 1] = (sp_digit)((c >> 53) & 0x1fffffffffffffL);
c = (c & 0x1fffffffffffffL) << 53;
}
r[0] = (sp_digit)(c >> 53);
@@ -9513,7 +9513,7 @@ SP_NOINLINE static void sp_4096_mul_add_39(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1fffffffffffffL;
t >>= 53;
}
r[39] += t;
r[39] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -10492,7 +10492,7 @@ SP_NOINLINE static void sp_4096_mul_add_78(sp_digit* r, const sp_digit* a,
r[i] = t & 0x1fffffffffffffL;
t >>= 53;
}
r[78] += t;
r[78] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[8];
@@ -12689,18 +12689,18 @@ static int sp_256_mod_mul_norm_5(sp_digit* r, const sp_digit* a, const sp_digit*
a32[0] = (sp_digit)(a[0]) & 0xffffffffL;
a32[1] = (sp_digit)(a[0] >> 32U);
a32[1] |= a[1] << 20U;
a32[1] |= (sp_digit)a[1] << 20U;
a32[1] &= 0xffffffffL;
a32[2] = (sp_digit)(a[1] >> 12U) & 0xffffffffL;
a32[3] = (sp_digit)(a[1] >> 44U);
a32[3] |= a[2] << 8U;
a32[3] |= (sp_digit)a[2] << 8U;
a32[3] &= 0xffffffffL;
a32[4] = (sp_digit)(a[2] >> 24U);
a32[4] |= a[3] << 28U;
a32[4] |= (sp_digit)a[3] << 28U;
a32[4] &= 0xffffffffL;
a32[5] = (sp_digit)(a[3] >> 4U) & 0xffffffffL;
a32[6] = (sp_digit)(a[3] >> 36U);
a32[6] |= a[4] << 16U;
a32[6] |= (sp_digit)a[4] << 16U;
a32[6] &= 0xffffffffL;
a32[7] = (sp_digit)(a[4] >> 16U) & 0xffffffffL;
@@ -12980,8 +12980,8 @@ SP_NOINLINE static void sp_256_mul_5(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 104;
r[k + 1] = (c >> 52) & 0xfffffffffffffL;
r[k + 2] += (sp_digit)(c >> 104);
r[k + 1] = (sp_digit)((c >> 52) & 0xfffffffffffffL);
c = (c & 0xfffffffffffffL) << 52;
}
r[0] = (sp_digit)(c >> 52);
@@ -13110,7 +13110,7 @@ SP_NOINLINE static void sp_256_mul_add_5(sp_digit* r, const sp_digit* a,
r[i] = t & 0xfffffffffffffL;
t >>= 52;
}
r[5] += t;
r[5] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[5];
@@ -13267,8 +13267,8 @@ SP_NOINLINE static void sp_256_sqr_5(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 104;
r[k + 1] = (c >> 52) & 0xfffffffffffffL;
r[k + 2] += (sp_digit)(c >> 104);
r[k + 1] = (sp_digit)((c >> 52) & 0xfffffffffffffL);
c = (c & 0xfffffffffffffL) << 52;
}
r[0] = (sp_digit)(c >> 52);
@@ -18369,7 +18369,7 @@ int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
sp_point_256 pd;
sp_point_256 qd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_256* p;
sp_point_256* q = NULL;
int err;
@@ -18440,7 +18440,7 @@ int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
sp_digit tmpd[2 * 5 * 2];
sp_point_256 pd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_256* p;
int err;
@@ -18499,7 +18499,7 @@ int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ)
sp_digit tmpd[2 * 5 * 4];
sp_point_256 pd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_256* p;
int err;
@@ -18856,26 +18856,26 @@ static int sp_384_mod_mul_norm_7(sp_digit* r, const sp_digit* a, const sp_digit*
a32[0] = (sp_digit)(a[0]) & 0xffffffffL;
a32[1] = (sp_digit)(a[0] >> 32U);
a32[1] |= a[1] << 23U;
a32[1] |= (sp_digit)a[1] << 23U;
a32[1] &= 0xffffffffL;
a32[2] = (sp_digit)(a[1] >> 9U) & 0xffffffffL;
a32[3] = (sp_digit)(a[1] >> 41U);
a32[3] |= a[2] << 14U;
a32[3] |= (sp_digit)a[2] << 14U;
a32[3] &= 0xffffffffL;
a32[4] = (sp_digit)(a[2] >> 18U) & 0xffffffffL;
a32[5] = (sp_digit)(a[2] >> 50U);
a32[5] |= a[3] << 5U;
a32[5] |= (sp_digit)a[3] << 5U;
a32[5] &= 0xffffffffL;
a32[6] = (sp_digit)(a[3] >> 27U);
a32[6] |= a[4] << 28U;
a32[6] |= (sp_digit)a[4] << 28U;
a32[6] &= 0xffffffffL;
a32[7] = (sp_digit)(a[4] >> 4U) & 0xffffffffL;
a32[8] = (sp_digit)(a[4] >> 36U);
a32[8] |= a[5] << 19U;
a32[8] |= (sp_digit)a[5] << 19U;
a32[8] &= 0xffffffffL;
a32[9] = (sp_digit)(a[5] >> 13U) & 0xffffffffL;
a32[10] = (sp_digit)(a[5] >> 45U);
a32[10] |= a[6] << 10U;
a32[10] |= (sp_digit)a[6] << 10U;
a32[10] &= 0xffffffffL;
a32[11] = (sp_digit)(a[6] >> 22U) & 0xffffffffL;
@@ -19178,8 +19178,8 @@ SP_NOINLINE static void sp_384_mul_7(sp_digit* r, const sp_digit* a,
c += ((int128_t)a[i]) * b[j];
}
r[k + 2] += c >> 110;
r[k + 1] = (c >> 55) & 0x7fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 110);
r[k + 1] = (sp_digit)((c >> 55) & 0x7fffffffffffffL);
c = (c & 0x7fffffffffffffL) << 55;
}
r[0] = (sp_digit)(c >> 55);
@@ -19340,7 +19340,7 @@ SP_NOINLINE static void sp_384_mul_add_7(sp_digit* r, const sp_digit* a,
r[i] = t & 0x7fffffffffffffL;
t >>= 55;
}
r[7] += t;
r[7] += (sp_digit)t;
#else
int128_t tb = b;
int128_t t[7];
@@ -19494,8 +19494,8 @@ SP_NOINLINE static void sp_384_sqr_7(sp_digit* r, const sp_digit* a)
c += ((int128_t)a[i]) * a[i];
}
r[k + 2] += c >> 110;
r[k + 1] = (c >> 55) & 0x7fffffffffffffL;
r[k + 2] += (sp_digit)(c >> 110);
r[k + 1] = (sp_digit)((c >> 55) & 0x7fffffffffffffL);
c = (c & 0x7fffffffffffffL) << 55;
}
r[0] = (sp_digit)(c >> 55);
@@ -25165,7 +25165,7 @@ int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
sp_point_384 pd;
sp_point_384 qd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_384* p;
sp_point_384* q = NULL;
int err;
@@ -25236,7 +25236,7 @@ int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
sp_digit tmpd[2 * 7 * 2];
sp_point_384 pd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_384* p;
int err;
@@ -25295,7 +25295,7 @@ int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ)
sp_digit tmpd[2 * 7 * 6];
sp_point_384 pd;
#endif
sp_digit* tmp;
sp_digit* tmp = NULL;
sp_point_384* p;
int err;

View File

@@ -5254,11 +5254,11 @@ static int fp_read_radix_16(fp_int *a, const char *str)
for (i = (int)(XSTRLEN(str) - 1); i >= 0; i--) {
ch = str[i];
if (ch >= '0' && ch <= '9')
ch -= '0';
ch -= (char)'0';
else if (ch >= 'A' && ch <= 'F')
ch -= 'A' - 10;
ch -= (char)'A' - 10;
else if (ch >= 'a' && ch <= 'f')
ch -= 'a' - 10;
ch -= (char)'a' - 10;
else
return FP_VAL;