HKDS: Heirarchal Key Derivation System 1.0.0.2 (A2)
A fast post-quantum secure replacement for DUKPT
keccak.h File Reference

SHA3 header definition
Contains the public api and documentation for SHA3 digest, SHAKE, cSHAKE, and KMAC implementations. More...

#include "common.h"
#include "hkds_config.h"

Go to the source code of this file.

Data Structures

struct  hkds_keccak_state
 The Keccak state array; state array must be initialized by the caller. More...
 

Macros

#define HKDS_KECCAK_CSHAKE_DOMAIN_ID   0x04
 The cSHAKE domain id.
 
#define HKDS_KECCAK_KMAC_DOMAIN_ID   0x04
 The KMAC domain id.
 
#define HKDS_KECCAK_KPA_DOMAIN_ID   0x41
 The KPA domain id.
 
#define HKDS_KECCAK_PERMUTATION_ROUNDS   24
 The standard number of permutation rounds.
 
#define HKDS_KECCAK_PERMUTATION_MAX_ROUNDS   48
 The maximum number of permutation rounds.
 
#define HKDS_KECCAK_PERMUTATION_MIN_ROUNDS   12
 The minimum number of permutation rounds.
 
#define HKDS_KECCAK_SHA3_DOMAIN_ID   0x06
 The SHA3 domain id.
 
#define HKDS_KECCAK_SHAKE_DOMAIN_ID   0x1F
 The SHAKE domain id.
 
#define HKDS_KECCAK_STATE_BYTE_SIZE   200
 The Keccak state array byte size.
 
#define HKDS_KECCAK_128_RATE   168
 The 128-bit absorption rate.
 
#define HKDS_KECCAK_256_RATE   136
 The 256-bit absorption rate.
 
#define HKDS_KECCAK_512_RATE   72
 The 512 bit absorption rate.
 
#define HKDS_KECCAK_STATE_SIZE   25
 The Keccak SHA3 uint64 state array size.
 
#define HKDS_KECCAK_STATE_BYTE_SIZE   200
 The Keccak state array byte size.
 
#define HKDS_KMAC_256_KEY_SIZE   32
 The KMAC-256 key size in bytes.
 
#define HKDS_KMAC_512_KEY_SIZE   64
 The KMAC-512 key size in bytes.
 
#define HKDS_KECCAK_SCBKDF_DOMAIN_ID   0x42
 The SCBKDF domain id.
 
#define HKDS_SHA3_128_HASH_SIZE   16
 The HKDS_SHA3_128_HASH_SIZE hash size in bytes (16)
 
#define HKDS_SHA3_256_HASH_SIZE   32
 The SHA-256 hash size in bytes (32)
 
#define HKDS_SHA3_512_HASH_SIZE   64
 The SHA-512 hash size in bytes (64)
 
#define HKDS_SHAKE_256_KEY_SIZE   32
 The SHAKE-256 key size in bytes.
 
#define HKDS_SHAKE512_KEY_SIZE   64
 The SHAKE-512 key size in bytes.
 

Typedefs

typedef HKDS_EXPORT_API struct hkds_keccak_state hkds_keccak_state
 
typedef enum hkds_keccak_rate hkds_keccak_rate
 

Enumerations

enum  hkds_keccak_rate { hkds_keccak_rate_none = 0 , hkds_keccak_rate_128 = HKDS_KECCAK_128_RATE , hkds_keccak_rate_256 = HKDS_KECCAK_256_RATE , hkds_keccak_rate_512 = HKDS_KECCAK_512_RATE }
 The Keccak rate; determines which security strength is used by the function, 128, 256, or 512-bit. More...
 

Functions

HKDS_EXPORT_API void hkds_keccak_absorb (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *message, size_t msglen, uint8_t domain, size_t rounds)
 Absorb an input message into the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_absorb_custom (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *custom, size_t custlen, const uint8_t *name, size_t namelen, size_t rounds)
 Absorb the custom, and name arrays into the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_absorb_key_custom (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen, const uint8_t *name, size_t namelen, size_t rounds)
 Absorb the custom, name, and key arrays into the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_dispose (hkds_keccak_state *ctx)
 Dispose of the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_finalize (hkds_keccak_state *ctx, hkds_keccak_rate rate, uint8_t *output, size_t outlen, uint8_t domain, size_t rounds)
 Finalize the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_incremental_absorb (hkds_keccak_state *ctx, uint32_t rate, const uint8_t *message, size_t msglen)
 Absorb bytes into state incrementally.
 
HKDS_EXPORT_API void hkds_keccak_incremental_finalize (hkds_keccak_state *ctx, uint32_t rate, uint8_t domain)
 Finalize state added incrementally.
 
HKDS_EXPORT_API void hkds_keccak_incremental_squeeze (hkds_keccak_state *ctx, size_t rate, uint8_t *output, size_t outlen)
 Extract an array of bytes from the Keccak state.
 
HKDS_EXPORT_API void hkds_keccak_permute (hkds_keccak_state *ctx, size_t rounds)
 The Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.
 
HKDS_EXPORT_API void hkds_keccak_permute_p1600c (uint64_t *state, size_t rounds)
 The compact Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.
 
HKDS_EXPORT_API void hkds_keccak_permute_p1600u (uint64_t *state)
 The unrolled Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.
 
HKDS_EXPORT_API void hkds_keccak_squeezeblocks (hkds_keccak_state *ctx, uint8_t *output, size_t nblocks, hkds_keccak_rate rate, size_t rounds)
 The Keccak squeeze function.
 
HKDS_EXPORT_API void hkds_keccak_initialize_state (hkds_keccak_state *ctx)
 Initializes a Keccak state structure, must be called before message processing. Long form api: must be used in conjunction with the block-update and finalize functions.
 
HKDS_EXPORT_API void hkds_keccak_update (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *message, size_t msglen, size_t rounds)
 Update Keccak state with message input.
 
HKDS_EXPORT_API void hkds_shake128_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen)
 Key a SHAKE-128 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.
 
HKDS_EXPORT_API void hkds_shake256_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen)
 Key a SHAKE-256 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.
 
HKDS_EXPORT_API void hkds_shake512_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen)
 Key a SHAKE-512 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.
 
HKDS_EXPORT_API void hkds_shake_initialize (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *key, size_t keylen)
 The SHAKE initialize function. Long form api: must be used in conjunction with the squeezeblocks function. Absorb and finalize an input key byte array.
 
HKDS_EXPORT_API void hkds_shake_squeezeblocks (hkds_keccak_state *ctx, hkds_keccak_rate rate, uint8_t *output, size_t nblocks)
 The SHAKE squeeze function. Long form api: must be used in conjunction with the initialize function. Permutes and extracts the state to an output byte array.
 
HKDS_EXPORT_API void hkds_kmac128_compute (uint8_t *output, size_t outlen, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen)
 Key a KMAC-128 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.
 
HKDS_EXPORT_API void hkds_kmac256_compute (uint8_t *output, size_t outlen, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen)
 Key a KMAC-256 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.
 
HKDS_EXPORT_API void hkds_kmac512_compute (uint8_t *output, size_t outlen, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen)
 Key a KMAC-512 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.
 
HKDS_EXPORT_API void hkds_kmac_update (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *message, size_t msglen)
 The KMAC message update function. Long form api: must be used in conjunction with the initialize and finalize functions.
 
HKDS_EXPORT_API void hkds_kmac_finalize (hkds_keccak_state *ctx, hkds_keccak_rate rate, uint8_t *output, size_t outlen)
 The KMAC finalize function. Long form api: must be used in conjunction with the initialize and blockupdate functions. Final processing and calculation of the MAC code.
 
HKDS_EXPORT_API void hkds_kmac_initialize (hkds_keccak_state *ctx, hkds_keccak_rate rate, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen)
 Initialize a KMAC instance. Long form api: must be used in conjunction with the blockupdate and finalize functions. Key the MAC generator and initialize the internal state.
 
HKDS_EXPORT_API void hkds_shake_128x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, size_t inplen)
 Process 4 SHAKE-128 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_shake_256x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, size_t inplen)
 Process 4 SHAKE-256 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_shake_512x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, size_t inplen)
 Process 4 SHAKE-512 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_shake_128x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, const uint8_t *inp4, const uint8_t *inp5, const uint8_t *inp6, const uint8_t *inp7, size_t inplen)
 Process 8 SHAKE-128 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_shake_256x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, const uint8_t *inp4, const uint8_t *inp5, const uint8_t *inp6, const uint8_t *inp7, size_t inplen)
 Process 8 SHAKE-256 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_shake_512x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *inp0, const uint8_t *inp1, const uint8_t *inp2, const uint8_t *inp3, const uint8_t *inp4, const uint8_t *inp5, const uint8_t *inp6, const uint8_t *inp7, size_t inplen)
 Process 8 SHAKE-512 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_128x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, size_t msglen)
 Process 4 KMAC-128 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_256x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, size_t msglen)
 Process 4 KMAC-256 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_512x4 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, size_t msglen)
 Process 4 KMAC-512 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_128x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, const uint8_t *key4, const uint8_t *key5, const uint8_t *key6, const uint8_t *key7, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, const uint8_t *cst4, const uint8_t *cst5, const uint8_t *cst6, const uint8_t *cst7, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, const uint8_t *msg4, const uint8_t *msg5, const uint8_t *msg6, const uint8_t *msg7, size_t msglen)
 Process 8 KMAC-128 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_256x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, const uint8_t *key4, const uint8_t *key5, const uint8_t *key6, const uint8_t *key7, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, const uint8_t *cst4, const uint8_t *cst5, const uint8_t *cst6, const uint8_t *cst7, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, const uint8_t *msg4, const uint8_t *msg5, const uint8_t *msg6, const uint8_t *msg7, size_t msglen)
 Process 8 KMAC-256 instances simultaneously using SIMD instructions.
 
HKDS_EXPORT_API void hkds_kmac_512x8 (uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3, uint8_t *out4, uint8_t *out5, uint8_t *out6, uint8_t *out7, size_t outlen, const uint8_t *key0, const uint8_t *key1, const uint8_t *key2, const uint8_t *key3, const uint8_t *key4, const uint8_t *key5, const uint8_t *key6, const uint8_t *key7, size_t keylen, const uint8_t *cst0, const uint8_t *cst1, const uint8_t *cst2, const uint8_t *cst3, const uint8_t *cst4, const uint8_t *cst5, const uint8_t *cst6, const uint8_t *cst7, size_t cstlen, const uint8_t *msg0, const uint8_t *msg1, const uint8_t *msg2, const uint8_t *msg3, const uint8_t *msg4, const uint8_t *msg5, const uint8_t *msg6, const uint8_t *msg7, size_t msglen)
 Process 8 KMAC-512 instances simultaneously using SIMD instructions.
 

Detailed Description

SHA3 header definition
Contains the public api and documentation for SHA3 digest, SHAKE, cSHAKE, and KMAC implementations.

Usage Examples
SHA3-512 hash computation using long-form api

#define MSGLEN 200
uint8_t msg[MSGLEN] = {...};
uint8_t hash[HKDS_SHA3_512_HASH_SIZE] = { 0 };
hkds_sha3_initialize(ctx.state);
hkds_sha3_update(&ctx, hkds_keccak_rate_512, msg, MSGLEN);
hkds_sha3_finalize(&ctx, hkds_keccak_rate_512, hash);
@ hkds_keccak_rate_512
Definition keccak.h:280
#define HKDS_SHA3_512_HASH_SIZE
The SHA-512 hash size in bytes (64)
Definition keccak.h:244
The Keccak state array; state array must be initialized by the caller.
Definition keccak.h:265
uint64_t state[HKDS_KECCAK_STATE_SIZE]
Definition keccak.h:266

KMAC-256 MAC code generation using long-form api

#define MSGLEN 200
uint8_t msg[MSGLEN] = {...};
uint8_t key[HKDS_KMAC_256_KEY_SIZE] = {...};
uint8_t cust[...] = {...};
uint8_t code[HKDS_KMAC_256_MAC_SIZE] = { 0 };
hkds_kmac_initialize(&ctx, hkds_keccak_rate_256, key, sizeof(key), cust, sizeof(cust));
hkds_kmac_update(&ctx, hkds_keccak_rate_256, msg, MSGLEN);
hkds_kmac_finalize(&ctx, hkds_keccak_rate_256, code, sizeof(code));
@ hkds_keccak_rate_256
Definition keccak.h:279
#define HKDS_KMAC_256_KEY_SIZE
The KMAC-256 key size in bytes.
Definition keccak.h:214

cSHAKE-512 pseudo-random generation using long-form api

uint8_t output[64] = { 0 };
uint8_t key[HKDS_KMAC_512_KEY_SIZE] = {...};
uint8_t cust[...] = {...};
uint8_t name[...] = {...};
hkds_cshake_initialize(&ctx, key, sizeof(key), name, sizeof(name), cust, sizeof(cust));
hkds_cshake_squeezeblocks(&ctx, output, 1);
#define HKDS_KMAC_512_KEY_SIZE
The KMAC-512 key size in bytes.
Definition keccak.h:220
Remarks
The SHA3, SHAKE, cSHAKE, and KMAC implementations all share two forms of api: short-form and long-form.
The short-form api, which initializes the state, processes a message, and finalizes by producing output, all in a single function call, for example; hkds_sha3_compute512(uint8_t* output, const uint8_t* message, size_t msglen), the entire message array is processed and the hash code is written to the output array.
The long-form api uses an initialization call to prepare the state, a blockupdate call if the message is longer than a single message block, and the finalize call, which finalizes the state and generates a hash, mac-code, or an array of pseudo-random.
Each of the function families (SHA3, SHAKE, KMAC), have a corresponding set of reference constants associated with that member, example; SHAKE_256_KEY is the minimum expected SHAKE-256 key size in bytes, HKDS_KMAC_512_MAC_SIZE is the minimum size of the KMAC-512 output mac-code output array, and HKDS_KECCAK_512_RATE is the SHA3-512 message absorption rate.

For additional usage examples, see sha3_test.h.

NIST: SHA3 Fips202 http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
NIST: SP800-185 http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf
NIST: SHA3 Keccak Submission http://keccak.noekeon.org/Keccak-submission-3.pdf
NIST: SHA3 Keccak Slides http://csrc.nist.gov/groups/ST/hash/sha-3/documents/Keccak-slides-at-NIST.pdf
NIST: SHA3 Third-Round Report http://nvlpubs.nist.gov/nistpubs/ir/2012/NIST.IR.7896.pdf
Team Keccak: Specifications summary https://keccak.team/keccak_specs_summary.html

Macro Definition Documentation

◆ HKDS_KECCAK_STATE_BYTE_SIZE [1/2]

#define HKDS_KECCAK_STATE_BYTE_SIZE   200

The Keccak state array byte size.

The Keccak SHA3 state size in bytes.

◆ HKDS_KECCAK_STATE_BYTE_SIZE [2/2]

#define HKDS_KECCAK_STATE_BYTE_SIZE   200

The Keccak state array byte size.

The Keccak SHA3 state size in bytes.

Enumeration Type Documentation

◆ hkds_keccak_rate

The Keccak rate; determines which security strength is used by the function, 128, 256, or 512-bit.

Enumerator
hkds_keccak_rate_none 

No bit rate was selected

hkds_keccak_rate_128 

The Keccak 128-bit rate

hkds_keccak_rate_256 

The Keccak 256-bit rate

hkds_keccak_rate_512 

The Keccak 512-bit rate

Function Documentation

◆ hkds_keccak_absorb()

HKDS_EXPORT_API void hkds_keccak_absorb ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * message,
size_t msglen,
uint8_t domain,
size_t rounds )

Absorb an input message into the Keccak state.

Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
message[const] The input message byte array
msglenThe number of message bytes to process
domainThe function domain id
roundsThe number of permutation rounds, the default is 24, maximum is 48

◆ hkds_keccak_absorb_custom()

HKDS_EXPORT_API void hkds_keccak_absorb_custom ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * custom,
size_t custlen,
const uint8_t * name,
size_t namelen,
size_t rounds )

Absorb the custom, and name arrays into the Keccak state.

Parameters
ctx[struct] The Keccak state structure
rateThe rate of absorption in bytes
custom[const] The customization string
custlenThe byte length of the customization string
name[const] The function name string
namelenThe byte length of the function name
roundsThe number of permutation rounds, the default is 24, maximum is 48

◆ hkds_keccak_absorb_key_custom()

HKDS_EXPORT_API void hkds_keccak_absorb_key_custom ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen,
const uint8_t * name,
size_t namelen,
size_t rounds )

Absorb the custom, name, and key arrays into the Keccak state.

Parameters
ctx[struct] The Keccak state structure
rateThe rate of absorption in bytes
key[const] The input key byte array
keylenThe number of key bytes to process
custom[const] The customization string
custlenThe byte length of the customization string
name[const] The function name string
namelenThe byte length of the function name
roundsThe number of permutation rounds, the default is 24, maximum is 48

◆ hkds_keccak_dispose()

HKDS_EXPORT_API void hkds_keccak_dispose ( hkds_keccak_state * ctx)

Dispose of the Keccak state.

Warning
The dispose function must be called when disposing of the function state. This function safely destroys the internal state.
Parameters
ctx[struct] The Keccak state structure

◆ hkds_keccak_finalize()

HKDS_EXPORT_API void hkds_keccak_finalize ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
uint8_t * output,
size_t outlen,
uint8_t domain,
size_t rounds )

Finalize the Keccak state.

Parameters
ctx[struct] The Keccak state structure
rateThe rate of absorption in bytes
outputThe output byte array
outlenThe number of output bytes to generate
domainThe function domain id
roundsThe number of permutation rounds, the default is 24, maximum is 48

◆ hkds_keccak_incremental_absorb()

HKDS_EXPORT_API void hkds_keccak_incremental_absorb ( hkds_keccak_state * ctx,
uint32_t rate,
const uint8_t * message,
size_t msglen )

Absorb bytes into state incrementally.

Parameters
ctxThe function state
rateThe rate of absorption in bytes
message[const] The input message array
msglenThe number of message bytes

◆ hkds_keccak_incremental_finalize()

HKDS_EXPORT_API void hkds_keccak_incremental_finalize ( hkds_keccak_state * ctx,
uint32_t rate,
uint8_t domain )

Finalize state added incrementally.

Parameters
ctxThe function state
rateThe rate of absorption in bytes
domainThe function domain id

◆ hkds_keccak_incremental_squeeze()

HKDS_EXPORT_API void hkds_keccak_incremental_squeeze ( hkds_keccak_state * ctx,
size_t rate,
uint8_t * output,
size_t outlen )

Extract an array of bytes from the Keccak state.

Parameters
ctxThe function state
outputThe output byte array
outlenThe number of output bytes to generate
rateThe rate of absorption in bytes

◆ hkds_keccak_initialize_state()

HKDS_EXPORT_API void hkds_keccak_initialize_state ( hkds_keccak_state * ctx)

Initializes a Keccak state structure, must be called before message processing. Long form api: must be used in conjunction with the block-update and finalize functions.

Parameters
ctx[struct] A reference to the Keccak state; must be initialized

◆ hkds_keccak_permute()

HKDS_EXPORT_API void hkds_keccak_permute ( hkds_keccak_state * ctx,
size_t rounds )

The Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.

Parameters
ctx[struct] The function state; must be initialized
roundsThe number of permutation rounds, the default and maximum is 24

◆ hkds_keccak_permute_p1600c()

HKDS_EXPORT_API void hkds_keccak_permute_p1600c ( uint64_t * state,
size_t rounds )

The compact Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.

Parameters
stateThe state array; must be initialized
roundsThe number of permutation rounds, the default and maximum is 24

◆ hkds_keccak_permute_p1600u()

HKDS_EXPORT_API void hkds_keccak_permute_p1600u ( uint64_t * state)

The unrolled Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.

Parameters
stateThe state array; must be initialized

◆ hkds_keccak_squeezeblocks()

HKDS_EXPORT_API void hkds_keccak_squeezeblocks ( hkds_keccak_state * ctx,
uint8_t * output,
size_t nblocks,
hkds_keccak_rate rate,
size_t rounds )

The Keccak squeeze function.

Warning
Output array must be initialized to a multiple of the byte rate.
Parameters
ctx[struct] A reference to the Keccak state; must be initialized
outputThe output byte array
nblocksThe number of blocks to extract
rateThe rate of absorption in bytes
roundsThe number of permutation rounds, the default and maximum is 24

◆ hkds_keccak_update()

HKDS_EXPORT_API void hkds_keccak_update ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * message,
size_t msglen,
size_t rounds )

Update Keccak state with message input.

Warning
The state must be initialized before calling
Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
message[const] The input message byte array
msglenThe number of message bytes to process
roundsThe number of permutation rounds, the default and maximum is 24

◆ hkds_kmac128_compute()

HKDS_EXPORT_API void hkds_kmac128_compute ( uint8_t * output,
size_t outlen,
const uint8_t * message,
size_t msglen,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen )

Key a KMAC-128 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.

Parameters
outputThe MAC code byte array
outlenThe number of MAC code bytes to generate
message[const] The message input byte array
msglenThe number of message bytes to process
key[const] The input key byte array
keylenThe number of key bytes to process
custom[const] The customization string
custlenThe byte length of the customization string

◆ hkds_kmac256_compute()

HKDS_EXPORT_API void hkds_kmac256_compute ( uint8_t * output,
size_t outlen,
const uint8_t * message,
size_t msglen,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen )

Key a KMAC-256 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.

Parameters
outputThe MAC code byte array
outlenThe number of MAC code bytes to generate
message[const] The message input byte array
msglenThe number of message bytes to process
key[const] The input key byte array
keylenThe number of key bytes to process
custom[const] The customization string
custlenThe byte length of the customization string

◆ hkds_kmac512_compute()

HKDS_EXPORT_API void hkds_kmac512_compute ( uint8_t * output,
size_t outlen,
const uint8_t * message,
size_t msglen,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen )

Key a KMAC-512 instance and generate a MAC code. Short form api: processes the key and custom inputs and generates the MAC code with a single call. Key the MAC generator process a message and output the MAC code.

Parameters
outputThe MAC code byte array
outlenThe number of MAC code bytes to generate
message[const] The message input byte array
msglenThe number of message bytes to process
key[const] The input key byte array
keylenThe number of key bytes to process
custom[const] The customization string
custlenThe byte length of the customization string

◆ hkds_kmac_128x4()

HKDS_EXPORT_API void hkds_kmac_128x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
size_t msglen )

Process 4 KMAC-128 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
keylenThe length of the input key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msglenThe length of the message arrays

◆ hkds_kmac_128x8()

HKDS_EXPORT_API void hkds_kmac_128x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
const uint8_t * key4,
const uint8_t * key5,
const uint8_t * key6,
const uint8_t * key7,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
const uint8_t * cst4,
const uint8_t * cst5,
const uint8_t * cst6,
const uint8_t * cst7,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
const uint8_t * msg4,
const uint8_t * msg5,
const uint8_t * msg6,
const uint8_t * msg7,
size_t msglen )

Process 8 KMAC-128 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
key4[const] The 5th key array
key5[const] The 6th key array
key6[const] The 7th key array
key7[const] The 8th key array
keylenThe length of the key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cst4[const] The 5th custom array
cst5[const] The 6th custom array
cst6[const] The 7th custom array
cst7[const] The 8th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msg4[const] The 5th message array
msg5[const] The 6th message array
msg6[const] The 7th message array
msg7[const] The 8th message array
msglenThe length of the message arrays

◆ hkds_kmac_256x4()

HKDS_EXPORT_API void hkds_kmac_256x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
size_t msglen )

Process 4 KMAC-256 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
keylenThe length of the input key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msglenThe length of the message arrays

◆ hkds_kmac_256x8()

HKDS_EXPORT_API void hkds_kmac_256x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
const uint8_t * key4,
const uint8_t * key5,
const uint8_t * key6,
const uint8_t * key7,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
const uint8_t * cst4,
const uint8_t * cst5,
const uint8_t * cst6,
const uint8_t * cst7,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
const uint8_t * msg4,
const uint8_t * msg5,
const uint8_t * msg6,
const uint8_t * msg7,
size_t msglen )

Process 8 KMAC-256 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
key4[const] The 5th key array
key5[const] The 6th key array
key6[const] The 7th key array
key7[const] The 8th key array
keylenThe length of the key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cst4[const] The 5th custom array
cst5[const] The 6th custom array
cst6[const] The 7th custom array
cst7[const] The 8th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msg4[const] The 5th message array
msg5[const] The 6th message array
msg6[const] The 7th message array
msg7[const] The 8th message array
msglenThe length of the message arrays

◆ hkds_kmac_512x4()

HKDS_EXPORT_API void hkds_kmac_512x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
size_t msglen )

Process 4 KMAC-512 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
keylenThe length of the input key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msglenThe length of the message arrays

◆ hkds_kmac_512x8()

HKDS_EXPORT_API void hkds_kmac_512x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * key0,
const uint8_t * key1,
const uint8_t * key2,
const uint8_t * key3,
const uint8_t * key4,
const uint8_t * key5,
const uint8_t * key6,
const uint8_t * key7,
size_t keylen,
const uint8_t * cst0,
const uint8_t * cst1,
const uint8_t * cst2,
const uint8_t * cst3,
const uint8_t * cst4,
const uint8_t * cst5,
const uint8_t * cst6,
const uint8_t * cst7,
size_t cstlen,
const uint8_t * msg0,
const uint8_t * msg1,
const uint8_t * msg2,
const uint8_t * msg3,
const uint8_t * msg4,
const uint8_t * msg5,
const uint8_t * msg6,
const uint8_t * msg7,
size_t msglen )

Process 8 KMAC-512 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
key0[const] The 1st key array
key1[const] The 2nd key array
key2[const] The 3rd key array
key3[const] The 4th key array
key4[const] The 5th key array
key5[const] The 6th key array
key6[const] The 7th key array
key7[const] The 8th key array
keylenThe length of the key arrays
cst0[const] The 1st custom array
cst1[const] The 2nd custom array
cst2[const] The 3rd custom array
cst3[const] The 4th custom array
cst4[const] The 5th custom array
cst5[const] The 6th custom array
cst6[const] The 7th custom array
cst7[const] The 8th custom array
cstlenThe length of the custom arrays
msg0[const] The 1st message array
msg1[const] The 2nd message array
msg2[const] The 3rd message array
msg3[const] The 4th message array
msg4[const] The 5th message array
msg5[const] The 6th message array
msg6[const] The 7th message array
msg7[const] The 8th message array
msglenThe length of the message arrays

◆ hkds_kmac_finalize()

HKDS_EXPORT_API void hkds_kmac_finalize ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
uint8_t * output,
size_t outlen )

The KMAC finalize function. Long form api: must be used in conjunction with the initialize and blockupdate functions. Final processing and calculation of the MAC code.

Warning
The state must be initialized before calling.
Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
outputThe output byte array
outlenThe number of bytes to extract

◆ hkds_kmac_initialize()

HKDS_EXPORT_API void hkds_kmac_initialize ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen )

Initialize a KMAC instance. Long form api: must be used in conjunction with the blockupdate and finalize functions. Key the MAC generator and initialize the internal state.

Parameters
ctx[struct] A reference to the keccak state; must be initialized
rateThe rate of absorption in bytes
key[const] The input key byte array
keylenThe number of key bytes to process
custom[const] The customization string
custlenThe byte length of the customization string

◆ hkds_kmac_update()

HKDS_EXPORT_API void hkds_kmac_update ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * message,
size_t msglen )

The KMAC message update function. Long form api: must be used in conjunction with the initialize and finalize functions.

Warning
The state must be initialized before calling.
Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
message[const] The message input byte array
msglenThe number of message bytes to process

◆ hkds_shake128_compute()

HKDS_EXPORT_API void hkds_shake128_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen )

Key a SHAKE-128 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.

Warning
The output array length must not be zero.
Parameters
outputThe output byte array
outlenThe number of output bytes to generate
key[const] The input key byte array
keylenThe number of key bytes to process

◆ hkds_shake256_compute()

HKDS_EXPORT_API void hkds_shake256_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen )

Key a SHAKE-256 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.

Warning
The output array length must not be zero.
Parameters
outputThe output byte array
outlenThe number of output bytes to generate
key[const] The input key byte array
keylenThe number of key bytes to process

◆ hkds_shake512_compute()

HKDS_EXPORT_API void hkds_shake512_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen )

Key a SHAKE-512 instance, and generate an array of pseudo-random bytes. Short form api: processes the key and generates the pseudo-random output with a single call.

Warning
The output array length must not be zero.
Parameters
outputThe output byte array
outlenThe number of output bytes to generate
key[const] The input key byte array
keylenThe number of key bytes to process

◆ hkds_shake_128x4()

HKDS_EXPORT_API void hkds_shake_128x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
size_t inplen )

Process 4 SHAKE-128 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
inp0[const] The 1st input key array
inp1[const] The 2nd input key array
inp2[const] The 3rd input key array
inp3[const] The 4th input key array
inplenThe length of the input key arrays

◆ hkds_shake_128x8()

HKDS_EXPORT_API void hkds_shake_128x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
const uint8_t * inp4,
const uint8_t * inp5,
const uint8_t * inp6,
const uint8_t * inp7,
size_t inplen )

Process 8 SHAKE-128 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
inp0[const] The 1st input key array
inp1[const] The 2nd input key array
inp2[const] The 3rd input key array
inp3[const] The 4th input key array
inp4[const] The 5th input key array
inp5[const] The 6th input key array
inp6[const] The 7th input key array
inp7[const] The 8th input key array
inplenThe length of the input key arrays

◆ hkds_shake_256x4()

HKDS_EXPORT_API void hkds_shake_256x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
size_t inplen )

Process 4 SHAKE-256 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
inp0[const] The 1st input key array
inp1[const] The 2nd input key array
inp2[const] The 3rd input key array
inp3[const] The 4th input key array
inplenThe length of the input key arrays

◆ hkds_shake_256x8()

HKDS_EXPORT_API void hkds_shake_256x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
const uint8_t * inp4,
const uint8_t * inp5,
const uint8_t * inp6,
const uint8_t * inp7,
size_t inplen )

Process 8 SHAKE-256 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
[const]inp0: The 1st input key array
[const]inp1: The 2nd input key array
[const]inp2: The 3rd input key array
[const]inp3: The 4th input key array
[const]inp4: The 5th input key array
[const]inp5: The 6th input key array
[const]inp6: The 7th input key array
[const]inp7: The 8th input key array
inplenThe length of the input key arrays

◆ hkds_shake_512x4()

HKDS_EXPORT_API void hkds_shake_512x4 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
size_t inplen )

Process 4 SHAKE-512 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX2 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
outlenThe length of the output arrays
inp0[const] The 1st input key array
inp1[const] The 2nd input key array
inp2[const] The 3rd input key array
inp3[const] The 4th input key array
inplenThe length of the input key arrays

◆ hkds_shake_512x8()

HKDS_EXPORT_API void hkds_shake_512x8 ( uint8_t * out0,
uint8_t * out1,
uint8_t * out2,
uint8_t * out3,
uint8_t * out4,
uint8_t * out5,
uint8_t * out6,
uint8_t * out7,
size_t outlen,
const uint8_t * inp0,
const uint8_t * inp1,
const uint8_t * inp2,
const uint8_t * inp3,
const uint8_t * inp4,
const uint8_t * inp5,
const uint8_t * inp6,
const uint8_t * inp7,
size_t inplen )

Process 8 SHAKE-512 instances simultaneously using SIMD instructions.

Warning
The input and output arrays must be of the same length. This function requires the AVX512 instruction set.
Parameters
out0The 1st output array
out1The 2nd output array
out2The 3rd output array
out3The 4th output array
out4The 5th output array
out5The 6th output array
out6The 7th output array
out7The 8th output array
outlenThe length of the output arrays
inp0[const] The 1st input key array
inp1[const] The 2nd input key array
inp2[const] The 3rd input key array
inp3[const] The 4th input key array
inp4[const] The 5th input key array
inp5[const] The 6th input key array
inp6[const] The 7th input key array
inp7[const] The 8th input key array
inplenThe length of the input key arrays

◆ hkds_shake_initialize()

HKDS_EXPORT_API void hkds_shake_initialize ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
const uint8_t * key,
size_t keylen )

The SHAKE initialize function. Long form api: must be used in conjunction with the squeezeblocks function. Absorb and finalize an input key byte array.

Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
key[const] The input key byte array
keylenThe number of key bytes to process

◆ hkds_shake_squeezeblocks()

HKDS_EXPORT_API void hkds_shake_squeezeblocks ( hkds_keccak_state * ctx,
hkds_keccak_rate rate,
uint8_t * output,
size_t nblocks )

The SHAKE squeeze function. Long form api: must be used in conjunction with the initialize function. Permutes and extracts the state to an output byte array.

Warning
Output array must be initialized to a multiple of the byte rate. The state must be initialized before calling.
Parameters
ctx[struct] A reference to the Keccak state; must be initialized
rateThe rate of absorption in bytes
outputThe output byte array
nblocksThe number of blocks to extract