2019-05-20 03:43:18 +00:00
|
|
|
/*
|
|
|
|
hmac_sha256.h
|
|
|
|
Originally written by https://github.com/h5p9sl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _HMAC_SHA256_H_
|
|
|
|
#define _HMAC_SHA256_H_
|
|
|
|
|
2019-07-05 02:27:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2021-08-18 22:39:37 +00:00
|
|
|
#endif // __cplusplus
|
2019-07-05 02:27:00 +00:00
|
|
|
|
2021-04-21 12:41:12 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2021-08-18 22:39:37 +00:00
|
|
|
size_t // Returns the number of bytes written to `out`
|
2021-04-21 12:41:12 +00:00
|
|
|
hmac_sha256(
|
|
|
|
// [in]: The key and its length.
|
|
|
|
// Should be at least 32 bytes long for optimal security.
|
2021-08-18 22:39:37 +00:00
|
|
|
const void* key,
|
|
|
|
const size_t keylen,
|
2021-04-21 12:41:12 +00:00
|
|
|
|
|
|
|
// [in]: The data to hash alongside the key.
|
2021-08-18 22:39:37 +00:00
|
|
|
const void* data,
|
|
|
|
const size_t datalen,
|
2021-04-21 12:41:12 +00:00
|
|
|
|
|
|
|
// [out]: The output hash.
|
|
|
|
// Should be 32 bytes long. If it's less than 32 bytes,
|
|
|
|
// the resulting hash will be truncated to the specified length.
|
2021-08-18 22:39:37 +00:00
|
|
|
void* out,
|
|
|
|
const size_t outlen);
|
2019-05-20 03:43:18 +00:00
|
|
|
|
2019-07-05 02:27:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2021-08-18 22:39:37 +00:00
|
|
|
#endif // __cplusplus
|
2019-05-20 03:43:18 +00:00
|
|
|
|
2021-08-18 22:39:37 +00:00
|
|
|
#endif // _HMAC_SHA256_H_
|