1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-23 16:08:59 +00:00
pqcrypto/crypto_sign/sphincs-haraka-128s-simple/clean/haraka.h
Thom Wiggers aa4611a4d1 Eliminate the global state
This PR sacrifices passing some extra arguments to get rid of the global
state.

* Haraka needs state in all hash calls, this results in changes to the
  hash functions specified in `hash.h`.  The extra pointers passed would
  not be necessary for SHA256 or SHAKE256.
* SHAKE256 did not have global state, but uniformity in the implementations
  requires us to pass  around the new state context anyway. Otherwise,
  @joostrijneveld's SPHINCS+ generator doesn't really work anymore).

We introduce a new header file called `primitive.h` which defines the
required state type for the generic functions. I did not go into
replacing _all_ occurrences of state variables by the new `hash_state`
macro.
2019-07-16 15:46:27 -04:00

41 lines
1.7 KiB
C

#ifndef SPX_HARAKA_H
#define SPX_HARAKA_H
#include <stdint.h>
#include <stddef.h>
typedef struct {
uint64_t tweaked512_rc64[10][8];
uint32_t tweaked256_rc32[10][8];
uint32_t tweaked256_rc32_sseed[10][8];
} harakactx;
/* Tweak constants with seed */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_tweak_constants(
harakactx *state,
const unsigned char *pk_seed, const unsigned char *sk_seed,
unsigned long long seed_length);
/* Haraka Sponge */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S_inc_init(uint8_t *s_inc);
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S_inc_absorb(uint8_t *s_inc, const uint8_t *m, size_t mlen, const harakactx *state);
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S_inc_finalize(uint8_t *s_inc);
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S_inc_squeeze(uint8_t *out, size_t outlen, uint8_t *s_inc, const harakactx *state);
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S(
unsigned char *out, unsigned long long outlen,
const unsigned char *in, unsigned long long inlen, const harakactx *state);
/* Applies the 512-bit Haraka permutation to in. */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka512_perm(unsigned char *out, const unsigned char *in, const harakactx *state);
/* Implementation of Haraka-512 */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka512(unsigned char *out, const unsigned char *in, const harakactx *state);
/* Implementation of Haraka-256 */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka256(unsigned char *out, const unsigned char *in, const harakactx *state);
/* Implementation of Haraka-256 using sk.seed constants */
void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka256_sk(unsigned char *out, const unsigned char *in, const harakactx *state);
#endif