Browse Source

NTRU Prime: avoid unsigned unary negation

tags/v0.0.1
John M. Schanck 4 years ago
committed by Kris Kwiatkowski
parent
commit
4883bb44c0
9 changed files with 9 additions and 9 deletions
  1. +1
    -1
      crypto_kem/sntrup653/avx2/crypto_core_invsntrup653.c
  2. +1
    -1
      crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c
  3. +1
    -1
      crypto_kem/sntrup653/clean/crypto_core_wforcesntrup653.c
  4. +1
    -1
      crypto_kem/sntrup761/avx2/crypto_core_invsntrup761.c
  5. +1
    -1
      crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c
  6. +1
    -1
      crypto_kem/sntrup761/clean/crypto_core_wforcesntrup761.c
  7. +1
    -1
      crypto_kem/sntrup857/avx2/crypto_core_invsntrup857.c
  8. +1
    -1
      crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c
  9. +1
    -1
      crypto_kem/sntrup857/clean/crypto_core_wforcesntrup857.c

+ 1
- 1
crypto_kem/sntrup653/avx2/crypto_core_invsntrup653.c View File

@@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup653/clean/crypto_core_inv3sntrup653.c View File

@@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup653/clean/crypto_core_wforcesntrup653.c View File

@@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup761/avx2/crypto_core_invsntrup761.c View File

@@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup761/clean/crypto_core_inv3sntrup761.c View File

@@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup761/clean/crypto_core_wforcesntrup761.c View File

@@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup857/avx2/crypto_core_invsntrup857.c View File

@@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup857/clean/crypto_core_inv3sntrup857.c View File

@@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


+ 1
- 1
crypto_kem/sntrup857/clean/crypto_core_wforcesntrup857.c View File

@@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}


Loading…
Cancel
Save