From: Niels Möller Date: Sun, 16 Jun 2024 19:00:51 +0000 (+0200) Subject: Add nettle_mac structs for gosthash94 and gosthash94cp. X-Git-Tag: nettle_3.10.1_release_20241230~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=963d7cc048197ccd10f4df373af8eaa1d60ab3bb;p=thirdparty%2Fnettle.git Add nettle_mac structs for gosthash94 and gosthash94cp. --- diff --git a/ChangeLog b/ChangeLog index ca7a424c..0259bc3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2024-06-16 Niels Möller + * hmac-gosthash94-meta.c: New file. + * nettle-meta.h (nettle_hmac_gosthash94) + (nettle_hmac_gosthash94cp): Declare. + * nettle-meta-macs.c (_nettle_macs): Add nettle_hmac_gosthash94 + and nettle_hmac_gosthash94cp. + * Makefile.in (nettle_SOURCES): Add hmac-gosthash94-meta.c. + * testsuite/meta-mac-test.c: Update test. + * Released Nettle-3.10. * examples/rsa-encrypt-test: Consistently add $EXEEXT to diff --git a/Makefile.in b/Makefile.in index 2bf7f1e8..71ad761e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -126,7 +126,8 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c aes-decrypt-table.c \ hmac-sha512.c hmac-streebog.c hmac-sm3.c \ hmac-md5-meta.c hmac-ripemd160-meta.c hmac-sha1-meta.c \ hmac-sha224-meta.c hmac-sha256-meta.c hmac-sha384-meta.c \ - hmac-sha512-meta.c hmac-streebog-meta.c hmac-sm3-meta.c \ + hmac-sha512-meta.c hmac-gosthash94-meta.c \ + hmac-streebog-meta.c hmac-sm3-meta.c \ knuth-lfib.c hkdf.c \ md2.c md2-meta.c md4.c md4-meta.c \ md5.c md5-compat.c md5-meta.c \ diff --git a/hmac-gosthash94-meta.c b/hmac-gosthash94-meta.c new file mode 100644 index 00000000..6078807a --- /dev/null +++ b/hmac-gosthash94-meta.c @@ -0,0 +1,56 @@ +/* hmac-gosthash94-meta.c + + Copyright (C) 2024 Niels Möller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nettle-meta.h" + +#include "hmac.h" + +static void +hmac_gosthash94_set_key_wrapper (void *ctx, const uint8_t *key) +{ + hmac_gosthash94_set_key (ctx, GOSTHASH94_DIGEST_SIZE, key); +} + +const struct nettle_mac nettle_hmac_gosthash94 += _NETTLE_HMAC(hmac_gosthash94, GOSTHASH94); + +static void +hmac_gosthash94cp_set_key_wrapper (void *ctx, const uint8_t *key) +{ + hmac_gosthash94cp_set_key (ctx, GOSTHASH94CP_DIGEST_SIZE, key); +} + +const struct nettle_mac nettle_hmac_gosthash94cp += _NETTLE_HMAC(hmac_gosthash94cp, GOSTHASH94CP); diff --git a/nettle-meta-macs.c b/nettle-meta-macs.c index 40aa6dcd..48b2176e 100644 --- a/nettle-meta-macs.c +++ b/nettle-meta-macs.c @@ -41,6 +41,8 @@ const struct nettle_mac * const _nettle_macs[] = { &nettle_cmac_aes128, &nettle_cmac_aes256, &nettle_cmac_des3, + &nettle_hmac_gosthash94, + &nettle_hmac_gosthash94cp, &nettle_hmac_md5, &nettle_hmac_ripemd160, &nettle_hmac_sha1, diff --git a/nettle-meta.h b/nettle-meta.h index 19dc96c5..f0d4b1e2 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -285,6 +285,8 @@ extern const struct nettle_mac nettle_cmac_aes256; extern const struct nettle_mac nettle_cmac_des3; /* HMAC variants with key size = digest size */ +extern const struct nettle_mac nettle_hmac_gosthash94; +extern const struct nettle_mac nettle_hmac_gosthash94cp; extern const struct nettle_mac nettle_hmac_md5; extern const struct nettle_mac nettle_hmac_ripemd160; extern const struct nettle_mac nettle_hmac_sha1; diff --git a/testsuite/meta-mac-test.c b/testsuite/meta-mac-test.c index 0ff82810..6c848a88 100644 --- a/testsuite/meta-mac-test.c +++ b/testsuite/meta-mac-test.c @@ -5,6 +5,8 @@ const char* macs[] = { "cmac_aes128", "cmac_aes256", "cmac_des3", + "hmac_gosthash94", + "hmac_gosthash94cp", "hmac_md5", "hmac_ripemd160", "hmac_sha1",