@@ -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) { | |||||
shake128_squeezeblocks(output, nblocks, s->s); | |||||
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) { | |||||
shake128_squeezeblocks(output, nblocks, s); | |||||
} | } | ||||
/************************************************* | /************************************************* | ||||
@@ -6,12 +6,8 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
typedef struct { | |||||
uint64_t s[25]; | |||||
} 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_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y); | |||||
void PQCLEAN_KYBER1024_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *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 */ |
@@ -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) { | |||||
shake128_squeezeblocks(output, nblocks, s->s); | |||||
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) { | |||||
shake128_squeezeblocks(output, nblocks, s); | |||||
} | } | ||||
/************************************************* | /************************************************* | ||||
@@ -4,12 +4,8 @@ | |||||
#include "fips202.h" | #include "fips202.h" | ||||
#include "params.h" | #include "params.h" | ||||
typedef struct { | |||||
uint64_t s[25]; | |||||
} 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_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y); | |||||
void PQCLEAN_KYBER512_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *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 */ |
@@ -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) { | |||||
shake128_squeezeblocks(output, nblocks, s->s); | |||||
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *s) { | |||||
shake128_squeezeblocks(output, nblocks, s); | |||||
} | } | ||||
/************************************************* | /************************************************* | ||||
@@ -4,12 +4,8 @@ | |||||
#include "fips202.h" | #include "fips202.h" | ||||
#include "params.h" | #include "params.h" | ||||
typedef struct { | |||||
uint64_t s[25]; | |||||
} 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_kyber_shake128_absorb(shake128ctx *s, const unsigned char *input, unsigned char x, unsigned char y); | |||||
void PQCLEAN_KYBER768_CLEAN_kyber_shake128_squeezeblocks(unsigned char *output, size_t nblocks, shake128ctx *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 */ |