diff --git a/src/libsodium/crypto_generichash/crypto_generichash.c b/src/libsodium/crypto_generichash/crypto_generichash.c index 541eec80..9deb0d14 100644 --- a/src/libsodium/crypto_generichash/crypto_generichash.c +++ b/src/libsodium/crypto_generichash/crypto_generichash.c @@ -16,7 +16,7 @@ crypto_generichash_init(crypto_generichash_blake2b_state *state, { return crypto_generichash_blake2b_init(state, key, keylen, outlen); } - + int crypto_generichash_update(crypto_generichash_blake2b_state *state, const unsigned char *in, diff --git a/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c index 6b03dbeb..deb03526 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +++ b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c @@ -60,12 +60,12 @@ checksum_compute(void) { long long i; long long j; - + for (i = 0;i < CHECKSUM_BYTES;++i) { long long mlen = i; long long klen = crypto_onetimeauth_KEYBYTES; long long hlen = crypto_onetimeauth_BYTES; - + for (j = -16;j < 0;++j) h[j] = random(); for (j = -16;j < 0;++j) k[j] = random(); for (j = -16;j < 0;++j) m[j] = random(); @@ -75,14 +75,14 @@ checksum_compute(void) for (j = -16;j < hlen + 16;++j) h2[j] = h[j]; for (j = -16;j < klen + 16;++j) k2[j] = k[j]; for (j = -16;j < mlen + 16;++j) m2[j] = m[j]; - + if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero"; - + for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k"; for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m"; for (j = -16;j < 0;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes before output"; for (j = hlen;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes after output"; - + for (j = -16;j < 0;++j) h[j] = random(); for (j = -16;j < 0;++j) k[j] = random(); for (j = -16;j < 0;++j) m[j] = random(); @@ -92,38 +92,38 @@ checksum_compute(void) for (j = -16;j < hlen + 16;++j) h2[j] = h[j]; for (j = -16;j < klen + 16;++j) k2[j] = k[j]; for (j = -16;j < mlen + 16;++j) m2[j] = m[j]; - + if (crypto_onetimeauth(m2,m2,mlen,k) != 0) return "crypto_onetimeauth returns nonzero"; for (j = 0;j < hlen;++j) if (m2[j] != h[j]) return "crypto_onetimeauth does not handle m overlap"; for (j = 0;j < hlen;++j) m2[j] = m[j]; if (crypto_onetimeauth(k2,m2,mlen,k2) != 0) return "crypto_onetimeauth returns nonzero"; for (j = 0;j < hlen;++j) if (k2[j] != h[j]) return "crypto_onetimeauth does not handle k overlap"; for (j = 0;j < hlen;++j) k2[j] = k[j]; - + if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero"; - + for (j = -16;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth overwrites h"; for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k"; for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m"; - + crypto_hash_sha256(h2,h,hlen); for (j = 0;j < klen;++j) k[j] ^= h2[j % 32]; if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero"; if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero"; - + crypto_hash_sha256(h2,h,hlen); for (j = 0;j < mlen;++j) m[j] ^= h2[j % 32]; m[mlen] = h2[0]; } if (crypto_onetimeauth(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth returns nonzero"; if (crypto_onetimeauth_verify(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth_verify returns nonzero"; - + for (i = 0;i < crypto_onetimeauth_BYTES;++i) { checksum[2 * i] = "0123456789abcdef"[15 & (h[i] >> 4)]; checksum[2 * i + 1] = "0123456789abcdef"[15 & h[i]]; } checksum[2 * i] = 0; - + return NULL; } @@ -131,7 +131,7 @@ crypto_onetimeauth_poly1305_implementation * crypto_onetimeauth_pick_best_implementation(void) { crypto_onetimeauth_poly1305_implementation *implementations[] = { - &crypto_onetimeauth_poly1305_53_implementation, + &crypto_onetimeauth_poly1305_53_implementation, &crypto_onetimeauth_poly1305_ref_implementation, NULL }; @@ -150,6 +150,6 @@ crypto_onetimeauth_pick_best_implementation(void) break; } } while (implementations[++i] != NULL); - + return implementations[i]; } diff --git a/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c b/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c index 276b514d..4a490446 100644 --- a/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +++ b/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c @@ -279,67 +279,67 @@ int fe25519_sqrt_vartime(fe25519 *r, const fe25519 *x, unsigned char parity) void fe25519_invert(fe25519 *r, const fe25519 *x) { - fe25519 z2; - fe25519 z9; - fe25519 z11; - fe25519 z2_5_0; - fe25519 z2_10_0; - fe25519 z2_20_0; - fe25519 z2_50_0; - fe25519 z2_100_0; - fe25519 t0; - fe25519 t1; - int i; + fe25519 z2; + fe25519 z9; + fe25519 z11; + fe25519 z2_5_0; + fe25519 z2_10_0; + fe25519 z2_20_0; + fe25519 z2_50_0; + fe25519 z2_100_0; + fe25519 t0; + fe25519 t1; + int i; - /* 2 */ fe25519_square(&z2,x); - /* 4 */ fe25519_square(&t1,&z2); - /* 8 */ fe25519_square(&t0,&t1); - /* 9 */ fe25519_mul(&z9,&t0,x); - /* 11 */ fe25519_mul(&z11,&z9,&z2); - /* 22 */ fe25519_square(&t0,&z11); - /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t0,&z9); + /* 2 */ fe25519_square(&z2,x); + /* 4 */ fe25519_square(&t1,&z2); + /* 8 */ fe25519_square(&t0,&t1); + /* 9 */ fe25519_mul(&z9,&t0,x); + /* 11 */ fe25519_mul(&z11,&z9,&z2); + /* 22 */ fe25519_square(&t0,&z11); + /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t0,&z9); - /* 2^6 - 2^1 */ fe25519_square(&t0,&z2_5_0); - /* 2^7 - 2^2 */ fe25519_square(&t1,&t0); - /* 2^8 - 2^3 */ fe25519_square(&t0,&t1); - /* 2^9 - 2^4 */ fe25519_square(&t1,&t0); - /* 2^10 - 2^5 */ fe25519_square(&t0,&t1); - /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t0,&z2_5_0); + /* 2^6 - 2^1 */ fe25519_square(&t0,&z2_5_0); + /* 2^7 - 2^2 */ fe25519_square(&t1,&t0); + /* 2^8 - 2^3 */ fe25519_square(&t0,&t1); + /* 2^9 - 2^4 */ fe25519_square(&t1,&t0); + /* 2^10 - 2^5 */ fe25519_square(&t0,&t1); + /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t0,&z2_5_0); - /* 2^11 - 2^1 */ fe25519_square(&t0,&z2_10_0); - /* 2^12 - 2^2 */ fe25519_square(&t1,&t0); - /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } - /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t1,&z2_10_0); + /* 2^11 - 2^1 */ fe25519_square(&t0,&z2_10_0); + /* 2^12 - 2^2 */ fe25519_square(&t1,&t0); + /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } + /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t1,&z2_10_0); - /* 2^21 - 2^1 */ fe25519_square(&t0,&z2_20_0); - /* 2^22 - 2^2 */ fe25519_square(&t1,&t0); - /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } - /* 2^40 - 2^0 */ fe25519_mul(&t0,&t1,&z2_20_0); + /* 2^21 - 2^1 */ fe25519_square(&t0,&z2_20_0); + /* 2^22 - 2^2 */ fe25519_square(&t1,&t0); + /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } + /* 2^40 - 2^0 */ fe25519_mul(&t0,&t1,&z2_20_0); - /* 2^41 - 2^1 */ fe25519_square(&t1,&t0); - /* 2^42 - 2^2 */ fe25519_square(&t0,&t1); - /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } - /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t0,&z2_10_0); + /* 2^41 - 2^1 */ fe25519_square(&t1,&t0); + /* 2^42 - 2^2 */ fe25519_square(&t0,&t1); + /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } + /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t0,&z2_10_0); - /* 2^51 - 2^1 */ fe25519_square(&t0,&z2_50_0); - /* 2^52 - 2^2 */ fe25519_square(&t1,&t0); - /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } - /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t1,&z2_50_0); + /* 2^51 - 2^1 */ fe25519_square(&t0,&z2_50_0); + /* 2^52 - 2^2 */ fe25519_square(&t1,&t0); + /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } + /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t1,&z2_50_0); - /* 2^101 - 2^1 */ fe25519_square(&t1,&z2_100_0); - /* 2^102 - 2^2 */ fe25519_square(&t0,&t1); - /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } - /* 2^200 - 2^0 */ fe25519_mul(&t1,&t0,&z2_100_0); + /* 2^101 - 2^1 */ fe25519_square(&t1,&z2_100_0); + /* 2^102 - 2^2 */ fe25519_square(&t0,&t1); + /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } + /* 2^200 - 2^0 */ fe25519_mul(&t1,&t0,&z2_100_0); - /* 2^201 - 2^1 */ fe25519_square(&t0,&t1); - /* 2^202 - 2^2 */ fe25519_square(&t1,&t0); - /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } - /* 2^250 - 2^0 */ fe25519_mul(&t0,&t1,&z2_50_0); + /* 2^201 - 2^1 */ fe25519_square(&t0,&t1); + /* 2^202 - 2^2 */ fe25519_square(&t1,&t0); + /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } + /* 2^250 - 2^0 */ fe25519_mul(&t0,&t1,&z2_50_0); - /* 2^251 - 2^1 */ fe25519_square(&t1,&t0); - /* 2^252 - 2^2 */ fe25519_square(&t0,&t1); - /* 2^253 - 2^3 */ fe25519_square(&t1,&t0); - /* 2^254 - 2^4 */ fe25519_square(&t0,&t1); - /* 2^255 - 2^5 */ fe25519_square(&t1,&t0); - /* 2^255 - 21 */ fe25519_mul(r,&t1,&z11); + /* 2^251 - 2^1 */ fe25519_square(&t1,&t0); + /* 2^252 - 2^2 */ fe25519_square(&t0,&t1); + /* 2^253 - 2^3 */ fe25519_square(&t1,&t0); + /* 2^254 - 2^4 */ fe25519_square(&t0,&t1); + /* 2^255 - 2^5 */ fe25519_square(&t1,&t0); + /* 2^255 - 21 */ fe25519_mul(r,&t1,&z11); } diff --git a/src/libsodium/crypto_stream/aes128ctr/portable/common.h b/src/libsodium/crypto_stream/aes128ctr/portable/common.h index e6e60dc2..aa956eb8 100644 --- a/src/libsodium/crypto_stream/aes128ctr/portable/common.h +++ b/src/libsodium/crypto_stream/aes128ctr/portable/common.h @@ -448,26 +448,26 @@ void store64_littleendian(unsigned char *x,uint64 u); #define bitslice(x0, x1, x2, x3, x4, x5, x6, x7, t) \ - swapmove(x0, x1, 1, BS0, t);\ - swapmove(x2, x3, 1, BS0, t);\ - swapmove(x4, x5, 1, BS0, t);\ - swapmove(x6, x7, 1, BS0, t);\ - ;\ - swapmove(x0, x2, 2, BS1, t);\ - swapmove(x1, x3, 2, BS1, t);\ - swapmove(x4, x6, 2, BS1, t);\ - swapmove(x5, x7, 2, BS1, t);\ - ;\ - swapmove(x0, x4, 4, BS2, t);\ - swapmove(x1, x5, 4, BS2, t);\ - swapmove(x2, x6, 4, BS2, t);\ - swapmove(x3, x7, 4, BS2, t);\ + swapmove(x0, x1, 1, BS0, t);\ + swapmove(x2, x3, 1, BS0, t);\ + swapmove(x4, x5, 1, BS0, t);\ + swapmove(x6, x7, 1, BS0, t);\ + ;\ + swapmove(x0, x2, 2, BS1, t);\ + swapmove(x1, x3, 2, BS1, t);\ + swapmove(x4, x6, 2, BS1, t);\ + swapmove(x5, x7, 2, BS1, t);\ + ;\ + swapmove(x0, x4, 4, BS2, t);\ + swapmove(x1, x5, 4, BS2, t);\ + swapmove(x2, x6, 4, BS2, t);\ + swapmove(x3, x7, 4, BS2, t);\ #define swapmove(a, b, n, m, t) \ - copy2(&t, &b);\ + copy2(&t, &b);\ rshift64_littleendian(&t, n);\ - xor2(&t, &a);\ + xor2(&t, &a);\ and2(&t, &m);\ xor2(&a, &t);\ lshift64_littleendian(&t, n);\ @@ -480,21 +480,21 @@ void store64_littleendian(unsigned char *x,uint64 u); /* Macros used for encryption (and decryption) */ #define shiftrows(x0, x1, x2, x3, x4, x5, x6, x7, i, M, bskey) \ - xor2(&x0, (int128 *)(bskey + 128*(i-1) + 0));\ + xor2(&x0, (int128 *)(bskey + 128*(i-1) + 0));\ shufb(&x0, M);\ - xor2(&x1, (int128 *)(bskey + 128*(i-1) + 16));\ + xor2(&x1, (int128 *)(bskey + 128*(i-1) + 16));\ shufb(&x1, M);\ - xor2(&x2, (int128 *)(bskey + 128*(i-1) + 32));\ + xor2(&x2, (int128 *)(bskey + 128*(i-1) + 32));\ shufb(&x2, M);\ - xor2(&x3, (int128 *)(bskey + 128*(i-1) + 48));\ + xor2(&x3, (int128 *)(bskey + 128*(i-1) + 48));\ shufb(&x3, M);\ - xor2(&x4, (int128 *)(bskey + 128*(i-1) + 64));\ + xor2(&x4, (int128 *)(bskey + 128*(i-1) + 64));\ shufb(&x4, M);\ - xor2(&x5, (int128 *)(bskey + 128*(i-1) + 80));\ + xor2(&x5, (int128 *)(bskey + 128*(i-1) + 80));\ shufb(&x5, M);\ - xor2(&x6, (int128 *)(bskey + 128*(i-1) + 96));\ + xor2(&x6, (int128 *)(bskey + 128*(i-1) + 96));\ shufb(&x6, M);\ - xor2(&x7, (int128 *)(bskey + 128*(i-1) + 112));\ + xor2(&x7, (int128 *)(bskey + 128*(i-1) + 112));\ shufb(&x7, M);\ @@ -507,28 +507,28 @@ void store64_littleendian(unsigned char *x,uint64 u); shufd(&t5, &x5, 0x93);\ shufd(&t6, &x6, 0x93);\ shufd(&t7, &x7, 0x93);\ - ;\ - xor2(&x0, &t0);\ - xor2(&x1, &t1);\ - xor2(&x2, &t2);\ - xor2(&x3, &t3);\ - xor2(&x4, &t4);\ - xor2(&x5, &t5);\ - xor2(&x6, &t6);\ - xor2(&x7, &t7);\ - ;\ - xor2(&t0, &x7);\ - xor2(&t1, &x0);\ - xor2(&t2, &x1);\ - xor2(&t1, &x7);\ - xor2(&t3, &x2);\ - xor2(&t4, &x3);\ - xor2(&t5, &x4);\ - xor2(&t3, &x7);\ - xor2(&t6, &x5);\ - xor2(&t7, &x6);\ - xor2(&t4, &x7);\ - ;\ + ;\ + xor2(&x0, &t0);\ + xor2(&x1, &t1);\ + xor2(&x2, &t2);\ + xor2(&x3, &t3);\ + xor2(&x4, &t4);\ + xor2(&x5, &t5);\ + xor2(&x6, &t6);\ + xor2(&x7, &t7);\ + ;\ + xor2(&t0, &x7);\ + xor2(&t1, &x0);\ + xor2(&t2, &x1);\ + xor2(&t1, &x7);\ + xor2(&t3, &x2);\ + xor2(&t4, &x3);\ + xor2(&t5, &x4);\ + xor2(&t3, &x7);\ + xor2(&t6, &x5);\ + xor2(&t7, &x6);\ + xor2(&t4, &x7);\ + ;\ shufd(&x0, &x0, 0x4e);\ shufd(&x1, &x1, 0x4e);\ shufd(&x2, &x2, 0x4e);\ @@ -537,229 +537,229 @@ void store64_littleendian(unsigned char *x,uint64 u); shufd(&x5, &x5, 0x4e);\ shufd(&x6, &x6, 0x4e);\ shufd(&x7, &x7, 0x4e);\ - ;\ - xor2(&t0, &x0);\ - xor2(&t1, &x1);\ - xor2(&t2, &x2);\ - xor2(&t3, &x3);\ - xor2(&t4, &x4);\ - xor2(&t5, &x5);\ - xor2(&t6, &x6);\ - xor2(&t7, &x7);\ + ;\ + xor2(&t0, &x0);\ + xor2(&t1, &x1);\ + xor2(&t2, &x2);\ + xor2(&t3, &x3);\ + xor2(&t4, &x4);\ + xor2(&t5, &x5);\ + xor2(&t6, &x6);\ + xor2(&t7, &x7);\ #define aesround(i, b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7, bskey) \ - shiftrows(b0, b1, b2, b3, b4, b5, b6, b7, i, SR, bskey);\ - sbox(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7);\ - mixcolumns(b0, b1, b4, b6, b3, b7, b2, b5, t0, t1, t2, t3, t4, t5, t6, t7);\ + shiftrows(b0, b1, b2, b3, b4, b5, b6, b7, i, SR, bskey);\ + sbox(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7);\ + mixcolumns(b0, b1, b4, b6, b3, b7, b2, b5, t0, t1, t2, t3, t4, t5, t6, t7);\ #define lastround(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7, bskey) \ - shiftrows(b0, b1, b2, b3, b4, b5, b6, b7, 10, SRM0, bskey);\ - sbox(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7);\ - xor2(&b0,(int128 *)(bskey + 128*10));\ - xor2(&b1,(int128 *)(bskey + 128*10+16));\ - xor2(&b4,(int128 *)(bskey + 128*10+32));\ - xor2(&b6,(int128 *)(bskey + 128*10+48));\ - xor2(&b3,(int128 *)(bskey + 128*10+64));\ - xor2(&b7,(int128 *)(bskey + 128*10+80));\ - xor2(&b2,(int128 *)(bskey + 128*10+96));\ - xor2(&b5,(int128 *)(bskey + 128*10+112));\ + shiftrows(b0, b1, b2, b3, b4, b5, b6, b7, 10, SRM0, bskey);\ + sbox(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, t4, t5, t6, t7);\ + xor2(&b0,(int128 *)(bskey + 128*10));\ + xor2(&b1,(int128 *)(bskey + 128*10+16));\ + xor2(&b4,(int128 *)(bskey + 128*10+32));\ + xor2(&b6,(int128 *)(bskey + 128*10+48));\ + xor2(&b3,(int128 *)(bskey + 128*10+64));\ + xor2(&b7,(int128 *)(bskey + 128*10+80));\ + xor2(&b2,(int128 *)(bskey + 128*10+96));\ + xor2(&b5,(int128 *)(bskey + 128*10+112));\ #define sbox(b0, b1, b2, b3, b4, b5, b6, b7, t0, t1, t2, t3, s0, s1, s2, s3) \ - InBasisChange(b0, b1, b2, b3, b4, b5, b6, b7); \ - Inv_GF256(b6, b5, b0, b3, b7, b1, b4, b2, t0, t1, t2, t3, s0, s1, s2, s3); \ - OutBasisChange(b7, b1, b4, b2, b6, b5, b0, b3); \ + InBasisChange(b0, b1, b2, b3, b4, b5, b6, b7); \ + Inv_GF256(b6, b5, b0, b3, b7, b1, b4, b2, t0, t1, t2, t3, s0, s1, s2, s3); \ + OutBasisChange(b7, b1, b4, b2, b6, b5, b0, b3); \ #define InBasisChange(b0, b1, b2, b3, b4, b5, b6, b7) \ - xor2(&b5, &b6);\ - xor2(&b2, &b1);\ - xor2(&b5, &b0);\ - xor2(&b6, &b2);\ - xor2(&b3, &b0);\ - ;\ - xor2(&b6, &b3);\ - xor2(&b3, &b7);\ - xor2(&b3, &b4);\ - xor2(&b7, &b5);\ - xor2(&b3, &b1);\ - ;\ - xor2(&b4, &b5);\ - xor2(&b2, &b7);\ - xor2(&b1, &b5);\ + xor2(&b5, &b6);\ + xor2(&b2, &b1);\ + xor2(&b5, &b0);\ + xor2(&b6, &b2);\ + xor2(&b3, &b0);\ + ;\ + xor2(&b6, &b3);\ + xor2(&b3, &b7);\ + xor2(&b3, &b4);\ + xor2(&b7, &b5);\ + xor2(&b3, &b1);\ + ;\ + xor2(&b4, &b5);\ + xor2(&b2, &b7);\ + xor2(&b1, &b5);\ #define OutBasisChange(b0, b1, b2, b3, b4, b5, b6, b7) \ - xor2(&b0, &b6);\ - xor2(&b1, &b4);\ - xor2(&b2, &b0);\ - xor2(&b4, &b6);\ - xor2(&b6, &b1);\ - ;\ - xor2(&b1, &b5);\ - xor2(&b5, &b3);\ - xor2(&b2, &b5);\ - xor2(&b3, &b7);\ - xor2(&b7, &b5);\ - ;\ - xor2(&b4, &b7);\ + xor2(&b0, &b6);\ + xor2(&b1, &b4);\ + xor2(&b2, &b0);\ + xor2(&b4, &b6);\ + xor2(&b6, &b1);\ + ;\ + xor2(&b1, &b5);\ + xor2(&b5, &b3);\ + xor2(&b2, &b5);\ + xor2(&b3, &b7);\ + xor2(&b7, &b5);\ + ;\ + xor2(&b4, &b7);\ #define Mul_GF4(x0, x1, y0, y1, t0) \ - copy2(&t0, &y0);\ - xor2(&t0, &y1);\ - and2(&t0, &x0);\ - xor2(&x0, &x1);\ - and2(&x0, &y1);\ - and2(&x1, &y0);\ - xor2(&x0, &x1);\ - xor2(&x1, &t0);\ + copy2(&t0, &y0);\ + xor2(&t0, &y1);\ + and2(&t0, &x0);\ + xor2(&x0, &x1);\ + and2(&x0, &y1);\ + and2(&x1, &y0);\ + xor2(&x0, &x1);\ + xor2(&x1, &t0);\ #define Mul_GF4_N(x0, x1, y0, y1, t0) \ - copy2(&t0, &y0);\ - xor2(&t0, &y1);\ - and2(&t0, &x0);\ - xor2(&x0, &x1);\ - and2(&x0, &y1);\ - and2(&x1, &y0);\ - xor2(&x1, &x0);\ - xor2(&x0, &t0);\ + copy2(&t0, &y0);\ + xor2(&t0, &y1);\ + and2(&t0, &x0);\ + xor2(&x0, &x1);\ + and2(&x0, &y1);\ + and2(&x1, &y0);\ + xor2(&x1, &x0);\ + xor2(&x0, &t0);\ #define Mul_GF4_2(x0, x1, x2, x3, y0, y1, t0, t1) \ - copy2(&t0, = y0);\ - xor2(&t0, &y1);\ - copy2(&t1, &t0);\ - and2(&t0, &x0);\ - and2(&t1, &x2);\ - xor2(&x0, &x1);\ - xor2(&x2, &x3);\ - and2(&x0, &y1);\ - and2(&x2, &y1);\ - and2(&x1, &y0);\ - and2(&x3, &y0);\ - xor2(&x0, &x1);\ - xor2(&x2, &x3);\ - xor2(&x1, &t0);\ - xor2(&x3, &t1);\ + copy2(&t0, = y0);\ + xor2(&t0, &y1);\ + copy2(&t1, &t0);\ + and2(&t0, &x0);\ + and2(&t1, &x2);\ + xor2(&x0, &x1);\ + xor2(&x2, &x3);\ + and2(&x0, &y1);\ + and2(&x2, &y1);\ + and2(&x1, &y0);\ + and2(&x3, &y0);\ + xor2(&x0, &x1);\ + xor2(&x2, &x3);\ + xor2(&x1, &t0);\ + xor2(&x3, &t1);\ #define Mul_GF16(x0, x1, x2, x3, y0, y1, y2, y3, t0, t1, t2, t3) \ - copy2(&t0, &x0);\ - copy2(&t1, &x1);\ - Mul_GF4(x0, x1, y0, y1, t2);\ - xor2(&t0, &x2);\ - xor2(&t1, &x3);\ - xor2(&y0, &y2);\ - xor2(&y1, &y3);\ - Mul_GF4_N(t0, t1, y0, y1, t2);\ - Mul_GF4(x2, x3, y2, y3, t3);\ - ;\ - xor2(&x0, &t0);\ - xor2(&x2, &t0);\ - xor2(&x1, &t1);\ - xor2(&x3, &t1);\ + copy2(&t0, &x0);\ + copy2(&t1, &x1);\ + Mul_GF4(x0, x1, y0, y1, t2);\ + xor2(&t0, &x2);\ + xor2(&t1, &x3);\ + xor2(&y0, &y2);\ + xor2(&y1, &y3);\ + Mul_GF4_N(t0, t1, y0, y1, t2);\ + Mul_GF4(x2, x3, y2, y3, t3);\ + ;\ + xor2(&x0, &t0);\ + xor2(&x2, &t0);\ + xor2(&x1, &t1);\ + xor2(&x3, &t1);\ #define Mul_GF16_2(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, t0, t1, t2, t3) \ - copy2(&t0, &x0);\ - copy2(&t1, &x1);\ - Mul_GF4(x0, x1, y0, y1, t2);\ - xor2(&t0, &x2);\ - xor2(&t1, &x3);\ - xor2(&y0, &y2);\ - xor2(&y1, &y3);\ - Mul_GF4_N(t0, t1, y0, y1, t3);\ - Mul_GF4(x2, x3, y2, y3, t2);\ - ;\ - xor2(&x0, &t0);\ - xor2(&x2, &t0);\ - xor2(&x1, &t1);\ - xor2(&x3, &t1);\ - ;\ - copy2(&t0, &x4);\ - copy2(&t1, &x5);\ - xor2(&t0, &x6);\ - xor2(&t1, &x7);\ - Mul_GF4_N(t0, t1, y0, y1, t3);\ - Mul_GF4(x6, x7, y2, y3, t2);\ - xor2(&y0, &y2);\ - xor2(&y1, &y3);\ - Mul_GF4(x4, x5, y0, y1, t3);\ - ;\ - xor2(&x4, &t0);\ - xor2(&x6, &t0);\ - xor2(&x5, &t1);\ - xor2(&x7, &t1);\ + copy2(&t0, &x0);\ + copy2(&t1, &x1);\ + Mul_GF4(x0, x1, y0, y1, t2);\ + xor2(&t0, &x2);\ + xor2(&t1, &x3);\ + xor2(&y0, &y2);\ + xor2(&y1, &y3);\ + Mul_GF4_N(t0, t1, y0, y1, t3);\ + Mul_GF4(x2, x3, y2, y3, t2);\ + ;\ + xor2(&x0, &t0);\ + xor2(&x2, &t0);\ + xor2(&x1, &t1);\ + xor2(&x3, &t1);\ + ;\ + copy2(&t0, &x4);\ + copy2(&t1, &x5);\ + xor2(&t0, &x6);\ + xor2(&t1, &x7);\ + Mul_GF4_N(t0, t1, y0, y1, t3);\ + Mul_GF4(x6, x7, y2, y3, t2);\ + xor2(&y0, &y2);\ + xor2(&y1, &y3);\ + Mul_GF4(x4, x5, y0, y1, t3);\ + ;\ + xor2(&x4, &t0);\ + xor2(&x6, &t0);\ + xor2(&x5, &t1);\ + xor2(&x7, &t1);\ #define Inv_GF16(x0, x1, x2, x3, t0, t1, t2, t3) \ - copy2(&t0, &x1);\ - copy2(&t1, &x0);\ - and2(&t0, &x3);\ - or2(&t1, &x2);\ - copy2(&t2, &x1);\ - copy2(&t3, &x0);\ - or2(&t2, &x2);\ - or2(&t3, &x3);\ - xor2(&t2, &t3);\ - ;\ - xor2(&t0, &t2);\ - xor2(&t1, &t2);\ - ;\ - Mul_GF4_2(x0, x1, x2, x3, t1, t0, t2, t3);\ + copy2(&t0, &x1);\ + copy2(&t1, &x0);\ + and2(&t0, &x3);\ + or2(&t1, &x2);\ + copy2(&t2, &x1);\ + copy2(&t3, &x0);\ + or2(&t2, &x2);\ + or2(&t3, &x3);\ + xor2(&t2, &t3);\ + ;\ + xor2(&t0, &t2);\ + xor2(&t1, &t2);\ + ;\ + Mul_GF4_2(x0, x1, x2, x3, t1, t0, t2, t3);\ #define Inv_GF256(x0, x1, x2, x3, x4, x5, x6, x7, t0, t1, t2, t3, s0, s1, s2, s3) \ - copy2(&t3, &x4);\ - copy2(&t2, &x5);\ - copy2(&t1, &x1);\ - copy2(&s1, &x7);\ - copy2(&s0, &x0);\ - ;\ - xor2(&t3, &x6);\ - xor2(&t2, &x7);\ - xor2(&t1, &x3);\ - xor2(&s1, &x6);\ - xor2(&s0, &x2);\ - ;\ - copy2(&s2, &t3);\ - copy2(&t0, &t2);\ - copy2(&s3, &t3);\ - ;\ - or2(&t2, &t1);\ - or2(&t3, &s0);\ - xor2(&s3, &t0);\ - and2(&s2, &s0);\ - and2(&t0, &t1);\ - xor2(&s0, &t1);\ - and2(&s3, &s0);\ - copy2(&s0, &x3);\ - xor2(&s0, &x2);\ - and2(&s1, &s0);\ - xor2(&t3, &s1);\ - xor2(&t2, &s1);\ - copy2(&s1, &x4);\ - xor2(&s1, &x5);\ - copy2(&s0, &x1);\ - copy2(&t1, &s1);\ - xor2(&s0, &x0);\ - or2(&t1, &s0);\ - and2(&s1, &s0);\ - xor2(&t0, &s1);\ - xor2(&t3, &s3);\ - xor2(&t2, &s2);\ - xor2(&t1, &s3);\ - xor2(&t0, &s2);\ - xor2(&t1, &s2);\ - copy2(&s0, &x7);\ - copy2(&s1, &x6);\ - copy2(&s2, &x5);\ - copy2(&s3, &x4);\ - and2(&s0, &x3);\ - and2(&s1, &x2);\ - and2(&s2, &x1);\ - or2(&s3, &x0);\ - xor2(&t3, &s0);\ - xor2(&t2, &s1);\ - xor2(&t1, &s2);\ - xor2(&t0, &s3);\ + copy2(&t3, &x4);\ + copy2(&t2, &x5);\ + copy2(&t1, &x1);\ + copy2(&s1, &x7);\ + copy2(&s0, &x0);\ + ;\ + xor2(&t3, &x6);\ + xor2(&t2, &x7);\ + xor2(&t1, &x3);\ + xor2(&s1, &x6);\ + xor2(&s0, &x2);\ + ;\ + copy2(&s2, &t3);\ + copy2(&t0, &t2);\ + copy2(&s3, &t3);\ + ;\ + or2(&t2, &t1);\ + or2(&t3, &s0);\ + xor2(&s3, &t0);\ + and2(&s2, &s0);\ + and2(&t0, &t1);\ + xor2(&s0, &t1);\ + and2(&s3, &s0);\ + copy2(&s0, &x3);\ + xor2(&s0, &x2);\ + and2(&s1, &s0);\ + xor2(&t3, &s1);\ + xor2(&t2, &s1);\ + copy2(&s1, &x4);\ + xor2(&s1, &x5);\ + copy2(&s0, &x1);\ + copy2(&t1, &s1);\ + xor2(&s0, &x0);\ + or2(&t1, &s0);\ + and2(&s1, &s0);\ + xor2(&t0, &s1);\ + xor2(&t3, &s3);\ + xor2(&t2, &s2);\ + xor2(&t1, &s3);\ + xor2(&t0, &s2);\ + xor2(&t1, &s2);\ + copy2(&s0, &x7);\ + copy2(&s1, &x6);\ + copy2(&s2, &x5);\ + copy2(&s3, &x4);\ + and2(&s0, &x3);\ + and2(&s1, &x2);\ + and2(&s2, &x1);\ + or2(&s3, &x0);\ + xor2(&t3, &s0);\ + xor2(&t2, &s1);\ + xor2(&t1, &s2);\ + xor2(&t0, &s3);\ ;\ copy2(&s0, &t3);\ xor2(&s0, &t2);\ diff --git a/src/libsodium/include/sodium/core.h b/src/libsodium/include/sodium/core.h index 339c8e7b..745acdb9 100644 --- a/src/libsodium/include/sodium/core.h +++ b/src/libsodium/include/sodium/core.h @@ -7,7 +7,7 @@ extern "C" { #endif int sodium_init(void); - + #ifdef __cplusplus } #endif diff --git a/src/libsodium/include/sodium/crypto_hash.h b/src/libsodium/include/sodium/crypto_hash.h index bfcc6941..eef28d8c 100644 --- a/src/libsodium/include/sodium/crypto_hash.h +++ b/src/libsodium/include/sodium/crypto_hash.h @@ -12,7 +12,7 @@ extern "C" { int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen); - + #ifdef __cplusplus } #endif diff --git a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h index 2d650cb9..02d93db2 100644 --- a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h +++ b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h @@ -11,12 +11,12 @@ extern struct crypto_onetimeauth_poly1305_implementation crypto_onetimeauth_poly1305_53_implementation; const char *crypto_onetimeauth_poly1305_53_implementation_name(void); - + int crypto_onetimeauth_poly1305_53(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k); - + int crypto_onetimeauth_poly1305_53_verify(const unsigned char *h, const unsigned char *in, unsigned long long inlen, diff --git a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_ref.h b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_ref.h index e8936376..1bc1d817 100644 --- a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_ref.h +++ b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_ref.h @@ -11,7 +11,7 @@ extern struct crypto_onetimeauth_poly1305_implementation crypto_onetimeauth_poly1305_ref_implementation; const char *crypto_onetimeauth_poly1305_ref_implementation_name(void); - + int crypto_onetimeauth_poly1305_ref(unsigned char *out, const unsigned char *in, unsigned long long inlen, diff --git a/src/libsodium/include/sodium/crypto_scalarmult.h b/src/libsodium/include/sodium/crypto_scalarmult.h index c09b64b0..3df0b27f 100644 --- a/src/libsodium/include/sodium/crypto_scalarmult.h +++ b/src/libsodium/include/sodium/crypto_scalarmult.h @@ -19,5 +19,5 @@ int crypto_scalarmult(unsigned char *q, const unsigned char *n, #ifdef __cplusplus } #endif - + #endif diff --git a/src/libsodium/include/sodium/crypto_secretbox.h b/src/libsodium/include/sodium/crypto_secretbox.h index 147be6ee..23ba411c 100644 --- a/src/libsodium/include/sodium/crypto_secretbox.h +++ b/src/libsodium/include/sodium/crypto_secretbox.h @@ -24,5 +24,5 @@ int crypto_secretbox_open(unsigned char *m, const unsigned char *c, #ifdef __cplusplus } #endif - + #endif diff --git a/src/libsodium/include/sodium/crypto_sign.h b/src/libsodium/include/sodium/crypto_sign.h index c3083781..4e03e178 100644 --- a/src/libsodium/include/sodium/crypto_sign.h +++ b/src/libsodium/include/sodium/crypto_sign.h @@ -28,5 +28,5 @@ int crypto_sign_open(unsigned char *m, unsigned long long *mlen, #ifdef __cplusplus } #endif - + #endif diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index ff467a2f..2a440d6d 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -64,7 +64,7 @@ sodium_hrtime(void) tv.tv_usec = ((int) tb.millitm) * 1000; ret = 0; #else - ret = gettimeofday(&tv, NULL); + ret = gettimeofday(&tv, NULL); #endif assert(ret == 0); if (ret == 0) { diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index 728c9294..5731ecc5 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -160,7 +160,7 @@ randombytes_sysrandom_buf(void * const buf, const size_t size) #ifdef ULONG_LONG_MAX assert(size <= ULONG_LONG_MAX); #endif -#ifndef _WIN32 +#ifndef _WIN32 if (safe_read(stream.random_data_source_fd, buf, size) != (ssize_t) size) { abort(); } diff --git a/test/default/box7.c b/test/default/box7.c index 0cf5cffc..1e146767 100644 --- a/test/default/box7.c +++ b/test/default/box7.c @@ -26,9 +26,9 @@ int main(void) if (crypto_box_open(m2,c,mlen + crypto_box_ZEROBYTES,n,alicepk,bobsk) == 0) { for (i = 0;i < mlen + crypto_box_ZEROBYTES;++i) if (m2[i] != m[i]) { - printf("bad decryption\n"); - break; - } + printf("bad decryption\n"); + break; + } } else { printf("ciphertext fails verification\n"); } diff --git a/test/default/box8.c b/test/default/box8.c index d753b7ba..5ecc51aa 100644 --- a/test/default/box8.c +++ b/test/default/box8.c @@ -32,9 +32,9 @@ int main(void) if (crypto_box_open(m2,c,mlen + crypto_box_ZEROBYTES,n,alicepk,bobsk) == 0) { for (i = 0;i < mlen + crypto_box_ZEROBYTES;++i) if (m2[i] != m[i]) { - printf("forgery\n"); - return 100; - } + printf("forgery\n"); + return 100; + } } else { ++caught; } diff --git a/test/default/cmptest.h b/test/default/cmptest.h index 45dbc5da..8f393073 100644 --- a/test/default/cmptest.h +++ b/test/default/cmptest.h @@ -27,7 +27,7 @@ int main(void) xmain(); rewind(fp_res); if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) { - perror("fopen(" TEST_NAME_OUT ")"); + perror("fopen(" TEST_NAME_OUT ")"); return 99; } do { diff --git a/test/default/secretbox7.c b/test/default/secretbox7.c index 5dd8b821..9c8e0c55 100644 --- a/test/default/secretbox7.c +++ b/test/default/secretbox7.c @@ -22,9 +22,9 @@ int main(void) if (crypto_secretbox_open(m2,c,mlen + crypto_secretbox_ZEROBYTES,n,k) == 0) { for (i = 0;i < mlen + crypto_secretbox_ZEROBYTES;++i) if (m2[i] != m[i]) { - printf("bad decryption\n"); - break; - } + printf("bad decryption\n"); + break; + } } else { printf("ciphertext fails verification\n"); } diff --git a/test/default/secretbox8.c b/test/default/secretbox8.c index c3424b6c..8b8db3ee 100644 --- a/test/default/secretbox8.c +++ b/test/default/secretbox8.c @@ -27,9 +27,9 @@ int main(void) if (crypto_secretbox_open(m2,c,mlen + crypto_secretbox_ZEROBYTES,n,k) == 0) { for (i = 0;i < mlen + crypto_secretbox_ZEROBYTES;++i) if (m2[i] != m[i]) { - printf("forgery\n"); - return 100; - } + printf("forgery\n"); + return 100; + } } else { ++caught; }