|
SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
|
HMAC keyed-hash message authentication code (in conjunction with: MD5,SHA1,SHA256,SHA384,SHA512)
Data Structures | |
| struct | SharkSslHMACCtx |
| HMAC. More... | |
Typedefs | |
| typedef struct SharkSslHMACCtx | SharkSslHMACCtx |
| HMAC. More... | |
Functions | |
| SHARKSSL_API int | SharkSslHMACCtx_constructor (SharkSslHMACCtx *ctx, U8 hashID, const U8 *key, U16 keyLen) |
| Initialize. More... | |
| SHARKSSL_API int | SharkSslHMACCtx_append (SharkSslHMACCtx *, const U8 *data, U32 len) |
| append More... | |
| SHARKSSL_API int | SharkSslHMACCtx_finish (SharkSslHMACCtx *, U8 *HMAC) |
| finish More... | |
| SHARKSSL_API int | sharkssl_HMAC (const U8 hashID, const U8 *data, U32 len, const U8 *key, U16 keyLen, U8 *digest) |
| HMAC. More... | |
| typedef struct SharkSslHMACCtx SharkSslHMACCtx |
HMAC.
In PSA consumer builds, this context owns a volatile PSA key. Do not copy it. Finish and destructor release the key; call destructor if a message is abandoned. Consumer methods return zero on success and -1 on error.
| int sharkssl_HMAC | ( | const U8 | hashID, |
| const U8 * | data, | ||
| U32 | len, | ||
| const U8 * | key, | ||
| U16 | keyLen, | ||
| U8 * | digest | ||
| ) |
HMAC.
Use a nonempty key and an enabled hash.
| hashID | the hash function to be used, can be one of: SHARKSSL_HASHID_MD5, SHARKSSL_HASHID_SHA1, SHARKSSL_HASHID_SHA256, SHARKSSL_HASHID_SHA384, SHARKSSL_HASHID_SHA512 |
| data | pointer to the data to be hashed |
| len | data length in bytes |
| key | pointer to the cryptographic key |
| keyLen | 'key' length |
| digest | output HMAC |
The PSA consumer additionally requires that hash/HMAC combination from its provider. The result is one full hash-length MAC; no truncation is performed.
| int SharkSslHMACCtx_append | ( | SharkSslHMACCtx * | ctx, |
| const U8 * | data, | ||
| U32 | len | ||
| ) |
append
| ctx | SharkSslHMACCtx *; required initialized, unfinished context. |
| data | const U8 *; message bytes, borrowed for the call; required when len is nonzero. |
| len | U32; message length in bytes. |
| int SharkSslHMACCtx_constructor | ( | SharkSslHMACCtx * | ctx, |
| U8 | hashID, | ||
| const U8 * | key, | ||
| U16 | keyLen | ||
| ) |
Initialize.
The PSA context owns an imported volatile key.
| ctx | Uninitialized data of size sizeof(SharkSslHMACCtx). |
| hashID | the hash function to be used, can be one of: SHARKSSL_HASHID_MD5, SHARKSSL_HASHID_SHA1, SHARKSSL_HASHID_SHA256, SHARKSSL_HASHID_SHA384, SHARKSSL_HASHID_SHA512 |
| key | pointer to the cryptographic key |
| keyLen | 'key' length |
Finish it or call SharkSslHMACCtx_destructor before reusing the storage. The native context retains a derived key pad until cleared.
| int SharkSslHMACCtx_finish | ( | SharkSslHMACCtx * | ctx, |
| U8 * | HMAC | ||
| ) |
finish
| ctx | SharkSslHMACCtx *; required active context. The PSA implementation also releases its operation and imported key; clear the native context with its destructor after use. |
| HMAC | U8 *; required output buffer sized to the selected hash digest (16, 20, 32, 48, or 64 bytes for the documented native hashes). |