diff options
author | Niels Möller <nisse@lysator.liu.se> | 2014-05-08 21:09:54 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2014-05-08 21:15:44 +0200 |
commit | aa52330e5428de2943dc053bf5690682ed9619da (patch) | |
tree | 09bf14fac208fe674143bc6f086bd78d85128fed | |
parent | b672e5530bd036eab6dd2aefbd0ab936517fbae4 (diff) | |
download | nettle-aa52330e5428de2943dc053bf5690682ed9619da.tar.gz |
Implemented algorithm array nettle_aeads.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | nettle-meta-aeads.c | 49 | ||||
-rw-r--r-- | nettle-meta.h | 4 | ||||
-rw-r--r-- | testsuite/.test-rules.make | 3 | ||||
-rw-r--r-- | testsuite/Makefile.in | 3 | ||||
-rw-r--r-- | testsuite/meta-aead-test.c | 32 |
7 files changed, 99 insertions, 3 deletions
@@ -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. diff --git a/Makefile.in b/Makefile.in index 42dd190b..a1ac54dd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 index 00000000..8c052646 --- /dev/null +++ b/nettle-meta-aeads.c @@ -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 +}; diff --git a/nettle-meta.h b/nettle-meta.h index 23a47ed9..2d8d5b84 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -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; diff --git a/testsuite/.test-rules.make b/testsuite/.test-rules.make index 03711c4b..8fc7ed41 100644 --- a/testsuite/.test-rules.make +++ b/testsuite/.test-rules.make @@ -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) diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 2ea2bf95..4028c6b6 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -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 index 00000000..1fcede40 --- /dev/null +++ b/testsuite/meta-aead-test.c @@ -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 */ +} + |