1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00

add duplicate consistency checks and remove some comments

This commit is contained in:
Matthias J. Kannwischer 2019-05-17 16:10:07 +02:00
parent 6659ba1d9c
commit 3d67b4c1c2
8 changed files with 171 additions and 52 deletions

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;
*/
}
}
}

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;
*/
}
}
}

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;
*/
}
}
}

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;
*/
}
}
}

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

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

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

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