Implemented algorithm array nettle_aeads.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 8 May 2014 19:09:54 +0000 (21:09 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 8 May 2014 19:15:44 +0000 (21:15 +0200)
ChangeLog
Makefile.in
nettle-meta-aeads.c [new file with mode: 0644]
nettle-meta.h
testsuite/.test-rules.make
testsuite/Makefile.in
testsuite/meta-aead-test.c [new file with mode: 0644]

index 127dbd35b1182c1a50072ba7cce729a33b8d6e7c..97380db3e289f05faa0d466c0d5e2c3c1b37f989 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2014-05-08  Niels Möller  <nisse@lysator.liu.se>
 
+       * Makefile.in (nettle_SOURCES): Added nettle-meta-aeads.c.
+       * nettle-meta.h (nettle_aeads): Declare array.
+       * nettle-meta-aeads.c (nettle_aeads): New file, new array.
+       * testsuite/meta-aead-test.c: New test case.
+       * testsuite/Makefile.in (TS_NETTLE_SOURCES): Added
+       meta-aead-test.c.
+
        * aclocal.m4 (GMP_PROG_CC_FOR_BUILD): If CC_FOR_BUILD is gcc, add
        -O option. This makes eccdata twice as fast.
 
index 42dd190b244adf5c112360f8c5ebcff3ac1b9f64..a1ac54dd6e409c4f83fc155db8b3cc96ffb88368 100644 (file)
@@ -106,8 +106,8 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
                 md2.c md2-meta.c md4.c md4-meta.c \
                 md5.c md5-compress.c md5-compat.c md5-meta.c \
                 memxor.c \
-                nettle-meta-armors.c nettle-meta-ciphers.c \
-                nettle-meta-hashes.c \
+                nettle-meta-aeads.c nettle-meta-armors.c \
+                nettle-meta-ciphers.c nettle-meta-hashes.c \
                 pbkdf2.c pbkdf2-hmac-sha1.c pbkdf2-hmac-sha256.c \
                 poly1305-aes.c poly1305-internal.c \
                 realloc.c \
diff --git a/nettle-meta-aeads.c b/nettle-meta-aeads.c
new file mode 100644 (file)
index 0000000..8c05264
--- /dev/null
@@ -0,0 +1,49 @@
+/* nettle-meta-aeads.c
+
+   Copyright (C) 2014 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 <stddef.h>
+
+#include "nettle-meta.h"
+
+const struct nettle_aead * const nettle_aeads[] = {
+  &nettle_gcm_aes128,
+  &nettle_gcm_aes192,
+  &nettle_gcm_aes256,
+  &nettle_gcm_camellia128,
+  &nettle_gcm_camellia256,
+  &nettle_eax_aes128,
+  &nettle_chacha_poly1305,
+  NULL
+};
index 23a47ed9c6b5e11914d2c335e3bfe55b3bf33dba..2d8d5b84b8fb65e4975b42fdb36a0e1a1e9ef48f 100644 (file)
@@ -155,6 +155,10 @@ struct nettle_aead
   nettle_hash_digest_func *digest;
 };
 
+/* null-terminated list of aead constructions implemented by this
+   version of nettle */
+extern const struct nettle_aead * const nettle_aeads[];
+
 extern const struct nettle_aead nettle_gcm_aes128;
 extern const struct nettle_aead nettle_gcm_aes192;
 extern const struct nettle_aead nettle_gcm_aes256;
index 03711c4b60c46bade46e08e0a46c80d96ed1ceb2..8fc7ed415637f356605e453d2d700fd2d341c07c 100644 (file)
@@ -136,6 +136,9 @@ meta-hash-test$(EXEEXT): meta-hash-test.$(OBJEXT)
 meta-cipher-test$(EXEEXT): meta-cipher-test.$(OBJEXT)
        $(LINK) meta-cipher-test.$(OBJEXT) $(TEST_OBJS) -o meta-cipher-test$(EXEEXT)
 
+meta-aead-test$(EXEEXT): meta-aead-test.$(OBJEXT)
+       $(LINK) meta-aead-test.$(OBJEXT) $(TEST_OBJS) -o meta-aead-test$(EXEEXT)
+
 meta-armor-test$(EXEEXT): meta-armor-test.$(OBJEXT)
        $(LINK) meta-armor-test.$(OBJEXT) $(TEST_OBJS) -o meta-armor-test$(EXEEXT)
 
index 2ea2bf95a15f17b11978be58f50e8669b28b6f8c..4028c6b6db4039bccf59e658d25699780683f094 100644 (file)
@@ -28,7 +28,8 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
                    cbc-test.c ctr-test.c gcm-test.c eax-test.c ccm-test.c \
                    poly1305-test.c chacha-poly1305-test.c \
                    hmac-test.c umac-test.c \
-                   meta-hash-test.c meta-cipher-test.c meta-armor-test.c \
+                   meta-hash-test.c meta-cipher-test.c\
+                   meta-aead-test.c meta-armor-test.c \
                    buffer-test.c yarrow-test.c pbkdf2-test.c
 
 TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
diff --git a/testsuite/meta-aead-test.c b/testsuite/meta-aead-test.c
new file mode 100644 (file)
index 0000000..1fcede4
--- /dev/null
@@ -0,0 +1,32 @@
+#include "testutils.h"
+#include "nettle-internal.h"
+#include "nettle-meta.h"
+
+const char* aeads[] = {
+  "gcm_aes128",
+  "gcm_aes192",
+  "gcm_aes256",
+  "gcm_camellia128",
+  "gcm_camellia256",
+  "eax_aes128",
+  "chacha_poly1305",
+};
+
+void
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(aeads)/sizeof(*aeads);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_aeads[j]; j++) {
+      if (0 == strcmp(aeads[i], nettle_aeads[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_aeads[j]); /* make sure we found a matching aead */
+  }
+  j = 0;
+  while (NULL != nettle_aeads[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any aeads */
+}
+