diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c index 65e2695a..65e7f0dd 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c index c45c92f0..5eea50f7 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c index 6bc2660f..c8c2c78b 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c index f9d7ed79..0f66469f 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c @@ -47,17 +47,17 @@ void fe_frombytes(fe h,const unsigned char *s) crypto_int64 carry8; crypto_int64 carry9; - carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + carry9 = (h9 + (crypto_int64) (1L << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + carry1 = (h1 + (crypto_int64) (1L << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; + carry3 = (h3 + (crypto_int64) (1L << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; + carry5 = (h5 + (crypto_int64) (1L << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; + carry7 = (h7 + (crypto_int64) (1L << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + carry0 = (h0 + (crypto_int64) (1L << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry2 = (h2 + (crypto_int64) (1L << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; + carry4 = (h4 + (crypto_int64) (1L << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry6 = (h6 + (crypto_int64) (1L << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; + carry8 = (h8 + (crypto_int64) (1L << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; h[0] = (crypto_int32) h0; h[1] = (crypto_int32) h1; diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c index 883d6127..f6d24c49 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c @@ -1,5 +1,7 @@ #include "fe.h" +#ifndef HAVE_TI_MODE + void fe_invert(fe out,const fe z) { fe t0; @@ -64,3 +66,5 @@ void fe_invert(fe out,const fe z) } fe_mul(out, t1, t0); } + +#endif diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c index 4d72888d..a70208ad 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c index a40b4f10..6856339b 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" #ifndef HAVE_TI_MODE @@ -199,59 +200,59 @@ void fe_mul(fe h,const fe f,const fe g) i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9 */ - carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry0 = (h0 + (crypto_int64) (1L << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry4 = (h4 + (crypto_int64) (1L << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; /* |h0| <= 2^25 */ /* |h4| <= 2^25 */ /* |h1| <= 1.51*2^58 */ /* |h5| <= 1.51*2^58 */ - carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; + carry1 = (h1 + (crypto_int64) (1L << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; + carry5 = (h5 + (crypto_int64) (1L << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; /* |h1| <= 2^24; from now on fits into int32 */ /* |h5| <= 2^24; from now on fits into int32 */ /* |h2| <= 1.21*2^59 */ /* |h6| <= 1.21*2^59 */ - carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; + carry2 = (h2 + (crypto_int64) (1L << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; + carry6 = (h6 + (crypto_int64) (1L << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; /* |h2| <= 2^25; from now on fits into int32 unchanged */ /* |h6| <= 2^25; from now on fits into int32 unchanged */ /* |h3| <= 1.51*2^58 */ /* |h7| <= 1.51*2^58 */ - carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + carry3 = (h3 + (crypto_int64) (1L << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; + carry7 = (h7 + (crypto_int64) (1L << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; /* |h3| <= 2^24; from now on fits into int32 unchanged */ /* |h7| <= 2^24; from now on fits into int32 unchanged */ /* |h4| <= 1.52*2^33 */ /* |h8| <= 1.52*2^33 */ - carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + carry4 = (h4 + (crypto_int64) (1L << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry8 = (h8 + (crypto_int64) (1L << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; /* |h4| <= 2^25; from now on fits into int32 unchanged */ /* |h8| <= 2^25; from now on fits into int32 unchanged */ /* |h5| <= 1.01*2^24 */ /* |h9| <= 1.51*2^58 */ - carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + carry9 = (h9 + (crypto_int64) (1L << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; /* |h9| <= 2^24; from now on fits into int32 unchanged */ /* |h0| <= 1.8*2^37 */ - carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry0 = (h0 + (crypto_int64) (1L << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; /* |h0| <= 2^25; from now on fits into int32 unchanged */ /* |h1| <= 1.01*2^24 */ - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; + h[0] = (crypto_int32) h0; + h[1] = (crypto_int32) h1; + h[2] = (crypto_int32) h2; + h[3] = (crypto_int32) h3; + h[4] = (crypto_int32) h4; + h[5] = (crypto_int32) h5; + h[6] = (crypto_int32) h6; + h[7] = (crypto_int32) h7; + h[8] = (crypto_int32) h8; + h[9] = (crypto_int32) h9; } #endif diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c index fc97964b..ecaa8a77 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" #ifndef HAVE_TI_MODE @@ -119,35 +120,35 @@ void fe_sq(fe h,const fe f) crypto_int64 carry8; crypto_int64 carry9; - carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry0 = (h0 + (crypto_int64) (1L << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry4 = (h4 + (crypto_int64) (1L << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; + carry1 = (h1 + (crypto_int64) (1L << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; + carry5 = (h5 + (crypto_int64) (1L << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; + carry2 = (h2 + (crypto_int64) (1L << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; + carry6 = (h6 + (crypto_int64) (1L << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + carry3 = (h3 + (crypto_int64) (1L << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; + carry7 = (h7 + (crypto_int64) (1L << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + carry4 = (h4 + (crypto_int64) (1L << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry8 = (h8 + (crypto_int64) (1L << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + carry9 = (h9 + (crypto_int64) (1L << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry0 = (h0 + (crypto_int64) (1L << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; + h[0] = (crypto_int32) h0; + h[1] = (crypto_int32) h1; + h[2] = (crypto_int32) h2; + h[3] = (crypto_int32) h3; + h[4] = (crypto_int32) h4; + h[5] = (crypto_int32) h5; + h[6] = (crypto_int32) h6; + h[7] = (crypto_int32) h7; + h[8] = (crypto_int32) h8; + h[9] = (crypto_int32) h9; } #endif diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c index 85001795..bdc126b0 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c index c7dcb8f9..3d84b1ef 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #ifndef HAVE_TI_MODE diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c index e6a81da2..98b5a4a2 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* h = f + g diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c index 252adb9b..d7379f00 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* Replace (f,g) with (g,g) if b == 1; diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c index 9c5bf865..0e0bf987 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* h = f diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c index 233f0dcb..c3d077de 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" #include "crypto_uint64.h" diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c index e2a604b6..816d97ea 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" /* diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c index 2078ce52..892e59d2 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* h = -f diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c index 5c5760c0..7812c63f 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" /* diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c index 2b0dc3ba..6757951f 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" #include "crypto_int64.h" /* diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c index 6e26b7df..c1b0ce1c 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* h = f - g diff --git a/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c b/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c index 0a63baf9..64950d3b 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_int32.h" /* Preconditions: diff --git a/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c b/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c index 3a11dbe2..1c2defdd 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c @@ -1,6 +1,5 @@ #include "sc.h" #include "crypto_int64.h" -#include "crypto_uint32.h" #include "crypto_uint64.h" static crypto_uint64 load_3(const unsigned char *in) diff --git a/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c b/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c index 6d6bbf76..07cbe8e3 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c @@ -1,6 +1,5 @@ #include "sc.h" #include "crypto_int64.h" -#include "crypto_uint32.h" #include "crypto_uint64.h" static crypto_uint64 load_3(const unsigned char *in)