X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=inc%2Fbearssl_hmac.h;h=4dc01ca31203c625dcf646140c7761c5919ba7b2;hp=71e9451d881997a0483be19298b796427c8eeabd;hb=fb4296c593895fe6758f42642bcc4f6fea2f8710;hpb=e683ebfe1962ef5b00a972761984674528922a4a diff --git a/inc/bearssl_hmac.h b/inc/bearssl_hmac.h index 71e9451..4dc01ca 100644 --- a/inc/bearssl_hmac.h +++ b/inc/bearssl_hmac.h @@ -30,6 +30,10 @@ #include "bearssl_hash.h" +#ifdef __cplusplus +extern "C" { +#endif + /** \file bearssl_hmac.h * * # HMAC @@ -80,6 +84,21 @@ typedef struct { void br_hmac_key_init(br_hmac_key_context *kc, const br_hash_class *digest_vtable, const void *key, size_t key_len); +/* + * \brief Get the underlying hash function. + * + * This function returns a pointer to the implementation vtable of the + * hash function used for this HMAC key context. + * + * \param kc HMAC key context. + * \return the hash function implementation. + */ +static inline const br_hash_class *br_hmac_key_get_digest( + const br_hmac_key_context *kc) +{ + return kc->dig_vtable; +} + /** * \brief HMAC computation context. * @@ -138,6 +157,21 @@ br_hmac_size(br_hmac_context *ctx) return ctx->out_len; } +/* + * \brief Get the underlying hash function. + * + * This function returns a pointer to the implementation vtable of the + * hash function used for this HMAC context. + * + * \param hc HMAC context. + * \return the hash function implementation. + */ +static inline const br_hash_class *br_hmac_get_digest( + const br_hmac_context *hc) +{ + return hc->dig.vtable; +} + /** * \brief Inject some bytes in HMAC. * @@ -151,7 +185,7 @@ void br_hmac_update(br_hmac_context *ctx, const void *data, size_t len); /** * \brief Compute the HMAC output. * - * The destination buffer MUST be large enough to accomodate the result; + * The destination buffer MUST be large enough to accommodate the result; * its length is at most the "natural length" of HMAC (i.e. the output * length of the underlying hash function). The context is NOT modified; * further bytes may be processed. Thus, "partial HMAC" values can be @@ -200,4 +234,8 @@ size_t br_hmac_outCT(const br_hmac_context *ctx, const void *data, size_t len, size_t min_len, size_t max_len, void *out); +#ifdef __cplusplus +} +#endif + #endif