1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-23 07:59:01 +00:00
pqcrypto/crypto_sign/sphincs-haraka-256f-robust/aesni/hash_harakax4.c
Thom Wiggers a655ec8a9d SPHINCS+ optimized implementations (#253)
* Add state destroy to SHA2 API

* Include optimized SPHINCS+ implementations

I've generated new implementations from the sphincsplus repository.

* Don't destroy sha256ctx after finalize

* Attempt to shut up MSVC

* Make sure to drop errors in rmtree
2019-12-12 14:29:29 +01:00

38 lines
1.3 KiB
C

#include <stdint.h>
#include <string.h>
#include "address.h"
#include "haraka.h"
#include "hash_state.h"
#include "hashx4.h"
#include "params.h"
/*
* 4-way parallel version of prf_addr; takes 4x as much input and output
*/
void PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_prf_addrx4(unsigned char *out0,
unsigned char *out1,
unsigned char *out2,
unsigned char *out3,
const unsigned char *key,
const uint32_t addrx4[4 * 8],
const hash_state *state_seeded) {
unsigned char bufx4[4 * PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_ADDR_BYTES];
/* Since PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_N may be smaller than 32, we need a temporary buffer. */
unsigned char outbuf[4 * 32];
unsigned int i;
(void)key; /* Suppress an 'unused parameter' warning. */
for (i = 0; i < 4; i++) {
PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_addr_to_bytes(bufx4 + i * PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_ADDR_BYTES, addrx4 + i * 8);
}
PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_haraka256_skx4(outbuf, bufx4, state_seeded);
memcpy(out0, outbuf, PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_N);
memcpy(out1, outbuf + 32, PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_N);
memcpy(out2, outbuf + 64, PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_N);
memcpy(out3, outbuf + 96, PQCLEAN_SPHINCSHARAKA256FROBUST_AESNI_N);
}