57QSC_CPLUSPLUS_ENABLED_START
90#define QSC_HKDF_256_KEY_SIZE 32U
96#define QSC_HKDF_512_KEY_SIZE 64U
102#define QSC_HMAC_256_KEY_SIZE 32U
108#define QSC_HMAC_512_KEY_SIZE 64U
114#define QSC_HMAC_256_MAC_SIZE 32U
120#define QSC_HMAC_512_MAC_SIZE 64U
126#define QSC_HMAC_256_RATE 64U
132#define QSC_HMAC_512_RATE 128U
138#define QSC_SHA2_256_HASH_SIZE 32U
144#define QSC_SHA2_384_HASH_SIZE 48U
150#define QSC_SHA2_512_HASH_SIZE 64U
156#define QSC_SHA2_256_RATE 64U
162#define QSC_SHA2_384_RATE 128U
168#define QSC_SHA2_512_RATE 128U
174#define QSC_SHA2_STATE_SIZE 8U
621QSC_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 qsccommon.h:605
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:56
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:782
QSC_EXPORT_API void qsc_sha512_initialize(qsc_sha512_state *ctx)
Initialize a SHA2-512 state structure.
Definition sha2.c:930
QSC_EXPORT_API void qsc_hmac384_dispose(qsc_hmac384_state *ctx)
Dispose of the HMAC-384 state.
Definition sha2.c:1464
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:1663
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:714
QSC_EXPORT_API void qsc_sha384_dispose(qsc_sha384_state *ctx)
Dispose of the SHA2-384 state.
Definition sha2.c:700
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:1409
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:1611
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:1731
QSC_EXPORT_API void qsc_hmac384_initialize(qsc_hmac384_state *ctx, const uint8_t *key, size_t keylen)
Initialize an HMAC-384 state structure with a key.
Definition sha2.c:1494
QSC_EXPORT_API void qsc_sha256_initialize(qsc_sha256_state *ctx)
Initialize a SHA2-256 state structure.
Definition sha2.c:110
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:617
#define QSC_SHA2_512_RATE
The SHA2-512 absorption rate in bytes.
Definition sha2.h:168
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:850
QSC_EXPORT_API void qsc_hmac512_dispose(qsc_hmac512_state *ctx)
Dispose of the HMAC-512 state.
Definition sha2.c:1549
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:1441
QSC_EXPORT_API void qsc_hmac384_compute(uint8_t *output, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen)
Process a message with HMAC(SHA2-384) and return the MAC code in the output byte array.
Definition sha2.c:1451
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:1391
QSC_EXPORT_API void qsc_sha384_initialize(qsc_sha384_state *ctx)
Initialize a SHA2-384 state structure.
Definition sha2.c:768
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:1561
#define QSC_SHA2_256_RATE
The SHA2-256 absorption rate in bytes.
Definition sha2.h:156
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:1579
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:1366
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:1621
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:1690
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:44
QSC_EXPORT_API void qsc_sha256_dispose(qsc_sha256_state *ctx)
Dispose of the SHA2-256 state.
Definition sha2.c:31
QSC_EXPORT_API void qsc_sha512_permute(uint64_t *output, const uint8_t *input)
The SHA2-512 permutation function.
Definition sha2.c:944
QSC_EXPORT_API void qsc_hmac256_dispose(qsc_hmac256_state *ctx)
Dispose of the HMAC-256 state.
Definition sha2.c:1379
#define QSC_SHA2_384_RATE
The SHA2-384 absorption rate in bytes.
Definition sha2.h:162
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:876
QSC_EXPORT_API void qsc_sha256_permute(uint32_t *output, const uint8_t *input)
The SHA2-256 permutation function.
Definition sha2.c:302
QSC_EXPORT_API void qsc_hmac384_finalize(qsc_hmac384_state *ctx, uint8_t *output)
Finalize the HMAC-384 state and return the MAC code in the output byte array.
Definition sha2.c:1476
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:1536
QSC_EXPORT_API void qsc_hmac384_update(qsc_hmac384_state *ctx, const uint8_t *message, size_t msglen)
Update HMAC-384 with message input.
Definition sha2.c:1526
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:1323
QSC_EXPORT_API void qsc_sha512_dispose(qsc_sha512_state *ctx)
Dispose of the SHA2-512 state.
Definition sha2.c:862
#define QSC_SHA2_STATE_SIZE
The SHA2 state array size.
Definition sha2.h:174
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:688
The HMAC(SHA2-256) state array.
Definition sha2.h:386
qsc_sha256_state pstate
Definition sha2.h:387
uint8_t ipad[QSC_SHA2_256_RATE]
Definition sha2.h:388
uint8_t opad[QSC_SHA2_256_RATE]
Definition sha2.h:389
The HMAC(SHA2-384) state array.
Definition sha2.h:450
qsc_sha384_state pstate
Definition sha2.h:451
uint8_t opad[QSC_SHA2_384_RATE]
Definition sha2.h:453
uint8_t ipad[QSC_SHA2_384_RATE]
Definition sha2.h:452
The HMAC(SHA2-512) state array.
Definition sha2.h:514
uint8_t opad[QSC_SHA2_512_RATE]
Definition sha2.h:517
uint8_t ipad[QSC_SHA2_512_RATE]
Definition sha2.h:516
qsc_sha512_state pstate
Definition sha2.h:515
The SHA2-256 digest state array.
Definition sha2.h:183
uint32_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:184
uint64_t t
Definition sha2.h:186
size_t position
Definition sha2.h:187
uint8_t buffer[QSC_SHA2_256_RATE]
Definition sha2.h:185
The SHA2-384 digest state array.
Definition sha2.h:253
uint8_t buffer[QSC_SHA2_384_RATE]
Definition sha2.h:256
size_t position
Definition sha2.h:257
uint64_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:254
uint64_t t[2U]
Definition sha2.h:255
The SHA2-512 digest state array.
Definition sha2.h:314
size_t position
Definition sha2.h:318
uint64_t state[QSC_SHA2_STATE_SIZE]
Definition sha2.h:315
uint64_t t[2U]
Definition sha2.h:316
uint8_t buffer[QSC_SHA2_512_RATE]
Definition sha2.h:317