|
Leancrypto 1.6.0
Post-Quantum Cryptographic Library
|
Macros | |
| #define | LC_KMAC_CTX_ON_STACK(name, hashname) |
| Allocate stack memory for the KMAC context. | |
| #define | LC_KMAC_CTX_ON_STACK_REINIT(name, hashname) |
| Allocate stack memory for the KMAC context. | |
Functions | |
| int | lc_kmac_init (struct lc_kmac_ctx *kmac_ctx, const uint8_t *key, size_t klen, const uint8_t *s, size_t slen) |
| Initialize KMAC context. | |
| void | lc_kmac_reinit (struct lc_kmac_ctx *kmac_ctx) |
| Re-initialize KMAC context after a kmac_final operation. | |
| void | lc_kmac_update (struct lc_kmac_ctx *kmac_ctx, const uint8_t *in, size_t inlen) |
| Update KMAC. | |
| void | lc_kmac_final (struct lc_kmac_ctx *kmac_ctx, uint8_t *mac, size_t maclen) |
| Calculate KMAC MAC. | |
| void | lc_kmac_final_xof (struct lc_kmac_ctx *kmac_ctx, uint8_t *mac, size_t maclen) |
| Calculate KMAC MAC in XOF mode. | |
| int | lc_kmac_alloc (const struct lc_hash *hash, struct lc_kmac_ctx **kmac_ctx, uint32_t flags) |
| Allocate KMAC context on heap. | |
| void | lc_kmac_zero_free (struct lc_kmac_ctx *kmac_ctx) |
| Zeroize and free KMAC context. | |
| void | lc_kmac_zero (struct lc_kmac_ctx *kmac_ctx) |
| Zeroize KMAC context allocated with either LC_KMAC_CTX_ON_STACK or lc_kmac_alloc. | |
| size_t | lc_kmac_macsize (struct lc_kmac_ctx *kmac_ctx) |
| Return the MAC size. | |
| int | lc_kmac (const struct lc_hash *hash, const uint8_t *key, size_t keylen, const uint8_t *s, size_t slen, const uint8_t *in, size_t inlen, uint8_t *mac, size_t maclen) |
| Calculate KMAC - one-shot. | |
| int | lc_kmac_xof (const struct lc_hash *hash, const uint8_t *key, size_t keylen, const uint8_t *s, size_t slen, const uint8_t *in, size_t inlen, uint8_t *mac, size_t maclen) |
| Calculate KMAC in XOF mode - one-shot. | |
| #define LC_KMAC_CTX_ON_STACK | ( | name, | |
| hashname ) |
Allocate stack memory for the KMAC context.
This allocates the memory without re-initialization support
| [in] | name | Name of the stack variable - use lc_cshake256 or lc_cshake128 |
| [in] | hashname | Pointer of type struct hash referencing the hash implementation to be used |
| #define LC_KMAC_CTX_ON_STACK_REINIT | ( | name, | |
| hashname ) |
Allocate stack memory for the KMAC context.
This allocates the memory with re-initialization support. See KMAC_FLAGS_SUPPORT_REINIT for the explanation about re-initialization.
| [in] | name | Name of the stack variable - use lc_cshake256 or lc_cshake128 |
| [in] | hashname | Pointer of type struct hash referencing the hash implementation to be used |
| int lc_kmac | ( | const struct lc_hash * | hash, |
| const uint8_t * | key, | ||
| size_t | keylen, | ||
| const uint8_t * | s, | ||
| size_t | slen, | ||
| const uint8_t * | in, | ||
| size_t | inlen, | ||
| uint8_t * | mac, | ||
| size_t | maclen ) |
Calculate KMAC - one-shot.
| [in] | hash | Reference to hash implementation to be used to perform KMAC calculation with. Use lc_cshake256 or lc_cshake128. |
| [in] | key | MAC key of arbitrary size |
| [in] | keylen | Size of the MAC key |
| [in] | in | Buffer holding the data whose MAC shall be calculated |
| [in] | inlen | Length of the input buffer |
| [in] | s | Optional customization string - if not needed, use NULL |
| [in] | slen | Size of s |
| [out] | mac | Buffer with at least the size of the message digest. |
| [in] | maclen | Size of the requested MAC |
The KMAC calculation operates entirely on the stack.
| int lc_kmac_alloc | ( | const struct lc_hash * | hash, |
| struct lc_kmac_ctx ** | kmac_ctx, | ||
| uint32_t | flags ) |
Allocate KMAC context on heap.
NOTE: This is defined for cshake256 as of now.
| [in] | hash | Reference to hash implementation to be used to perform KMAC calculation with. Use cshake256! |
| [out] | kmac_ctx | Allocated KMAC context |
| [in] | flags | Zero or more of the flags defined below |
| void lc_kmac_final | ( | struct lc_kmac_ctx * | kmac_ctx, |
| uint8_t * | mac, | ||
| size_t | maclen ) |
Calculate KMAC MAC.
If the cipher handle shall be used for a new KMAC operation with the same key after this call, you MUST re-initialize the handle with kmac_reinit.
| [in] | kmac_ctx | Reference to kmac context implementation to be used to perform KMAC calculation with. |
| [out] | mac | Buffer with at least the size of the message digest that is returned by kmac_macsize. |
| [in] | maclen | Size of the requested MAC |
| void lc_kmac_final_xof | ( | struct lc_kmac_ctx * | kmac_ctx, |
| uint8_t * | mac, | ||
| size_t | maclen ) |
Calculate KMAC MAC in XOF mode.
If the cipher handle shall be used for a new KMAC operation with the same key after this call, you MUST re-initialize the handle with kmac_reinit.
This call is can be to be invoked multiple times It generates more message digest.
E.g. the following calls are equal:
size_t maclen = LC_SHA3_256_SIZE_BLOCK * 3 + 5;
lc_kmac_final_xof(ctx, mac, maclen);
and
| [in] | kmac_ctx | Reference to kmac context implementation to be used to perform KMAC calculation with. |
| [out] | mac | Buffer to hold the message digest |
| [in] | maclen | Size of the requested MAC |
| int lc_kmac_init | ( | struct lc_kmac_ctx * | kmac_ctx, |
| const uint8_t * | key, | ||
| size_t | klen, | ||
| const uint8_t * | s, | ||
| size_t | slen ) |
Initialize KMAC context.
| [in] | kmac_ctx | Reference to kmac context implementation to be used to perform KMAC calculation with. |
| [in] | key | MAC key of arbitrary size |
| [in] | klen | Size of the MAC key |
| [in] | s | Optional customization string - if not needed, use NULL |
| [in] | slen | Size of s |
The caller must provide an allocated kmac_ctx. This can be achieved by using KMAC_CTX_ON_STACK or by using kmac_alloc.
| size_t lc_kmac_macsize | ( | struct lc_kmac_ctx * | kmac_ctx | ) |
Return the MAC size.
| [in] | kmac_ctx | KMAC context |
| void lc_kmac_reinit | ( | struct lc_kmac_ctx * | kmac_ctx | ) |
Re-initialize KMAC context after a kmac_final operation.
This operation allows the KMAC context to be used again with the same key set during kmac_init.
| [in] | kmac_ctx | Reference to kmac context implementation to be used to perform KMAC calculation with. |
| void lc_kmac_update | ( | struct lc_kmac_ctx * | kmac_ctx, |
| const uint8_t * | in, | ||
| size_t | inlen ) |
Update KMAC.
| [in] | kmac_ctx | Reference to kmac context implementation to be used to perform KMAC calculation with. |
| [in] | in | Buffer holding the data whose MAC shall be calculated |
| [in] | inlen | Length of the input buffer |
| int lc_kmac_xof | ( | const struct lc_hash * | hash, |
| const uint8_t * | key, | ||
| size_t | keylen, | ||
| const uint8_t * | s, | ||
| size_t | slen, | ||
| const uint8_t * | in, | ||
| size_t | inlen, | ||
| uint8_t * | mac, | ||
| size_t | maclen ) |
Calculate KMAC in XOF mode - one-shot.
| [in] | hash | Reference to hash implementation to be used to perform KMAC calculation with. Use lc_cshake256 or lc_cshake128. |
| [in] | key | MAC key of arbitrary size |
| [in] | keylen | Size of the MAC key |
| [in] | in | Buffer holding the data whose MAC shall be calculated |
| [in] | inlen | Length of the input buffer |
| [in] | s | Optional customization string - if not needed, use NULL |
| [in] | slen | Size of s |
| [out] | mac | Buffer with at least the size of the message digest. |
| [in] | maclen | Size of the requested MAC |
The KMAC calculation operates entirely on the stack.
| void lc_kmac_zero | ( | struct lc_kmac_ctx * | kmac_ctx | ) |
Zeroize KMAC context allocated with either LC_KMAC_CTX_ON_STACK or lc_kmac_alloc.
| [in] | kmac_ctx | KMAC context to be zeroized |
| void lc_kmac_zero_free | ( | struct lc_kmac_ctx * | kmac_ctx | ) |
Zeroize and free KMAC context.
| [in] | kmac_ctx | KMAC context to be zeroized and freed |