Port Kyber{512,768,1024} to fips202 ctx struct

This commit is contained in:
Thom Wiggers 2019-05-20 10:23:22 +02:00
vanhempi b153768783
commit 23e118207d
No known key found for this signature in database
GPG avaimen ID: 001BB0A7CE26E363
6 muutettua tiedostoa jossa 26 lisäystä ja 38 poistoa

Näytä tiedosto

@ -13,7 +13,7 @@
* - unsigned char i additional byte of input * - unsigned char i additional byte of input
* - unsigned char j additional byte of input * - unsigned char j additional byte of input
**************************************************/ **************************************************/
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y) { void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y) {
unsigned char extseed[KYBER_SYMBYTES + 2]; unsigned char extseed[KYBER_SYMBYTES + 2];
int i; int i;
@ -22,7 +22,7 @@ void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsign
} }
extseed[i++] = x; extseed[i++] = x;
extseed[i] = y; extseed[i] = y;
shake128_absorb(s->s, extseed, KYBER_SYMBYTES + 2); shake128_absorb(s, extseed, KYBER_SYMBYTES + 2);
} }
/************************************************* /*************************************************
@ -34,10 +34,10 @@ void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsign
* *
* Arguments: - unsigned char *output: pointer to output blocks * Arguments: - unsigned char *output: pointer to output blocks
* - size_t nblocks: number of blocks to be squeezed (written to output) * - size_t nblocks: number of blocks to be squeezed (written to output)
* - keccak_state *s: pointer to in/output Keccak state * - shake128ctx *s: pointer to in/output Keccak state
**************************************************/ **************************************************/
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s) { void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) {
shake128_squeezeblocks(output, nblocks, s->s); shake128_squeezeblocks(output, nblocks, s);
} }
/************************************************* /*************************************************

Näytä tiedosto

@ -6,12 +6,8 @@
#include <stdlib.h> #include <stdlib.h>
typedef struct { void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y);
uint64_t s[25]; void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s);
} keccak_state;
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y);
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s);
void PQCLEAN_KYBER1024_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce); void PQCLEAN_KYBER1024_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce);
#define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES) #define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES)
@ -23,6 +19,6 @@ void PQCLEAN_KYBER1024_CLEAN_shake256_prf(unsigned char *output, size_t outlen,
#define XOF_BLOCKBYTES 168 #define XOF_BLOCKBYTES 168
typedef keccak_state xof_state; typedef shake128ctx xof_state;
#endif /* SYMMETRIC_H */ #endif /* SYMMETRIC_H */

Näytä tiedosto

@ -8,12 +8,12 @@
* *
* Description: Absorb step of the SHAKE128 specialized for the Kyber context. * Description: Absorb step of the SHAKE128 specialized for the Kyber context.
* *
* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak state * Arguments: - shake128ctx *s: pointer to (uninitialized) output Keccak state
* - const unsigned char *input: pointer to KYBER_SYMBYTES input to be absorbed into s * - const unsigned char *input: pointer to KYBER_SYMBYTES input to be absorbed into s
* - unsigned char i additional byte of input * - unsigned char i additional byte of input
* - unsigned char j additional byte of input * - unsigned char j additional byte of input
**************************************************/ **************************************************/
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y) { void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y) {
unsigned char extseed[KYBER_SYMBYTES + 2]; unsigned char extseed[KYBER_SYMBYTES + 2];
int i; int i;
@ -22,7 +22,7 @@ void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigne
} }
extseed[i++] = x; extseed[i++] = x;
extseed[i] = y; extseed[i] = y;
shake128_absorb(s->s, extseed, KYBER_SYMBYTES + 2); shake128_absorb(s, extseed, KYBER_SYMBYTES + 2);
} }
/************************************************* /*************************************************
@ -34,10 +34,10 @@ void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigne
* *
* Arguments: - unsigned char *output: pointer to output blocks * Arguments: - unsigned char *output: pointer to output blocks
* - size_t nblocks: number of blocks to be squeezed (written to output) * - size_t nblocks: number of blocks to be squeezed (written to output)
* - keccak_state *s: pointer to in/output Keccak state * - shake128ctx *s: pointer to in/output Keccak state
**************************************************/ **************************************************/
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s) { void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) {
shake128_squeezeblocks(output, nblocks, s->s); shake128_squeezeblocks(output, nblocks, s);
} }
/************************************************* /*************************************************

Näytä tiedosto

@ -4,12 +4,8 @@
#include "fips202.h" #include "fips202.h"
#include "params.h" #include "params.h"
typedef struct { void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y);
uint64_t s[25]; void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s);
} keccak_state;
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y);
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s);
void PQCLEAN_KYBER512_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce); void PQCLEAN_KYBER512_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce);
#define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES) #define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES)
@ -21,6 +17,6 @@ void PQCLEAN_KYBER512_CLEAN_shake256_prf(unsigned char *output, size_t outlen, c
#define XOF_BLOCKBYTES 168 #define XOF_BLOCKBYTES 168
typedef keccak_state xof_state; typedef shake128ctx xof_state;
#endif /* SYMMETRIC_H */ #endif /* SYMMETRIC_H */

Näytä tiedosto

@ -8,12 +8,12 @@
* *
* Description: Absorb step of the SHAKE128 specialized for the Kyber context. * Description: Absorb step of the SHAKE128 specialized for the Kyber context.
* *
* Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak state * Arguments: - shake128ctx *s: pointer to (uninitialized) output Keccak state
* - const unsigned char *input: pointer to KYBER_SYMBYTES input to be absorbed into s * - const unsigned char *input: pointer to KYBER_SYMBYTES input to be absorbed into s
* - unsigned char i additional byte of input * - unsigned char i additional byte of input
* - unsigned char j additional byte of input * - unsigned char j additional byte of input
**************************************************/ **************************************************/
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y) { void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y) {
unsigned char extseed[KYBER_SYMBYTES + 2]; unsigned char extseed[KYBER_SYMBYTES + 2];
int i; int i;
@ -22,7 +22,7 @@ void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigne
} }
extseed[i++] = x; extseed[i++] = x;
extseed[i] = y; extseed[i] = y;
shake128_absorb(s->s, extseed, KYBER_SYMBYTES + 2); shake128_absorb(s, extseed, KYBER_SYMBYTES + 2);
} }
/************************************************* /*************************************************
@ -34,10 +34,10 @@ void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigne
* *
* Arguments: - unsigned char *output: pointer to output blocks * Arguments: - unsigned char *output: pointer to output blocks
* - size_t nblocks: number of blocks to be squeezed (written to output) * - size_t nblocks: number of blocks to be squeezed (written to output)
* - keccak_state *s: pointer to in/output Keccak state * - shake128ctx *s: pointer to in/output Keccak state
**************************************************/ **************************************************/
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s) { void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) {
shake128_squeezeblocks(output, nblocks, s->s); shake128_squeezeblocks(output, nblocks, s);
} }
/************************************************* /*************************************************

Näytä tiedosto

@ -4,12 +4,8 @@
#include "fips202.h" #include "fips202.h"
#include "params.h" #include "params.h"
typedef struct { void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y);
uint64_t s[25]; void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s);
} keccak_state;
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_absorb(keccak_state *s, const unsigned char *input, unsigned char x, unsigned char y);
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, keccak_state *s);
void PQCLEAN_KYBER768_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce); void PQCLEAN_KYBER768_CLEAN_shake256_prf(unsigned char *output, size_t outlen, const unsigned char *key, unsigned char nonce);
#define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES) #define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES)
@ -21,6 +17,6 @@ void PQCLEAN_KYBER768_CLEAN_shake256_prf(unsigned char *output, size_t outlen, c
#define XOF_BLOCKBYTES 168 #define XOF_BLOCKBYTES 168
typedef keccak_state xof_state; typedef shake128ctx xof_state;
#endif /* SYMMETRIC_H */ #endif /* SYMMETRIC_H */