|
Leancrypto 1.6.0
Post-Quantum Cryptographic Library
|
Go to the source code of this file.
Macros | |
| #define | LC_CSHAKE_FLAGS_SUPPORT_REINIT (1 << 0) |
| #define | LC_CSHAKE_CTX_ON_STACK(name, hashname) |
| Allocate stack memory for the CSHAKE context. | |
| #define | LC_CSHAKE_CTX_ON_STACK_REINIT(name, hashname) |
| Allocate stack memory for the CSHAKE context. | |
Functions | |
| int | lc_cshake_init (struct lc_hash_ctx *ctx, const uint8_t *n, size_t nlen, const uint8_t *s, size_t slen) |
| Initialize the hash state following the cSHAKE specification. | |
| static void | lc_cshake_final (struct lc_hash_ctx *ctx, uint8_t *out, size_t outlen) |
| Generate a cSHAKE message digest from a given state. | |
| int | lc_cshake_ctx_init (struct lc_cshake_ctx *cshake_ctx, const uint8_t *n, size_t nlen, const uint8_t *s, size_t slen) |
| Initialize the hash state with re-init support following the cSHAKE specification. | |
| void | lc_cshake_ctx_reinit (struct lc_cshake_ctx *cshake_ctx) |
| Re-initialize CSHAKE context after a cshake_final operation. | |
| void | lc_cshake_ctx_update (struct lc_cshake_ctx *cshake_ctx, const uint8_t *in, size_t inlen) |
| Update CSHAKE. | |
| void | lc_cshake_ctx_final (struct lc_cshake_ctx *cshake_ctx, uint8_t *out, size_t outlen) |
| Generate a cSHAKE message digest from a given state. | |
| int | lc_cshake_ctx_alloc (const struct lc_hash *hash, struct lc_cshake_ctx **cshake_ctx, uint32_t flags) |
| Allocate CSHAKE context on heap. | |
| void | lc_cshake_ctx_zero_free (struct lc_cshake_ctx *cshake_ctx) |
| Zeroize and free CSHAKE context. | |
| static void | lc_cshake_ctx_zero (struct lc_cshake_ctx *cshake_ctx) |
| Zeroize CSHAKE context allocated with either LC_CSHAKE_CTX_ON_STACK or lc_cshake_alloc. | |
| #define LC_CSHAKE_CTX_ON_STACK | ( | name, | |
| hashname ) |
Allocate stack memory for the CSHAKE 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 |
Definition at line 239 of file lc_cshake.h.
| #define LC_CSHAKE_CTX_ON_STACK_REINIT | ( | name, | |
| hashname ) |
Allocate stack memory for the CSHAKE context.
This allocates the memory with re-initialization support. See CSHAKE_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 |
Definition at line 262 of file lc_cshake.h.
| #define LC_CSHAKE_FLAGS_SUPPORT_REINIT (1 << 0) |
Definition at line 197 of file lc_cshake.h.
| int lc_cshake_ctx_alloc | ( | const struct lc_hash * | hash, |
| struct lc_cshake_ctx ** | cshake_ctx, | ||
| uint32_t | flags ) |
Allocate CSHAKE context on heap.
NOTE: This is defined for cshake256 as of now.
| [in] | hash | Reference to hash implementation to be used to perform CSHAKE calculation with. Use cshake256! |
| [out] | cshake_ctx | Allocated CSHAKE context |
| [in] | flags | Zero or more of the flags defined below |
| void lc_cshake_ctx_final | ( | struct lc_cshake_ctx * | cshake_ctx, |
| uint8_t * | out, | ||
| size_t | outlen ) |
Generate a cSHAKE message digest from a given state.
The function can be invoked repeatedly to squeeze more data from the cSHAKE state.
| [in] | cshake_ctx | Initialized hash context |
| [out] | out | Buffer allocated by caller that is filled with the message digest data. |
| [in] | outlen | Size of the output buffer to be filled. |
| int lc_cshake_ctx_init | ( | struct lc_cshake_ctx * | cshake_ctx, |
| const uint8_t * | n, | ||
| size_t | nlen, | ||
| const uint8_t * | s, | ||
| size_t | slen ) |
Initialize the hash state with re-init support following the cSHAKE specification.
| [in] | cshake_ctx | Initialized hash context |
| [in] | n | N is a function-name bit string, used by NIST to define functions based on cSHAKE. When no function other than cSHAKE is desired, N is set to the empty string. |
| [in] | nlen | Length of n |
| [in] | s | S is a customization bit string. The user selects this string to define a variant of the function. When no customization is desired, S is set to the empty string. |
| [in] | slen | Length of s |
| void lc_cshake_ctx_reinit | ( | struct lc_cshake_ctx * | cshake_ctx | ) |
Re-initialize CSHAKE context after a cshake_final operation.
This operation allows the CSHAKE context to be used again with the same key set during cshake_init.
| [in] | cshake_ctx | Reference to cshake context implementation to be used to perform CSHAKE calculation with. |
| void lc_cshake_ctx_update | ( | struct lc_cshake_ctx * | cshake_ctx, |
| const uint8_t * | in, | ||
| size_t | inlen ) |
Update CSHAKE.
| [in] | cshake_ctx | Reference to cshake context implementation to be used to perform cSHAKE calculation with. |
| [in] | in | Buffer holding the data whose MAC shall be calculated |
| [in] | inlen | Length of the input buffer |
|
inlinestatic |
Zeroize CSHAKE context allocated with either LC_CSHAKE_CTX_ON_STACK or lc_cshake_alloc.
| [in] | cshake_ctx | CSHAKE context to be zeroized |
Definition at line 212 of file lc_cshake.h.
| void lc_cshake_ctx_zero_free | ( | struct lc_cshake_ctx * | cshake_ctx | ) |
Zeroize and free CSHAKE context.
| [in] | cshake_ctx | CSHAKE context to be zeroized and freed |
|
inlinestatic |
Generate a cSHAKE message digest from a given state.
The function can be invoked repeatedly to squeeze more data from the cSHAKE state.
| [in] | ctx | Initialized hash context |
| [out] | out | Buffer allocated by caller that is filled with the message digest data. |
| [in] | outlen | Size of the output buffer to be filled. |
Definition at line 76 of file lc_cshake.h.
| int lc_cshake_init | ( | struct lc_hash_ctx * | ctx, |
| const uint8_t * | n, | ||
| size_t | nlen, | ||
| const uint8_t * | s, | ||
| size_t | slen ) |
Initialize the hash state following the cSHAKE specification.
To invoke cSHAKE, perform the following steps:
lc_cshake_init lc_hash_set_digestsize lc_hash_update ... lc_hash_update lc_hash_final
Or use the helper lc_cshake_final:
lc_cshake_init lc_hash_update ... lc_hash_update lc_cshake_final
| [in] | ctx | Initialized hash context |
| [in] | n | N is a function-name bit string, used by NIST to define functions based on cSHAKE. When no function other than cSHAKE is desired, N is set to the empty string. |
| [in] | nlen | Length of n |
| [in] | s | S is a customization bit string. The user selects this string to define a variant of the function. When no customization is desired, S is set to the empty string. |
| [in] | slen | Length of s |