]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
New test case.
authorNiels Möller <nisse@lysator.liu.se>
Wed, 9 Oct 2002 21:14:31 +0000 (23:14 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 9 Oct 2002 21:14:31 +0000 (23:14 +0200)
Rev: src/nettle/testsuite/dsa-keygen-test.c:1.1

testsuite/dsa-keygen-test.c [new file with mode: 0644]

diff --git a/testsuite/dsa-keygen-test.c b/testsuite/dsa-keygen-test.c
new file mode 100644 (file)
index 0000000..7ec83fa
--- /dev/null
@@ -0,0 +1,50 @@
+#include "testutils.h"
+
+#include "knuth-lfib.h"
+
+#if __GNUC__
+# define UNUSED __attribute__ ((__unused__))
+#else
+# define UNUSED
+#endif
+
+static void
+progress(void *ctx UNUSED, int c)
+{
+  fputc(c, stderr);
+}
+
+int
+test_main(void)
+{
+#if WITH_PUBLIC_KEY
+
+  struct dsa_public_key pub;
+  struct dsa_private_key key;
+  
+  struct knuth_lfib_ctx lfib;
+  
+  dsa_private_key_init(&key);
+  dsa_public_key_init(&pub);
+
+  /* Generate a 1024 bit key with random e */
+  knuth_lfib_init(&lfib, 13);
+
+  if (!dsa_generate_keypair(&pub, &key,
+                           &lfib, (nettle_random_func) knuth_lfib_random,
+                           NULL, verbose ? progress : NULL,
+                           1024))
+    FAIL();
+
+  test_dsa_key(&pub, &key);
+  test_dsa(&pub, &key);
+
+  dsa_public_key_clear(&pub);
+  dsa_private_key_clear(&key);
+  
+  SUCCESS();
+  
+#else /* !WITH_PUBLIC_KEY */
+  SKIP();
+#endif /* !WITH_PUBLIC_KEY */
+}