#ifndef AWS_CAL_HMAC_H_
#define AWS_CAL_HMAC_H_
#include <aws/cal/exports.h>
#include <aws/common/byte_buf.h>
#include <aws/common/common.h>
#define AWS_SHA256_HMAC_LEN 32
struct aws_hmac;
struct aws_hmac_vtable {
const char *alg_name;
const char *provider;
void (*destroy)(struct aws_hmac *hmac);
int (*update)(struct aws_hmac *hmac, const struct aws_byte_cursor *buf);
int (*finalize)(struct aws_hmac *hmac, struct aws_byte_buf *out);
};
struct aws_hmac {
struct aws_allocator *allocator;
struct aws_hmac_vtable *vtable;
size_t digest_size;
bool good;
void *impl;
};
typedef struct aws_hmac *(aws_hmac_new_fn)(struct aws_allocator *allocator, const struct aws_byte_cursor *secret);
AWS_EXTERN_C_BEGIN
AWS_CAL_API struct aws_hmac *aws_sha256_hmac_new(struct aws_allocator *allocator, const struct aws_byte_cursor *secret);
AWS_CAL_API void aws_hmac_destroy(struct aws_hmac *hmac);
AWS_CAL_API int aws_hmac_update(struct aws_hmac *hmac, const struct aws_byte_cursor *to_hmac);
AWS_CAL_API int aws_hmac_finalize(struct aws_hmac *hmac, struct aws_byte_buf *output, size_t truncate_to);
AWS_CAL_API int aws_sha256_hmac_compute(
struct aws_allocator *allocator,
const struct aws_byte_cursor *secret,
const struct aws_byte_cursor *to_hmac,
struct aws_byte_buf *output,
size_t truncate_to);
AWS_CAL_API void aws_set_sha256_hmac_new_fn(aws_hmac_new_fn *fn);
AWS_EXTERN_C_END
#endif