]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Contributed by Daniel Kahn Gillmor:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Wed, 23 Mar 2011 10:35:00 +0000 (11:35 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 23 Mar 2011 10:35:00 +0000 (11:35 +0100)
* testsuite/Makefile.in (TS_NETTLE_SOURCES): Added
meta-hash-test.c, meta-cipher-test.c, and meta-armor-test.c.

* testsuite/meta-hash-test.c: New file.
* testsuite/meta-cipher-test.c: New file.
* testsuite/meta-armor-test.c: New file.

Rev: nettle/testsuite/.test-rules.make:1.10
Rev: nettle/testsuite/Makefile.in:1.13
Rev: nettle/testsuite/meta-armor-test.c:1.1
Rev: nettle/testsuite/meta-cipher-test.c:1.1
Rev: nettle/testsuite/meta-hash-test.c:1.1

testsuite/.test-rules.make
testsuite/Makefile.in
testsuite/meta-armor-test.c [new file with mode: 0644]
testsuite/meta-cipher-test.c [new file with mode: 0644]
testsuite/meta-hash-test.c [new file with mode: 0644]

index 1233307b2c587cbec17ebdfa732f7a37a2e52f58..fc234729908576dcad7a0d3e9370a8d13e5f4bdf 100644 (file)
@@ -82,6 +82,15 @@ gcm-test$(EXEEXT): gcm-test.$(OBJEXT)
 hmac-test$(EXEEXT): hmac-test.$(OBJEXT)
        $(LINK) hmac-test.$(OBJEXT) $(TEST_OBJS) -o hmac-test$(EXEEXT)
 
+meta-hash-test$(EXEEXT): meta-hash-test.$(OBJEXT)
+       $(LINK) meta-hash-test.$(OBJEXT) $(TEST_OBJS) -o meta-hash-test$(EXEEXT)
+
+meta-cipher-test$(EXEEXT): meta-cipher-test.$(OBJEXT)
+       $(LINK) meta-cipher-test.$(OBJEXT) $(TEST_OBJS) -o meta-cipher-test$(EXEEXT)
+
+meta-armor-test$(EXEEXT): meta-armor-test.$(OBJEXT)
+       $(LINK) meta-armor-test.$(OBJEXT) $(TEST_OBJS) -o meta-armor-test$(EXEEXT)
+
 buffer-test$(EXEEXT): buffer-test.$(OBJEXT)
        $(LINK) buffer-test.$(OBJEXT) $(TEST_OBJS) -o buffer-test$(EXEEXT)
 
index 6eef3dc30ef17ad736c0b25ec15d06dc481bd6da..8a263cb3121c80141280e358ff30b851d0a229bb 100644 (file)
@@ -22,6 +22,7 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
                    serpent-test.c twofish-test.c \
                    knuth-lfib-test.c \
                    cbc-test.c ctr-test.c gcm-test.c hmac-test.c \
+                   meta-hash-test.c meta-cipher-test.c meta-armor-test.c \
                    buffer-test.c yarrow-test.c
 
 TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
diff --git a/testsuite/meta-armor-test.c b/testsuite/meta-armor-test.c
new file mode 100644 (file)
index 0000000..a99064b
--- /dev/null
@@ -0,0 +1,27 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* armors[] = {
+  "base16",
+  "base64"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(armors)/sizeof(*armors);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_armors[j]; j++) {
+      if (0 == strcmp(armors[i], nettle_armors[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_armors[j]); /* make sure we found a matching armor */
+  }
+  j = 0;
+  while (NULL != nettle_armors[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any armors */
+  SUCCESS();
+}
+  
diff --git a/testsuite/meta-cipher-test.c b/testsuite/meta-cipher-test.c
new file mode 100644 (file)
index 0000000..1bb74d8
--- /dev/null
@@ -0,0 +1,43 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* ciphers[] = {
+  "aes128",
+  "aes192",
+  "aes256",
+  "arctwo40",
+  "arctwo64",
+  "arctwo128",
+  "arctwo_gutmann128",
+  "arcfour128",
+  "camellia128",
+  "camellia192",
+  "camellia256",
+  "cast128",
+  "serpent128",
+  "serpent192",
+  "serpent256",
+  "twofish128",
+  "twofish192",
+  "twofish256"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(ciphers)/sizeof(*ciphers);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_ciphers[j]; j++) {
+      if (0 == strcmp(ciphers[i], nettle_ciphers[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_ciphers[j]); /* make sure we found a matching cipher */
+  }
+  j = 0;
+  while (NULL != nettle_ciphers[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any ciphers */
+  SUCCESS();
+}
+  
diff --git a/testsuite/meta-hash-test.c b/testsuite/meta-hash-test.c
new file mode 100644 (file)
index 0000000..d7f251c
--- /dev/null
@@ -0,0 +1,33 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* hashes[] = {
+  "md2",
+  "md4",
+  "md5",
+  "sha1",
+  "sha224",
+  "sha256",
+  "sha384",
+  "sha512"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(hashes)/sizeof(*hashes);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_hashes[j]; j++) {
+      if (0 == strcmp(hashes[i], nettle_hashes[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_hashes[j]); /* make sure we found a matching hash */
+  }
+  j = 0;
+  while (NULL != nettle_hashes[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any hashes */
+  SUCCESS();
+}
+