mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-30 03:11:43 +00:00
Port NewHope to fips202 structs
This commit is contained in:
parent
23e118207d
commit
98002329ad
@ -202,7 +202,7 @@ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_tomsg(unsigned char *msg, const poly *x)
|
|||||||
void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
||||||
unsigned int ctr = 0;
|
unsigned int ctr = 0;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
uint64_t state[25];
|
shake128ctx state;
|
||||||
uint8_t buf[SHAKE128_RATE];
|
uint8_t buf[SHAKE128_RATE];
|
||||||
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -214,9 +214,9 @@ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_uniform(poly *a, const unsigned char *see
|
|||||||
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
||||||
shake128_absorb(state, extseed, NEWHOPE_SYMBYTES + 1);
|
shake128_absorb(&state, extseed, NEWHOPE_SYMBYTES + 1);
|
||||||
while (ctr < 64) { /* Very unlikely to run more than once */
|
while (ctr < 64) { /* Very unlikely to run more than once */
|
||||||
shake128_squeezeblocks(buf, 1, state);
|
shake128_squeezeblocks(buf, 1, &state);
|
||||||
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
||||||
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
||||||
if (val < 5 * NEWHOPE_Q) {
|
if (val < 5 * NEWHOPE_Q) {
|
||||||
|
@ -202,7 +202,7 @@ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_tomsg(unsigned char *msg, const poly *x)
|
|||||||
void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
||||||
unsigned int ctr = 0;
|
unsigned int ctr = 0;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
uint64_t state[25];
|
shake128ctx state;
|
||||||
uint8_t buf[SHAKE128_RATE];
|
uint8_t buf[SHAKE128_RATE];
|
||||||
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -214,9 +214,9 @@ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_uniform(poly *a, const unsigned char *see
|
|||||||
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
||||||
shake128_absorb(state, extseed, NEWHOPE_SYMBYTES + 1);
|
shake128_absorb(&state, extseed, NEWHOPE_SYMBYTES + 1);
|
||||||
while (ctr < 64) { /* Very unlikely to run more than once */
|
while (ctr < 64) { /* Very unlikely to run more than once */
|
||||||
shake128_squeezeblocks(buf, 1, state);
|
shake128_squeezeblocks(buf, 1, &state);
|
||||||
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
||||||
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
||||||
if (val < 5 * NEWHOPE_Q) {
|
if (val < 5 * NEWHOPE_Q) {
|
||||||
|
@ -198,7 +198,7 @@ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_tomsg(unsigned char *msg, const poly *x) {
|
|||||||
void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
||||||
unsigned int ctr = 0;
|
unsigned int ctr = 0;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
uint64_t state[25];
|
shake128ctx state;
|
||||||
uint8_t buf[SHAKE128_RATE];
|
uint8_t buf[SHAKE128_RATE];
|
||||||
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -210,9 +210,9 @@ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed
|
|||||||
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
||||||
shake128_absorb(state, extseed, NEWHOPE_SYMBYTES + 1);
|
shake128_absorb(&state, extseed, NEWHOPE_SYMBYTES + 1);
|
||||||
while (ctr < 64) { /* Very unlikely to run more than once */
|
while (ctr < 64) { /* Very unlikely to run more than once */
|
||||||
shake128_squeezeblocks(buf, 1, state);
|
shake128_squeezeblocks(buf, 1, &state);
|
||||||
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
||||||
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
||||||
if (val < 5 * NEWHOPE_Q) {
|
if (val < 5 * NEWHOPE_Q) {
|
||||||
|
@ -198,7 +198,7 @@ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_tomsg(unsigned char *msg, const poly *x) {
|
|||||||
void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed) {
|
||||||
unsigned int ctr = 0;
|
unsigned int ctr = 0;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
uint64_t state[25];
|
shake128ctx state;
|
||||||
uint8_t buf[SHAKE128_RATE];
|
uint8_t buf[SHAKE128_RATE];
|
||||||
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
uint8_t extseed[NEWHOPE_SYMBYTES + 1];
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -210,9 +210,9 @@ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed
|
|||||||
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
for (i = 0; i < NEWHOPE_N / 64; i++) { /* generate a in blocks of 64 coefficients */
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
extseed[NEWHOPE_SYMBYTES] = (unsigned char) i; /* domain-separate the 16 independent calls */
|
||||||
shake128_absorb(state, extseed, NEWHOPE_SYMBYTES + 1);
|
shake128_absorb(&state, extseed, NEWHOPE_SYMBYTES + 1);
|
||||||
while (ctr < 64) { /* Very unlikely to run more than once */
|
while (ctr < 64) { /* Very unlikely to run more than once */
|
||||||
shake128_squeezeblocks(buf, 1, state);
|
shake128_squeezeblocks(buf, 1, &state);
|
||||||
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
for (j = 0; j < SHAKE128_RATE && ctr < 64; j += 2) {
|
||||||
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
val = (buf[j] | ((uint16_t) buf[j + 1] << 8));
|
||||||
if (val < 5 * NEWHOPE_Q) {
|
if (val < 5 * NEWHOPE_Q) {
|
||||||
|
Loading…
Reference in New Issue
Block a user