![]() |
m2mb API docs
25.20.008
m2mb API sets documentation
|
Ciphered MAC implementation, per FIPS pub 198.
More...
Modules | |
| M2MB_AES | |
| AES CBC & ECB algorithm implementation. http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. | |
| M2MB_DES | |
| DES & 3DES CBC & ECB algorithm implementation. | |
Enumerations | |
| enum | M2MB_CRYPTO_CMAC_ALG_E { M2MB_CRYPTO_CMAC_ALG_AES_128 = 1, M2MB_CRYPTO_CMAC_ALG_AES_192 = 2, M2MB_CRYPTO_CMAC_ALG_AES_256 = 3 } |
Functions | |
| M2MB_RESULT_E | m2mb_crypto_cmac_init (M2MB_CRYPTO_CMAC_CONTEXT *ctx) |
| Allocates a M2MB_CRYPTO_CMAC_CONTEXT structure. More... | |
| M2MB_RESULT_E | m2mb_crypto_cmac_setup (M2MB_CRYPTO_CMAC_CONTEXT ctx, const UINT8 *key, SIZE_T keylen) |
| Sets up an M2MB_CRYPTO_CMAC_CONTEXT structure. More... | |
| M2MB_RESULT_E | m2mb_crypto_cmac_update (M2MB_CRYPTO_CMAC_CONTEXT ctx, const UINT8 *data, SIZE_T len) |
| continuously CMAC of data. This function can be called repeatedly similar to streaming More... | |
| M2MB_RESULT_E | m2mb_crypto_cmac_final (M2MB_CRYPTO_CMAC_CONTEXT ctx, UINT8 *cmac) |
| This function computes the final CMAC for all previously provided messages for the given context. More... | |
| M2MB_RESULT_E | m2mb_crypto_cmac_reset (M2MB_CRYPTO_CMAC_CONTEXT ctx) |
| Prepare to run CMAC for a new message. More... | |
| M2MB_RESULT_E | m2mb_crypto_cmac_deinit (M2MB_CRYPTO_CMAC_CONTEXT ctx) |
| This function free an CMAC context. More... | |
| UINT8 * | m2mb_crypto_cmac (M2MB_CRYPTO_CMAC_ALG_E cmac_alg, const UINT8 *key, const SIZE_T keylen, const UINT8 *input, const SIZE_T inlen, UINT8 *cmac) |
| This function will compute the CMAC in one shot without needing any context. More... | |
Ciphered MAC implementation, per FIPS pub 198.
| UINT8* m2mb_crypto_cmac | ( | M2MB_CRYPTO_CMAC_ALG_E | cmac_alg, |
| const UINT8 * | key, | ||
| const SIZE_T | keylen, | ||
| const UINT8 * | input, | ||
| const SIZE_T | inlen, | ||
| UINT8 * | cmac | ||
| ) |
This function will compute the CMAC in one shot without needing any context.
This function is used to calculate an CMAC for a given data, key & hash algorithm.
If cmac is NULL, the CMAC is placed in a static array.
This function is similar to running the following function flow:
m2mb_crypto_cmac_init();
m2mb_crypto_cmac_setup();
m2mb_crypto_cmac_update();
m2mb_crypto_cmac_final();
m2mb_crypto_cmac_deinit();
| [in] | key | The symmetric key to use for the CMAC |
| [in] | keylen | The length of the provided key. |
| [in] | input | Buffer holding the data to compute CMAC for |
| [in] | inlen | length of the provided data |
| [out] | cmac | The calculated CMAC |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_deinit | ( | M2MB_CRYPTO_CMAC_CONTEXT | ctx | ) |
This function free an CMAC context.
This function free the provided context memory.
| [in] | ctx | Pointer to a previously initialized context structure to free |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_final | ( | M2MB_CRYPTO_CMAC_CONTEXT | ctx, |
| UINT8 * | cmac | ||
| ) |
This function computes the final CMAC for all previously provided messages for the given context.
This function is the final step for CMAC calculation.
It will return the calculated CMAC based on all the previous messages (sent via m2mb_crypto_cmac_update)
| [in] | ctx | A previously allocated cmac context. The context setup must be also done before using this function (using m2mb_crypto_cmac_setup) |
| [out] | cmac | The calculated cmac. Must be large enough to0 hold the CMAC per the selected message digest algorithm used for the setup. |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_init | ( | M2MB_CRYPTO_CMAC_CONTEXT * | ctx | ) |
Allocates a M2MB_CRYPTO_CMAC_CONTEXT structure.
This function allocates an CMAC context to be later used by any CMAC function.
| [in] | ctx | Pointer to a context structure to be allocated by this function. Any consecutive call to CMAC function must use the context. |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_reset | ( | M2MB_CRYPTO_CMAC_CONTEXT | ctx | ) |
Prepare to run CMAC for a new message.
Resets all previously provided messages.
The same key & hash algorithm provided to m2mb_crypto_cmac_setup() remains and will be used for new CMAC.
Usually used after m2mb_crypto_cmac_final() and before m2mb_crypto_cmac_update()
| [in] | ctx | Pointer to a previously allocated context structure to reset |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_setup | ( | M2MB_CRYPTO_CMAC_CONTEXT | ctx, |
| const UINT8 * | key, | ||
| SIZE_T | keylen | ||
| ) |
Sets up an M2MB_CRYPTO_CMAC_CONTEXT structure.
This function performs setup of a CMAC context providing the hash algorithm to use and the symmetric key.
Usually comes after m2mb_crypto_cmac_init() or m2mb_crypto_cmac_final().
Might also be called after m2mb_crypto_cmac_update() in order to restart the digest process.
| [in] | ctx | Pointer to a previously allocated context structure |
| [in] | key | The symmetric key to use for the cmac. |
| [in] | keylen | The length of the provided key. Only 128 & 256 are supported. |
Example
| M2MB_RESULT_E m2mb_crypto_cmac_update | ( | M2MB_CRYPTO_CMAC_CONTEXT | ctx, |
| const UINT8 * | data, | ||
| SIZE_T | len | ||
| ) |
continuously CMAC of data. This function can be called repeatedly similar to streaming
This function is used to continuously hash data (streaming data when not all buffer to be hashed is available in one shot).
This function can be called repeatedly.
| [in] | ctx | A previously allocated cmac context. The context setup must be also done before using this function (using m2mb_crypto_cmac_setup) |
| [in] | data | Buffer holding the data |
| [in] | len | length of the provided data |
Example