QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
sha3.h File Reference

SHA3 family of hash functions. More...

#include "common.h"

Go to the source code of this file.

Data Structures

struct  qsc_keccak_state
 The Keccak state array; state array must be initialized by the caller. More...
 
struct  qsc_kpa_state
 The KPA state array; state array must be initialized by the caller. More...
 

Macros

#define QSC_KECCAK_CSHAKE_DOMAIN_ID   0x04U
 The cSHAKE domain id.
 
#define QSC_KECCAK_KMAC_DOMAIN_ID   0x04U
 The KMAC domain id.
 
#define QSC_KECCAK_KPA_DOMAIN_ID   0x41U
 The KPA domain id.
 
#define QSC_KECCAK_PERMUTATION_ROUNDS   24ULL
 The standard number of permutation rounds.
 
#define QSC_KECCAK_PERMUTATION_MAX_ROUNDS   48ULL
 The maximum number of permutation rounds.
 
#define QSC_KECCAK_PERMUTATION_MIN_ROUNDS   12ULL
 The minimum number of permutation rounds.
 
#define QSC_KECCAK_SHA3_DOMAIN_ID   0x06U
 The SHA3 domain id.
 
#define QSC_KECCAK_SHAKE_DOMAIN_ID   0x1FU
 The SHAKE domain id.
 
#define QSC_KECCAK_STATE_BYTE_SIZE   200ULL
 The Keccak state array byte size.
 
#define QSC_KECCAK_128_RATE   168ULL
 The 128-bit absorption rate.
 
#define QSC_KECCAK_256_RATE   136ULL
 The 256-bit absorption rate.
 
#define QSC_KECCAK_512_RATE   72ULL
 The 512 bit absorption rate.
 
#define QSC_KECCAK_STATE_SIZE   25ULL
 The Keccak SHA3 uint64 state array size.
 
#define QSC_KECCAK_STATE_BYTE_SIZE   200ULL
 The Keccak state array byte size.
 
#define QSC_KMAC_256_KEY_SIZE   32ULL
 The KMAC-256 key size in bytes.
 
#define QSC_KMAC_512_KEY_SIZE   64ULL
 The KMAC-512 key size in bytes.
 
#define QSC_KECCAK_SCBKDF_DOMAIN_ID   0x42U
 The SCBKDF domain id.
 
#define QSC_SHA3_128_HASH_SIZE   16ULL
 The QSC_SHA3_128_HASH_SIZE hash size in bytes (16)
 
#define QSC_SHA3_256_HASH_SIZE   32ULL
 The SHA-256 hash size in bytes (32)
 
#define QSC_SHA3_512_HASH_SIZE   64ULL
 The SHA-512 hash size in bytes (64)
 
#define QSC_SHAKE_256_KEY_SIZE   32ULL
 The SHAKE-256 key size in bytes.
 
#define QSC_SHAKE512_KEY_SIZE   64ULL
 The SHAKE-512 key size in bytes.
 
#define QSC_KPA_128_KEY_SIZE   16ULL
 The KPA-128 key size in bytes.
 
#define QSC_KPA_256_KEY_SIZE   32ULL
 The KPA-256 key size in bytes.
 
#define QSC_KPA_512_KEY_SIZE   64ULL
 The KPA-512 key size in bytes.
 
#define QSC_KPA_ROUNDS   12ULL
 The number of Keccak rounds used by a KPA permutation.
 
#define QSC_KPA_PARALLELISM   8ULL
 The KPA degree of parallelization.
 

Enumerations

enum  qsc_keccak_rate { qsc_keccak_rate_none = 0x00U , qsc_keccak_rate_128 = 0xA8U , qsc_keccak_rate_256 = 0x88U , qsc_keccak_rate_512 = 0x48U }
 The Keccak rate; determines which security strength is used by the function, 128, 256, or 512-bit. More...
 

Functions

QSC_EXPORT_API void qsc_keccak_absorb (qsc_keccak_state *ctx, qsc_keccak_rate rate, const uint8_t *message, size_t msglen, uint8_t domain, size_t rounds)
 Absorb an input message into the Keccak state.
 
QSC_EXPORT_API void qsc_keccak_absorb_custom (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_keccak_absorb_key_custom (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_keccak_dispose (qsc_keccak_state *ctx)
 Dispose of the Keccak state.
 
QSC_EXPORT_API void qsc_keccak_finalize (qsc_keccak_state *ctx, qsc_keccak_rate rate, uint8_t *output, size_t outlen, uint8_t domain, size_t rounds)
 Finalize the Keccak state.
 
QSC_EXPORT_API void qsc_keccak_incremental_absorb (qsc_keccak_state *ctx, uint32_t rate, const uint8_t *message, size_t msglen)
 Absorb bytes into state incrementally.
 
QSC_EXPORT_API void qsc_keccak_incremental_finalize (qsc_keccak_state *ctx, uint32_t rate, uint8_t domain)
 Finalize state added incrementally.
 
QSC_EXPORT_API void qsc_keccak_incremental_squeeze (qsc_keccak_state *ctx, size_t rate, uint8_t *output, size_t outlen)
 Extract an array of bytes from the Keccak state.
 
QSC_EXPORT_API void qsc_keccak_permute (qsc_keccak_state *ctx, size_t rounds)
 The Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_keccak_permute_p1600u (uint64_t *state)
 The unrolled Keccak permute function. Internal function: Permutes the state array, can be used in external constructions.
 
QSC_EXPORT_API void qsc_keccak_squeezeblocks (qsc_keccak_state *ctx, uint8_t *output, size_t nblocks, qsc_keccak_rate rate, size_t rounds)
 The Keccak squeeze function.
 
QSC_EXPORT_API void qsc_keccak_initialize_state (qsc_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.
 
QSC_EXPORT_API void qsc_keccak_update (qsc_keccak_state *ctx, qsc_keccak_rate rate, const uint8_t *message, size_t msglen, size_t rounds)
 Update Keccak state with message input.
 
QSC_EXPORT_API void qsc_sha3_compute128 (uint8_t *output, const uint8_t *message, size_t msglen)
 Process a message with SHA3-128 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.
 
QSC_EXPORT_API void qsc_sha3_compute256 (uint8_t *output, const uint8_t *message, size_t msglen)
 Process a message with SHA3-256 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.
 
QSC_EXPORT_API void qsc_sha3_compute512 (uint8_t *output, const uint8_t *message, size_t msglen)
 Process a message with SHA3-512 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.
 
QSC_EXPORT_API void qsc_sha3_finalize (qsc_keccak_state *ctx, qsc_keccak_rate rate, uint8_t *output)
 Finalize the message state and returns the hash value in output. Long form api: must be used in conjunction with the initialize and block-update functions. Absorb the last block of message and create the hash value. Produces a 32 byte output code using QSC_KECCAK_256_RATE, 64 bytes with QSC_KECCAK_512_RATE.
 
QSC_EXPORT_API void qsc_sha3_initialize (qsc_keccak_state *ctx)
 Initialize the SHA3 state Long form api: Must be called before the update or finalize functions are called.
 
QSC_EXPORT_API void qsc_sha3_update (qsc_keccak_state *ctx, qsc_keccak_rate rate, const uint8_t *message, size_t msglen)
 Update SHA3 with message input. Long form api: must be used in conjunction with the initialize and finalize functions. Absorbs the input message into the state.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_shake_initialize (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_shake_squeezeblocks (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_cshake128_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen, const uint8_t *name, size_t namelen, const uint8_t *custom, size_t custlen)
 Key a cSHAKE-128 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array..
 
QSC_EXPORT_API void qsc_cshake256_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen, const uint8_t *name, size_t namelen, const uint8_t *custom, size_t custlen)
 Key a cSHAKE-256 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array.
 
QSC_EXPORT_API void qsc_cshake512_compute (uint8_t *output, size_t outlen, const uint8_t *key, size_t keylen, const uint8_t *name, size_t namelen, const uint8_t *custom, size_t custlen)
 Key a cSHAKE-512 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array.
 
QSC_EXPORT_API void qsc_cshake_initialize (qsc_keccak_state *ctx, qsc_keccak_rate rate, const uint8_t *key, size_t keylen, const uint8_t *name, size_t namelen, const uint8_t *custom, size_t custlen)
 The cSHAKE initialize function. Long form api: must be used in conjunction with the squeezeblocks function. Initialize the name and customization strings into the state.
 
QSC_EXPORT_API void qsc_cshake_squeezeblocks (qsc_keccak_state *ctx, qsc_keccak_rate rate, uint8_t *output, size_t nblocks)
 The cSHAKE squeeze function. Long form api: must be used in conjunction with the initialize function. Permutes and extracts blocks of state to an output byte array.
 
QSC_EXPORT_API void qsc_cshake_update (qsc_keccak_state *ctx, qsc_keccak_rate rate, const uint8_t *key, size_t keylen)
 The cSHAKE update function. Long form api: must be used in conjunction with the initialize and squeezeblocks functions. Finalize an input key directly into the state.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_kmac_update (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_kmac_finalize (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_kmac_initialize (qsc_keccak_state *ctx, qsc_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.
 
QSC_EXPORT_API void qsc_kpa_finalize (qsc_kpa_state *ctx, uint8_t *output, size_t outlen)
 The KPA finalize function. Long form api: must be used in conjunction with the initialize and blockupdate functions. Final processing and calculation of the MAC code.
 
QSC_EXPORT_API void qsc_kpa_initialize (qsc_kpa_state *ctx, const uint8_t *key, size_t keylen, const uint8_t *custom, size_t custlen)
 Initialize a KPA instance. Long form api: must be used in conjunction with the blockupdate and finalize functions. Key the MAC generator and initialize the internal state.
 
QSC_EXPORT_API void qsc_kpa_update (qsc_kpa_state *ctx, const uint8_t *message, size_t msglen)
 The KPA message update function. Long form api: must be used in conjunction with the initialize and finalize functions.
 
QSC_EXPORT_API void qsc_kpa_dispose (qsc_kpa_state *ctx)
 Dispose of the KPA state.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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.
 
QSC_EXPORT_API void qsc_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 family of hash functions.

This header defines the public API and documentation for SHA3 digest, SHAKE, cSHAKE, and KMAC implementations. The API supports both short-form functions (processing an entire message in one call) and long-form functions (initialize, update, finalize) for incremental processing of data.

// Example: SHA3-512 hash computation using the long-form API
#define MSGLEN 200
uint8_t msg[MSGLEN] = { ... };
uint8_t hash[QSC_SHA3_512_HASH_SIZE] = { 0 };
qsc_sha3_initialize(ctx.state);
qsc_sha3_update(&ctx, qsc_keccak_rate_512, msg, MSGLEN);
qsc_sha3_finalize(&ctx, qsc_keccak_rate_512, hash);
// Example: KMAC-256 MAC code generation using the long-form API
#define MSGLEN 200
uint8_t msg[MSGLEN] = { ... };
uint8_t key[QSC_KMAC_256_KEY_SIZE] = { ... };
uint8_t cust[...] = { ... };
uint8_t code[QSC_KMAC_256_MAC_SIZE] = { 0 };
qsc_kmac_initialize(&ctx2, qsc_keccak_rate_256, key, sizeof(key), cust, sizeof(cust));
qsc_kmac_update(&ctx2, qsc_keccak_rate_256, msg, MSGLEN);
qsc_kmac_finalize(&ctx2, qsc_keccak_rate_256, code, sizeof(code));
// Example: cSHAKE-512 pseudo-random generation using the long-form API
uint8_t output[64] = { 0 };
uint8_t key2[QSC_KMAC_512_KEY_SIZE] = { ... };
uint8_t cust2[...] = { ... };
uint8_t name[...] = { ... };
qsc_cshake_initialize(&ctx3, key2, sizeof(key2), name, sizeof(name), cust2, sizeof(cust2));
qsc_cshake_squeezeblocks(&ctx3, output, 1);
@ qsc_keccak_rate_256
Definition sha3.h:254
@ qsc_keccak_rate_512
Definition sha3.h:255
#define QSC_KMAC_512_KEY_SIZE
The KMAC-512 key size in bytes.
Definition sha3.h:195
#define QSC_KMAC_256_KEY_SIZE
The KMAC-256 key size in bytes.
Definition sha3.h:189
#define QSC_SHA3_512_HASH_SIZE
The SHA-512 hash size in bytes (64)
Definition sha3.h:219
The Keccak state array; state array must be initialized by the caller.
Definition sha3.h:240
uint64_t state[QSC_KECCAK_STATE_SIZE]
Definition sha3.h:241

Reference Links:

Macro Definition Documentation

◆ QSC_KECCAK_STATE_BYTE_SIZE [1/2]

#define QSC_KECCAK_STATE_BYTE_SIZE   200ULL

The Keccak state array byte size.

The Keccak SHA3 state size in bytes.

◆ QSC_KECCAK_STATE_BYTE_SIZE [2/2]

#define QSC_KECCAK_STATE_BYTE_SIZE   200ULL

The Keccak state array byte size.

The Keccak SHA3 state size in bytes.

Enumeration Type Documentation

◆ qsc_keccak_rate

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

Enumerator
qsc_keccak_rate_none 

No bit rate was selected

qsc_keccak_rate_128 

The Keccak 128-bit rate

qsc_keccak_rate_256 

The Keccak 256-bit rate

qsc_keccak_rate_512 

The Keccak 512-bit rate

Function Documentation

◆ qsc_cshake128_compute()

QSC_EXPORT_API void qsc_cshake128_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen,
const uint8_t * name,
size_t namelen,
const uint8_t * custom,
size_t custlen )

Key a cSHAKE-128 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array..

Parameters
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_cshake256_compute()

QSC_EXPORT_API void qsc_cshake256_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen,
const uint8_t * name,
size_t namelen,
const uint8_t * custom,
size_t custlen )

Key a cSHAKE-256 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array.

Parameters
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_cshake512_compute()

QSC_EXPORT_API void qsc_cshake512_compute ( uint8_t * output,
size_t outlen,
const uint8_t * key,
size_t keylen,
const uint8_t * name,
size_t namelen,
const uint8_t * custom,
size_t custlen )

Key a cSHAKE-512 instance and generate pseudo-random output. Short form api: processes the key, name, and custom inputs and generates the pseudo-random output with a single call. Permutes and extracts the state to an output byte array.

Parameters
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_cshake_initialize()

QSC_EXPORT_API void qsc_cshake_initialize ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
const uint8_t * key,
size_t keylen,
const uint8_t * name,
size_t namelen,
const uint8_t * custom,
size_t custlen )

The cSHAKE initialize function. Long form api: must be used in conjunction with the squeezeblocks function. Initialize the name and customization strings into the state.

Parameters
ctx[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_cshake_squeezeblocks()

QSC_EXPORT_API void qsc_cshake_squeezeblocks ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
uint8_t * output,
size_t nblocks )

The cSHAKE squeeze function. Long form api: must be used in conjunction with the initialize function. Permutes and extracts blocks of 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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
output[uint8_t*] The output byte array
nblocks[size_t] The number of blocks to extract

◆ qsc_cshake_update()

QSC_EXPORT_API void qsc_cshake_update ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
const uint8_t * key,
size_t keylen )

The cSHAKE update function. Long form api: must be used in conjunction with the initialize and squeezeblocks functions. Finalize an input key directly into the state.

Warning
Finalizes the key state, should not be used in consecutive calls. The state must be initialized before calling.
Parameters
ctx[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process

◆ qsc_keccak_absorb()

QSC_EXPORT_API void qsc_keccak_absorb ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
message[const uint8_t*] The input message byte array
msglen[size_t] The number of message bytes to process
domain[uint8_t] The function domain id
rounds[size_t] The number of permutation rounds, the default is 24, maximum is 48

◆ qsc_keccak_absorb_custom()

QSC_EXPORT_API void qsc_keccak_absorb_custom ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] The Keccak state structure
rate[qsc_keccak_rate] The rate of absorption in bytes
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
rounds[size_t] The number of permutation rounds, the default is 24, maximum is 48

◆ qsc_keccak_absorb_key_custom()

QSC_EXPORT_API void qsc_keccak_absorb_key_custom ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] The Keccak state structure
rate[qsc_keccak_rate] The rate of absorption in bytes
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string
name[const uint8_t*] The function name string
namelen[size_t] The byte length of the function name
rounds[size_t] The number of permutation rounds, the default is 24, maximum is 48

◆ qsc_keccak_dispose()

QSC_EXPORT_API void qsc_keccak_dispose ( qsc_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[qsc_keccak_state*] The Keccak state structure

◆ qsc_keccak_finalize()

QSC_EXPORT_API void qsc_keccak_finalize ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
uint8_t * output,
size_t outlen,
uint8_t domain,
size_t rounds )

Finalize the Keccak state.

Parameters
ctx[qsc_keccak_state*] The Keccak state structure
rate[qsc_keccak_rate] The rate of absorption in bytes
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
domain[size_t] The function domain id
rounds[size_t] The number of permutation rounds, the default is 24, maximum is 48

◆ qsc_keccak_incremental_absorb()

QSC_EXPORT_API void qsc_keccak_incremental_absorb ( qsc_keccak_state * ctx,
uint32_t rate,
const uint8_t * message,
size_t msglen )

Absorb bytes into state incrementally.

Parameters
ctx[qsc_keccak_state*] The function state
rate[qsc_keccak_rate] The rate of absorption in bytes
message[const uint8_t*] The input message array
msglen[size_t] The number of message bytes

◆ qsc_keccak_incremental_finalize()

QSC_EXPORT_API void qsc_keccak_incremental_finalize ( qsc_keccak_state * ctx,
uint32_t rate,
uint8_t domain )

Finalize state added incrementally.

Parameters
ctx[qsc_keccak_state*] The function state
rate[uint32_t] The rate of absorption in bytes
domain[uint8_t] The function domain id

◆ qsc_keccak_incremental_squeeze()

QSC_EXPORT_API void qsc_keccak_incremental_squeeze ( qsc_keccak_state * ctx,
size_t rate,
uint8_t * output,
size_t outlen )

Extract an array of bytes from the Keccak state.

Parameters
ctx[qsc_keccak_state*] The function state
rate[size_t] The rate of absorption in bytes
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate

◆ qsc_keccak_initialize_state()

QSC_EXPORT_API void qsc_keccak_initialize_state ( qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized

◆ qsc_keccak_permute()

QSC_EXPORT_API void qsc_keccak_permute ( qsc_keccak_state * ctx,
size_t rounds )

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

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

◆ qsc_keccak_permute_p1600c()

QSC_EXPORT_API void qsc_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
state[uint64_t*] The state array; must be initialized
rounds[size_t] The number of permutation rounds, the default and maximum is 24

◆ qsc_keccak_permute_p1600u()

QSC_EXPORT_API void qsc_keccak_permute_p1600u ( uint64_t * state)

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

Parameters
state[uint64_t*] The state array; must be initialized

◆ qsc_keccak_squeezeblocks()

QSC_EXPORT_API void qsc_keccak_squeezeblocks ( qsc_keccak_state * ctx,
uint8_t * output,
size_t nblocks,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
output[uint8_t*] The output byte array
nblocks[size_t] The number of blocks to extract
rate[qsc_keccak_rate] The rate of absorption in bytes
rounds[size_t] The number of permutation rounds, the default and maximum is 24

◆ qsc_keccak_update()

QSC_EXPORT_API void qsc_keccak_update ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
message[const uint8_t*] The input message byte array
msglen[size_t] The number of message bytes to process
rounds[size_t] The number of permutation rounds, the default and maximum is 24

◆ qsc_kmac128_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The MAC code byte array
outlen[size_t] The number of MAC code bytes to generate
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_kmac256_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The MAC code byte array
outlen[size_t] The number of MAC code bytes to generate
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_kmac512_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The MAC code byte array
outlen[size_t] The number of MAC code bytes to generate
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_kmac_128x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[uint8_t*] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
keylen[size_t] The length of the input key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t*] The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_128x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
key4[const uint8_t*] The 5th key array
key5[const uint8_t*] The 6th key array
key6[const uint8_t* The 7th key array
key7[const uint8_t*] The 8th key array
keylen[size_t] The length of the key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cst4[const uint8_t*] The 5th custom array
cst5[const uint8_t*] The 6th custom array
cst6[const uint8_t*] The 7th custom array
cst7[const uint8_t*] The 8th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t* The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msg4[const uint8_t*] The 5th message array
msg5[const uint8_t*] The 6th message array
msg6[const uint8_t*] The 7th message array
msg7[const uint8_t*] The 8th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_256x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[uint8_t*] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
keylen[size_t] The length of the input key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t*] The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_256x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
key4[const uint8_t*] The 5th key array
key5[const uint8_t*] The 6th key array
key6[const uint8_t* The 7th key array
key7[const uint8_t*] The 8th key array
keylen[size_t] The length of the key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cst4[const uint8_t*] The 5th custom array
cst5[const uint8_t*] The 6th custom array
cst6[const uint8_t*] The 7th custom array
cst7[const uint8_t*] The 8th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t* The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msg4[const uint8_t*] The 5th message array
msg5[const uint8_t*] The 6th message array
msg6[const uint8_t*] The 7th message array
msg7[const uint8_t*] The 8th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_512x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[uint8_t*] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
keylen[size_t] The length of the input key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t*] The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_512x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
key0[const uint8_t*] The 1st key array
key1[const uint8_t*] The 2nd key array
key2[const uint8_t*] The 3rd key array
key3[const uint8_t*] The 4th key array
key4[const uint8_t*] The 5th key array
key5[const uint8_t*] The 6th key array
key6[const uint8_t* The 7th key array
key7[const uint8_t*] The 8th key array
keylen[size_t] The length of the key arrays
cst0[const uint8_t*] The 1st custom array
cst1[const uint8_t*] The 2nd custom array
cst2[const uint8_t*] The 3rd custom array
cst3[const uint8_t*] The 4th custom array
cst4[const uint8_t*] The 5th custom array
cst5[const uint8_t*] The 6th custom array
cst6[const uint8_t*] The 7th custom array
cst7[const uint8_t*] The 8th custom array
cstlen[size_t] The length of the custom arrays
msg0[const uint8_t* The 1st message array
msg1[const uint8_t*] The 2nd message array
msg2[const uint8_t*] The 3rd message array
msg3[const uint8_t*] The 4th message array
msg4[const uint8_t*] The 5th message array
msg5[const uint8_t*] The 6th message array
msg6[const uint8_t*] The 7th message array
msg7[const uint8_t*] The 8th message array
msglen[size_t] The length of the message arrays

◆ qsc_kmac_finalize()

QSC_EXPORT_API void qsc_kmac_finalize ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
output[uint8_t*] The output byte array
outlen[size_t] The number of bytes to extract

◆ qsc_kmac_initialize()

QSC_EXPORT_API void qsc_kmac_initialize ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_kmac_update()

QSC_EXPORT_API void qsc_kmac_update ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process

◆ qsc_kpa_dispose()

QSC_EXPORT_API void qsc_kpa_dispose ( qsc_kpa_state * ctx)

Dispose of the KPA state.

Warning
The dispose function must be called when disposing of the function state. This function safely destroys the internal state.
Parameters
ctx[qsc_kpa_state*] A reference to the KPA state structure; must be initialized

◆ qsc_kpa_finalize()

QSC_EXPORT_API void qsc_kpa_finalize ( qsc_kpa_state * ctx,
uint8_t * output,
size_t outlen )

The KPA 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[qsc_kpa_state*] A reference to the KPA state structure; must be initialized
output[uint8_t*] The output byte array
outlen[size_t] The number of bytes to extract

◆ qsc_kpa_initialize()

QSC_EXPORT_API void qsc_kpa_initialize ( qsc_kpa_state * ctx,
const uint8_t * key,
size_t keylen,
const uint8_t * custom,
size_t custlen )

Initialize a KPA 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[qsc_kpa_state*] A reference to the KPA state structure; must be initialized
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process
custom[const uint8_t*] The customization string
custlen[size_t] The byte length of the customization string

◆ qsc_kpa_update()

QSC_EXPORT_API void qsc_kpa_update ( qsc_kpa_state * ctx,
const uint8_t * message,
size_t msglen )

The KPA 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[qsc_kpa_state*] A reference to the KPA state structure; must be initialized
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process

◆ qsc_sha3_compute128()

QSC_EXPORT_API void qsc_sha3_compute128 ( uint8_t * output,
const uint8_t * message,
size_t msglen )

Process a message with SHA3-128 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.

Warning
The output array must be at least 16 bytes in length.
Parameters
output[uint8_t*] The output byte array; receives the hash code
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process

◆ qsc_sha3_compute256()

QSC_EXPORT_API void qsc_sha3_compute256 ( uint8_t * output,
const uint8_t * message,
size_t msglen )

Process a message with SHA3-256 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.

Warning
The output array must be at least 32 bytes in length.
Parameters
output[uint8_t*] The output byte array; receives the hash code
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process

◆ qsc_sha3_compute512()

QSC_EXPORT_API void qsc_sha3_compute512 ( uint8_t * output,
const uint8_t * message,
size_t msglen )

Process a message with SHA3-512 and return the hash code in the output byte array. Short form api: processes the entire message and computes the hash code with a single call.

Warning
The output array must be at least 64 bytes in length.
Parameters
output[uint8_t*] The output byte array; receives the hash code
message[const uint8_t*] The message input byte array
msglen[size_t] The number of message bytes to process

◆ qsc_sha3_finalize()

QSC_EXPORT_API void qsc_sha3_finalize ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
uint8_t * output )

Finalize the message state and returns the hash value in output. Long form api: must be used in conjunction with the initialize and block-update functions. Absorb the last block of message and create the hash value. Produces a 32 byte output code using QSC_KECCAK_256_RATE, 64 bytes with QSC_KECCAK_512_RATE.

Warning
The output array must be sized correctly corresponding to the absorption rate ((200 - rate) / 2). Finalizes the message state, can not be used in consecutive calls. The state must be initialized before calling.
Parameters
ctx[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
output[uint8_t*] The output byte array; receives the hash code

◆ qsc_sha3_initialize()

QSC_EXPORT_API void qsc_sha3_initialize ( qsc_keccak_state * ctx)

Initialize the SHA3 state Long form api: Must be called before the update or finalize functions are called.

Parameters
ctx[qsc_keccak_state*] A reference to the Keccak state

◆ qsc_sha3_update()

QSC_EXPORT_API void qsc_sha3_update ( qsc_keccak_state * ctx,
qsc_keccak_rate rate,
const uint8_t * message,
size_t msglen )

Update SHA3 with message input. Long form api: must be used in conjunction with the initialize and finalize functions. Absorbs the input message into the state.

Warning
The state must be initialized before calling
Parameters
ctx[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
message[const uint8_t*] The input message byte array
msglen[size_t] The number of message bytes to process

◆ qsc_shake128_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process

◆ qsc_shake256_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process

◆ qsc_shake512_compute()

QSC_EXPORT_API void qsc_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
output[uint8_t*] The output byte array
outlen[size_t] The number of output bytes to generate
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process

◆ qsc_shake_128x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_128x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inp4[const uint8_t*] The 5th input key array
inp5[const uint8_t*] The 6th input key array
inp6[const uint8_t*] The 7th input key array
inp7[const uint8_t*] The 8th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_256x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_256x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inp4[const uint8_t*] The 5th input key array
inp5[const uint8_t*] The 6th input key array
inp6[const uint8_t*] The 7th input key array
inp7[const uint8_t*] The 8th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_512x4()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] The 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_512x8()

QSC_EXPORT_API void qsc_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
out0[uint8_t*] The 1st output array
out1[uint8_t*] 2nd output array
out2[uint8_t*] The 3rd output array
out3[uint8_t*] The 4th output array
out4[uint8_t*] The 5th output array
out5[uint8_t*] The 6th output array
out6[uint8_t*] The 7th output array
out7[uint8_t*] The 8th output array
outlen[size_t] The length of the output arrays
inp0[const uint8_t*] The 1st input key array
inp1[const uint8_t*] The 2nd input key array
inp2[const uint8_t*] The 3rd input key array
inp3[const uint8_t*] The 4th input key array
inp4[const uint8_t*] The 5th input key array
inp5[const uint8_t*] The 6th input key array
inp6[const uint8_t*] The 7th input key array
inp7[const uint8_t*] The 8th input key array
inplen[size_t] The length of the input key arrays

◆ qsc_shake_initialize()

QSC_EXPORT_API void qsc_shake_initialize ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
key[const uint8_t*] The input key byte array
keylen[size_t] The number of key bytes to process

◆ qsc_shake_squeezeblocks()

QSC_EXPORT_API void qsc_shake_squeezeblocks ( qsc_keccak_state * ctx,
qsc_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[qsc_keccak_state*] A reference to the Keccak state; must be initialized
rate[qsc_keccak_rate] The rate of absorption in bytes
output[uint8_t*] The output byte array
nblocks[size_t] The number of blocks to extract