|
Leancrypto 1.6.0
Post-Quantum Cryptographic Library
|
Macros | |
| #define | LC_HMAC_CTX_ON_STACK(name, hashname) |
| Allocate stack memory for the HMAC context. | |
Functions | |
| int | lc_hmac_init (struct lc_hmac_ctx *hmac_ctx, const uint8_t *key, size_t keylen) |
| Initialize HMAC context. | |
| void | lc_hmac_reinit (struct lc_hmac_ctx *hmac_ctx) |
| Re-initialize HMAC context after a hmac_final operation. | |
| void | lc_hmac_update (struct lc_hmac_ctx *hmac_ctx, const uint8_t *in, size_t inlen) |
| Update HMAC. | |
| void | lc_hmac_final (struct lc_hmac_ctx *hmac_ctx, uint8_t *mac) |
| Calculate HMAC mac. | |
| int | lc_hmac_alloc (const struct lc_hash *hash, struct lc_hmac_ctx **hmac_ctx) |
| Allocate HMAC context on heap. | |
| void | lc_hmac_zero_free (struct lc_hmac_ctx *hmac_ctx) |
| Zeroize and free HMAC context. | |
| void | lc_hmac_zero (struct lc_hmac_ctx *hmac_ctx) |
| Zeroize HMAC context allocated with either HMAC_CTX_ON_STACK or hmac_alloc. | |
| size_t | lc_hmac_macsize (struct lc_hmac_ctx *hmac_ctx) |
| Return the MAC size. | |
| int | lc_hmac (const struct lc_hash *hash, const uint8_t *key, size_t keylen, const uint8_t *in, size_t inlen, uint8_t *mac) |
| Calculate HMAC - one-shot. | |
| #define LC_HMAC_CTX_ON_STACK | ( | name, | |
| hashname ) |
Allocate stack memory for the HMAC context.
| [in] | name | Name of the stack variable |
| [in] | hashname | Pointer of type struct hash referencing the hash implementation to be used |
| int lc_hmac | ( | const struct lc_hash * | hash, |
| const uint8_t * | key, | ||
| size_t | keylen, | ||
| const uint8_t * | in, | ||
| size_t | inlen, | ||
| uint8_t * | mac ) |
Calculate HMAC - one-shot.
| [in] | hash | Reference to hash implementation to be used to perform HMAC calculation with. |
| [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 |
| [out] | mac | Buffer with at least the size of the message digest. |
The HMAC calculation operates entirely on the stack.
| int lc_hmac_alloc | ( | const struct lc_hash * | hash, |
| struct lc_hmac_ctx ** | hmac_ctx ) |
Allocate HMAC context on heap.
| [in] | hash | Reference to hash implementation to be used to perform HMAC calculation with. |
| [out] | hmac_ctx | Allocated HMAC context |
| void lc_hmac_final | ( | struct lc_hmac_ctx * | hmac_ctx, |
| uint8_t * | mac ) |
Calculate HMAC mac.
If the cipher handle shall be used for a new HMAC operation with the same key after this call, you MUST re-initialize the handle with hmac_reinit.
| [in] | hmac_ctx | Reference to hmac context implementation to be used to perform HMAC calculation with. |
| [out] | mac | Buffer with at least the size of the message digest that is returned by hmac_macsize. |
| int lc_hmac_init | ( | struct lc_hmac_ctx * | hmac_ctx, |
| const uint8_t * | key, | ||
| size_t | keylen ) |
Initialize HMAC context.
| [in] | hmac_ctx | Reference to hmac context implementation to be used to perform HMAC calculation with. |
| [in] | key | MAC key of arbitrary size |
| [in] | keylen | Size of the MAC key |
The caller must provide an allocated hmac_ctx. This can be achieved by using HMAC_CTX_ON_STACK or by using hmac_alloc.
| size_t lc_hmac_macsize | ( | struct lc_hmac_ctx * | hmac_ctx | ) |
Return the MAC size.
| [in] | hmac_ctx | HMAC context to be zeroized |
| void lc_hmac_reinit | ( | struct lc_hmac_ctx * | hmac_ctx | ) |
Re-initialize HMAC context after a hmac_final operation.
This operation allows the HMAC context to be used again with the same key set during hmac_init.
| [in] | hmac_ctx | Reference to hmac context implementation to be used to perform HMAC calculation with. |
| void lc_hmac_update | ( | struct lc_hmac_ctx * | hmac_ctx, |
| const uint8_t * | in, | ||
| size_t | inlen ) |
Update HMAC.
| [in] | hmac_ctx | Reference to hmac context implementation to be used to perform HMAC calculation with. |
| [in] | in | Buffer holding the data whose MAC shall be calculated |
| [in] | inlen | Length of the input buffer |
| void lc_hmac_zero | ( | struct lc_hmac_ctx * | hmac_ctx | ) |
Zeroize HMAC context allocated with either HMAC_CTX_ON_STACK or hmac_alloc.
| [in] | hmac_ctx | HMAC context to be zeroized |
| void lc_hmac_zero_free | ( | struct lc_hmac_ctx * | hmac_ctx | ) |
Zeroize and free HMAC context.
| [in] | hmac_ctx | HMAC context to be zeroized and freed |