From f67dd4f0ed34c9e41cde119b0b28c7a4342d37df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Sun, 9 Feb 2020 09:57:34 +0100 Subject: Add meta interface for HMAC functions. Based on patches by Daiki Ueno. --- nettle-meta.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'nettle-meta.h') diff --git a/nettle-meta.h b/nettle-meta.h index 42f8a863..d5a009f4 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -2,7 +2,7 @@ Information about algorithms. - Copyright (C) 2002, 2014 Niels Möller + Copyright (C) 2002, 2014, 2020 Niels Möller This file is part of GNU Nettle. @@ -257,9 +257,28 @@ extern const struct nettle_armor nettle_base64; extern const struct nettle_armor nettle_base64url; extern const struct nettle_armor nettle_base16; +#define _NETTLE_HMAC(name, HASH) { \ + #name, \ + sizeof(struct name##_ctx), \ + HASH##_DIGEST_SIZE, \ + HASH##_DIGEST_SIZE, \ + name##_set_key_wrapper, \ + (nettle_hash_update_func *) name##_update, \ + (nettle_hash_digest_func *) name##_digest, \ +} + extern const struct nettle_mac nettle_cmac_aes128; extern const struct nettle_mac nettle_cmac_aes256; +/* HMAC variants with key size = digest size */ +extern const struct nettle_mac nettle_hmac_md5; +extern const struct nettle_mac nettle_hmac_ripemd160; +extern const struct nettle_mac nettle_hmac_sha1; +extern const struct nettle_mac nettle_hmac_sha224; +extern const struct nettle_mac nettle_hmac_sha256; +extern const struct nettle_mac nettle_hmac_sha384; +extern const struct nettle_mac nettle_hmac_sha512; + #ifdef __cplusplus } #endif -- cgit v1.2.1