45QSC_CPLUSPLUS_ENABLED_START
74#if !defined(QSC_SHA2_SHANI_ENABLED)
82#define QSC_HKDF_256_KEY_SIZE 32ULL
88#define QSC_HKDF_512_KEY_SIZE 64ULL
94#define QSC_HMAC_256_KEY_SIZE 32ULL
100#define QSC_HMAC_512_KEY_SIZE 64ULL
106#define QSC_HMAC_256_MAC_SIZE 32ULL
112#define QSC_HMAC_512_MAC_SIZE 64ULL
118#define QSC_HMAC_256_RATE 64ULL
124#define QSC_HMAC_512_RATE 128ULL
130#define QSC_SHA2_256_HASH_SIZE 32ULL
136#define QSC_SHA2_384_HASH_SIZE 48ULL
142#define QSC_SHA2_512_HASH_SIZE 64ULL
148#define QSC_SHA2_256_RATE 64ULL
154#define QSC_SHA2_384_RATE 128ULL
160#define QSC_SHA2_512_RATE 128ULL
166#define QSC_SHA2_STATE_SIZE 8ULL
549QSC_CPLUSPLUS_ENABLED_END
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
QSC_EXPORT_API void qsc_sha256_finalize(qsc_sha256_state *ctx, uint8_t *output)
Finalize the message state and return the hash value in the output array.
Definition sha2.c:58
QSC_EXPORT_API void qsc_sha384_update(qsc_sha384_state *ctx, const uint8_t *message, size_t msglen)
Update SHA2-384 with message input.
Definition sha2.c:766
QSC_EXPORT_API void qsc_sha512_initialize(qsc_sha512_state *ctx)
Initialize a SHA2-512 state structure.
Definition sha2.c:912
QSC_EXPORT_API void qsc_hkdf256_extract(uint8_t *output, size_t otplen, const uint8_t *key, size_t keylen, const uint8_t *salt, size_t saltlen)
Extract a key from a combined key and salt input using HMAC(SHA2-256).
Definition sha2.c:1539
QSC_EXPORT_API void qsc_sha384_finalize(qsc_sha384_state *ctx, uint8_t *output)
Finalize the SHA2-384 state and return the hash value in the output array.
Definition sha2.c:705
QSC_EXPORT_API void qsc_sha384_dispose(qsc_sha384_state *ctx)
Dispose of the SHA2-384 state.
Definition sha2.c:690
QSC_EXPORT_API void qsc_hmac256_initialize(qsc_hmac256_state *ctx, const uint8_t *key, size_t keylen)
Initialize an HMAC-256 state structure with a key.
Definition sha2.c:1384
QSC_EXPORT_API void qsc_hmac512_update(qsc_hmac512_state *ctx, const uint8_t *message, size_t msglen)
Update HMAC-512 with message input.
Definition sha2.c:1494
QSC_EXPORT_API void qsc_hkdf512_extract(uint8_t *output, size_t otplen, const uint8_t *key, size_t keylen, const uint8_t *salt, size_t saltlen)
Extract a key from a combined key and salt input using HMAC(SHA2-512).
Definition sha2.c:1600
QSC_EXPORT_API void qsc_sha256_initialize(qsc_sha256_state *ctx)
Initialize a SHA2-256 state structure.
Definition sha2.c:108
QSC_EXPORT_API void qsc_sha256_update(qsc_sha256_state *ctx, const uint8_t *message, size_t msglen)
Update SHA2-256 with message input.
Definition sha2.c:609
#define QSC_SHA2_512_RATE
The SHA2-512 absorption rate in bytes.
Definition sha2.h:160
QSC_EXPORT_API void qsc_sha512_compute(uint8_t *output, const uint8_t *message, size_t msglen)
Process a message with SHA2-512 and return the hash code in the output byte array.
Definition sha2.c:834
QSC_EXPORT_API void qsc_hmac512_dispose(qsc_hmac512_state *ctx)
Dispose of the HMAC-512 state.
Definition sha2.c:1437
QSC_EXPORT_API void qsc_hmac256_update(qsc_hmac256_state *ctx, const uint8_t *message, size_t msglen)
Update HMAC-256 with message input.
Definition sha2.c:1413
QSC_EXPORT_API void qsc_hmac256_finalize(qsc_hmac256_state *ctx, uint8_t *output)
Finalize the HMAC-256 state and return the MAC code in the output byte array.
Definition sha2.c:1369
QSC_EXPORT_API void qsc_sha384_initialize(qsc_sha384_state *ctx)
Initialize a SHA2-384 state structure.
Definition sha2.c:755
QSC_EXPORT_API void qsc_hmac512_finalize(qsc_hmac512_state *ctx, uint8_t *output)
Finalize the HMAC-512 state and return the MAC code in the output byte array.
Definition sha2.c:1450
#define QSC_SHA2_256_RATE
The SHA2-256 absorption rate in bytes.
Definition sha2.h:148
QSC_EXPORT_API void qsc_hmac512_initialize(qsc_hmac512_state *ctx, const uint8_t *key, size_t keylen)
Initialize an HMAC-512 state structure with a key.
Definition sha2.c:1465
QSC_EXPORT_API void qsc_hmac256_compute(uint8_t *output, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen)
Process a message with HMAC(SHA2-256) and return the MAC code in the output byte array.
Definition sha2.c:1342
QSC_EXPORT_API void qsc_hkdf256_expand(uint8_t *output, size_t otplen, const uint8_t *key, size_t keylen, const uint8_t *info, size_t infolen)
Initialize an instance of HKDF(HMAC(SHA2-256)) and generate pseudo-random output.
Definition sha2.c:1504
QSC_EXPORT_API void qsc_hkdf512_expand(uint8_t *output, size_t otplen, const uint8_t *key, size_t keylen, const uint8_t *info, size_t infolen)
Initialize an instance of HKDF(HMAC(SHA2-512)) and generate pseudo-random output.
Definition sha2.c:1565
QSC_EXPORT_API void qsc_sha256_compute(uint8_t *output, const uint8_t *message, size_t msglen)
Process a message with SHA2-256 and return the hash code in the output byte array.
Definition sha2.c:46
QSC_EXPORT_API void qsc_sha256_dispose(qsc_sha256_state *ctx)
Dispose of the SHA2-256 state.
Definition sha2.c:33
QSC_EXPORT_API void qsc_sha512_permute(uint64_t *output, const uint8_t *input)
The SHA2-512 permutation function.
Definition sha2.c:923
QSC_EXPORT_API void qsc_hmac256_dispose(qsc_hmac256_state *ctx)
Dispose of the HMAC-256 state.
Definition sha2.c:1356
#define QSC_SHA2_384_RATE
The SHA2-384 absorption rate in bytes.
Definition sha2.h:154
QSC_EXPORT_API void qsc_sha512_finalize(qsc_sha512_state *ctx, uint8_t *output)
Finalize the SHA2-512 state and return the hash value in the output array.
Definition sha2.c:862
QSC_EXPORT_API void qsc_sha256_permute(uint32_t *output, const uint8_t *input)
The SHA2-256 permutation function.
Definition sha2.c:297
QSC_EXPORT_API void qsc_hmac512_compute(uint8_t *output, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen)
Process a message with HMAC(SHA2-512) and return the MAC code in the output byte array.
Definition sha2.c:1423
QSC_EXPORT_API void qsc_sha512_update(qsc_sha512_state *ctx, const uint8_t *message, size_t msglen)
Update SHA2-512 with message input.
Definition sha2.c:1299
QSC_EXPORT_API void qsc_sha512_dispose(qsc_sha512_state *ctx)
Dispose of the SHA2-512 state.
Definition sha2.c:847
#define QSC_SHA2_STATE_SIZE
The SHA2 state array size.
Definition sha2.h:166
QSC_EXPORT_API void qsc_sha384_compute(uint8_t *output, const uint8_t *message, size_t msglen)
Process a message with SHA2-384 and return the hash code in the output byte array.
Definition sha2.c:677
The HMAC(SHA2-256) state array.
Definition sha2.h:378
qsc_sha256_state pstate
Definition sha2.h:379
uint8_t ipad[QSC_SHA2_256_RATE]
Definition sha2.h:380
uint8_t opad[QSC_SHA2_256_RATE]
Definition sha2.h:381
The HMAC(SHA2-512) state array.
Definition sha2.h:442
uint8_t opad[QSC_SHA2_512_RATE]
Definition sha2.h:445
uint8_t ipad[QSC_SHA2_512_RATE]
Definition sha2.h:444
qsc_sha512_state pstate
Definition sha2.h:443
The SHA2-256 digest state array.
Definition sha2.h:175
uint32_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:176
uint64_t t
Definition sha2.h:178
size_t position
Definition sha2.h:179
uint8_t buffer[QSC_SHA2_256_RATE]
Definition sha2.h:177
The SHA2-384 digest state array.
Definition sha2.h:245
uint8_t buffer[QSC_SHA2_384_RATE]
Definition sha2.h:248
uint64_t t[2]
Definition sha2.h:247
size_t position
Definition sha2.h:249
uint64_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:246
The SHA2-512 digest state array.
Definition sha2.h:306
uint64_t t[2]
Definition sha2.h:308
size_t position
Definition sha2.h:310
uint64_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:307
uint8_t buffer[QSC_SHA2_512_RATE]
Definition sha2.h:309