From: Daiki Ueno <du...@redhat.com>

Signed-off-by: Daiki Ueno <du...@redhat.com>
---
 Makefile.in        |  2 +-
 nettle-meta-macs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 nettle-meta.h      |  7 ++++++
 3 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 nettle-meta-macs.c

diff --git a/Makefile.in b/Makefile.in
index 4cfc5005..8efe2f88 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -116,7 +116,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
                 memeql-sec.c memxor.c memxor3.c \
                 nettle-lookup-hash.c \
                 nettle-meta-aeads.c nettle-meta-armors.c \
-                nettle-meta-ciphers.c nettle-meta-hashes.c \
+                nettle-meta-ciphers.c nettle-meta-hashes.c nettle-meta-macs.c \
                 pbkdf2.c pbkdf2-hmac-sha1.c pbkdf2-hmac-sha256.c \
                 poly1305-aes.c poly1305-internal.c \
                 realloc.c \
diff --git a/nettle-meta-macs.c b/nettle-meta-macs.c
new file mode 100644
index 00000000..6575ed66
--- /dev/null
+++ b/nettle-meta-macs.c
@@ -0,0 +1,61 @@
+/* nettle-meta-macs.c
+
+   Copyright (C) 2011 Daniel Kahn Gillmor
+
+   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 <stddef.h>
+
+#include "nettle-meta.h"
+
+const struct nettle_mac * const _nettle_macs[] = {
+  &nettle_cmac_aes128,
+  &nettle_cmac_aes256,
+  &nettle_hmac_md5,
+  &nettle_hmac_ripemd160,
+  &nettle_hmac_sha1,
+  &nettle_hmac_sha224,
+  &nettle_hmac_sha256,
+  &nettle_hmac_sha384,
+  &nettle_hmac_sha512,
+  &nettle_umac32,
+  &nettle_umac64,
+  &nettle_umac96,
+  &nettle_umac128,
+  NULL
+};
+
+const struct nettle_mac * const *
+nettle_get_macs (void)
+{
+  return _nettle_macs;
+}
diff --git a/nettle-meta.h b/nettle-meta.h
index 55229501..c7e7ab0f 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -296,6 +296,13 @@ struct nettle_mac
   (nettle_hash_digest_func *) name##_digest,   \
 }
 
+/* null-terminated list of macs implemented by this
+   version of nettle */
+const struct nettle_mac * const * _NETTLE_ATTRIBUTE_PURE
+nettle_get_macs (void);
+
+#define nettle_macs (nettle_get_macs())
+
 extern const struct nettle_mac nettle_cmac_aes128;
 extern const struct nettle_mac nettle_cmac_aes256;
 
-- 
2.21.0

_______________________________________________
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to