Browse Source

add duplicate consistency checks and remove some comments

master
Matthias J. Kannwischer 5 years ago
parent
commit
3d67b4c1c2
8 changed files with 171 additions and 52 deletions
  1. +0
    -13
      crypto_kem/newhope1024cca/clean/poly.c
  2. +0
    -13
      crypto_kem/newhope1024cpa/clean/poly.c
  3. +0
    -13
      crypto_kem/newhope512cca/clean/poly.c
  4. +0
    -13
      crypto_kem/newhope512cpa/clean/poly.c
  5. +43
    -0
      test/duplicate_consistency/newhope1024cca_clean.yml
  6. +42
    -0
      test/duplicate_consistency/newhope1024cpa_clean.yml
  7. +44
    -0
      test/duplicate_consistency/newhope512cca_clean.yml
  8. +42
    -0
      test/duplicate_consistency/newhope512cpa_clean.yml

+ 0
- 13
crypto_kem/newhope1024cca/clean/poly.c View File

@@ -256,7 +256,6 @@ static unsigned char hw(unsigned char a) {
**************************************************/
void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_sample(poly *r, const unsigned char *seed, unsigned char nonce) {
unsigned char buf[128], a, b;
// uint32_t t, d, a, b, c;
int i, j;

unsigned char extseed[NEWHOPE_SYMBYTES + 2];
@@ -273,18 +272,6 @@ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_sample(poly *r, const unsigned char *seed
a = buf[2 * j];
b = buf[2 * j + 1];
r->coeffs[64 * i + j] = hw(a) + NEWHOPE_Q - hw(b);
/*
t = buf[j] | ((uint32_t)buf[j+1] << 8) | ((uint32_t)buf[j+2] << 16) | ((uint32_t)buf[j+3] << 24);
d = 0;
for(k=0;k<8;k++)
d += (t >> k) & 0x01010101;
a = d & 0xff;
b = ((d >> 8) & 0xff);
c = ((d >> 16) & 0xff);
d >>= 24;
r->coeffs[64*i+j/2] = a + NEWHOPE_Q - b;
r->coeffs[64*i+j/2+1] = c + NEWHOPE_Q - d;
*/
}
}
}


+ 0
- 13
crypto_kem/newhope1024cpa/clean/poly.c View File

@@ -256,7 +256,6 @@ static unsigned char hw(unsigned char a) {
**************************************************/
void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_sample(poly *r, const unsigned char *seed, unsigned char nonce) {
unsigned char buf[128], a, b;
// uint32_t t, d, a, b, c;
int i, j;

unsigned char extseed[NEWHOPE_SYMBYTES + 2];
@@ -273,18 +272,6 @@ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_sample(poly *r, const unsigned char *seed
a = buf[2 * j];
b = buf[2 * j + 1];
r->coeffs[64 * i + j] = hw(a) + NEWHOPE_Q - hw(b);
/*
t = buf[j] | ((uint32_t)buf[j+1] << 8) | ((uint32_t)buf[j+2] << 16) | ((uint32_t)buf[j+3] << 24);
d = 0;
for(k=0;k<8;k++)
d += (t >> k) & 0x01010101;
a = d & 0xff;
b = ((d >> 8) & 0xff);
c = ((d >> 16) & 0xff);
d >>= 24;
r->coeffs[64*i+j/2] = a + NEWHOPE_Q - b;
r->coeffs[64*i+j/2+1] = c + NEWHOPE_Q - d;
*/
}
}
}


+ 0
- 13
crypto_kem/newhope512cca/clean/poly.c View File

@@ -252,7 +252,6 @@ static unsigned char hw(unsigned char a) {
**************************************************/
void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_sample(poly *r, const unsigned char *seed, unsigned char nonce) {
unsigned char buf[128], a, b;
// uint32_t t, d, a, b, c;
int i, j;

unsigned char extseed[NEWHOPE_SYMBYTES + 2];
@@ -269,18 +268,6 @@ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_sample(poly *r, const unsigned char *seed,
a = buf[2 * j];
b = buf[2 * j + 1];
r->coeffs[64 * i + j] = hw(a) + NEWHOPE_Q - hw(b);
/*
t = buf[j] | ((uint32_t)buf[j+1] << 8) | ((uint32_t)buf[j+2] << 16) | ((uint32_t)buf[j+3] << 24);
d = 0;
for(k=0;k<8;k++)
d += (t >> k) & 0x01010101;
a = d & 0xff;
b = ((d >> 8) & 0xff);
c = ((d >> 16) & 0xff);
d >>= 24;
r->coeffs[64*i+j/2] = a + NEWHOPE_Q - b;
r->coeffs[64*i+j/2+1] = c + NEWHOPE_Q - d;
*/
}
}
}


+ 0
- 13
crypto_kem/newhope512cpa/clean/poly.c View File

@@ -252,7 +252,6 @@ static unsigned char hw(unsigned char a) {
**************************************************/
void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_sample(poly *r, const unsigned char *seed, unsigned char nonce) {
unsigned char buf[128], a, b;
// uint32_t t, d, a, b, c;
int i, j;

unsigned char extseed[NEWHOPE_SYMBYTES + 2];
@@ -269,18 +268,6 @@ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_sample(poly *r, const unsigned char *seed,
a = buf[2 * j];
b = buf[2 * j + 1];
r->coeffs[64 * i + j] = hw(a) + NEWHOPE_Q - hw(b);
/*
t = buf[j] | ((uint32_t)buf[j+1] << 8) | ((uint32_t)buf[j+2] << 16) | ((uint32_t)buf[j+3] << 24);
d = 0;
for(k=0;k<8;k++)
d += (t >> k) & 0x01010101;
a = d & 0xff;
b = ((d >> 8) & 0xff);
c = ((d >> 16) & 0xff);
d >>= 24;
r->coeffs[64*i+j/2] = a + NEWHOPE_Q - b;
r->coeffs[64*i+j/2+1] = c + NEWHOPE_Q - d;
*/
}
}
}


+ 43
- 0
test/duplicate_consistency/newhope1024cca_clean.yml View File

@@ -0,0 +1,43 @@
consistency_checks:
- source:
scheme: newhope1024cpa
implementation: clean
files:
- ntt.c
- poly.c
- precomp.c
- cpapke.c
- reduce.c
- verify.c
- params.h
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cca
implementation: clean
files:
- kem.c
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cpa
implementation: clean
files:
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h


+ 42
- 0
test/duplicate_consistency/newhope1024cpa_clean.yml View File

@@ -0,0 +1,42 @@
consistency_checks:
- source:
scheme: newhope1024cca
implementation: clean
files:
- ntt.c
- poly.c
- precomp.c
- cpapke.c
- reduce.c
- verify.c
- params.h
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cca
implementation: clean
files:
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cpa
implementation: clean
files:
- kem.c
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h

+ 44
- 0
test/duplicate_consistency/newhope512cca_clean.yml View File

@@ -0,0 +1,44 @@
consistency_checks:
- source:
scheme: newhope1024cpa
implementation: clean
files:
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope1024cca
implementation: clean
files:
- kem.c
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cpa
implementation: clean
files:
- ntt.c
- poly.c
- precomp.c
- cpapke.c
- reduce.c
- verify.c
- params.h
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h



+ 42
- 0
test/duplicate_consistency/newhope512cpa_clean.yml View File

@@ -0,0 +1,42 @@
consistency_checks:
- source:
scheme: newhope1024cpa
implementation: clean
files:
- kem.c
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope1024cca
implementation: clean
files:
- cpapke.c
- reduce.c
- verify.c
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h
- source:
scheme: newhope512cca
implementation: clean
files:
- ntt.c
- poly.c
- precomp.c
- cpapke.c
- reduce.c
- verify.c
- params.h
- cpapke.h
- ntt.h
- poly.h
- reduce.h
- verify.h

Loading…
Cancel
Save