summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-11-04 12:03:40 +0000
committerWerner Koch <wk@gnupg.org>2003-11-04 12:03:40 +0000
commitcaa019c4830e5d35dc2b988a0377b34034af8316 (patch)
tree2476eaa5e3970f7a4ee7d978aa53c24ad6c45035 /tests
parent56daf753b3749534bc180bbf8b9adc018a888885 (diff)
downloadlibgcrypt-caa019c4830e5d35dc2b988a0377b34034af8316.tar.gz
* Makefile.am (noinst_PROGRAMS): Use this so that test programs
get always build. * keygen.c (check_nonce): New. (main): Add a basic check for the nocen function.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog8
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/keygen.c38
3 files changed, 47 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 64b24f16..e8ff68fb 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-04 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am (noinst_PROGRAMS): Use this so that test programs
+ get always build.
+
+ * keygen.c (check_nonce): New.
+ (main): Add a basic check for the nocen function.
+
2003-10-31 Werner Koch <wk@gnupg.org>
* basic.c (check_aes128_cbc_cts_cipher): Make it a prototype
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c643f9ee..6b5e7035 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,6 @@ INCLUDES = -I$(top_srcdir)/src
LDADD = ../src/libgcrypt.la
EXTRA_PROGRAMS = benchmark testapi
-check_PROGRAMS = $(TESTS)
+noinst_PROGRAMS = $(TESTS)
AM_CFLAGS = @GPG_ERROR_CFLAGS@
diff --git a/tests/keygen.c b/tests/keygen.c
index 1d855f07..6cc8d4cb 100644
--- a/tests/keygen.c
+++ b/tests/keygen.c
@@ -176,7 +176,43 @@ check_rsa_keys (void)
}
+static void
+check_nonce (void)
+{
+ char a[32], b[32];
+ int i,j;
+ int oops=0;
+ if (verbose)
+ fprintf (stderr, "checking gcry_create_nonce\n");
+
+ gcry_create_nonce (a, sizeof a);
+ for (i=0; i < 10; i++)
+ {
+ gcry_create_nonce (b, sizeof b);
+ if (!memcmp (a, b, sizeof a))
+ die ("identical nounce found\n");
+ }
+ for (i=0; i < 10; i++)
+ {
+ gcry_create_nonce (a, sizeof a);
+ if (!memcmp (a, b, sizeof a))
+ die ("identical nounce found\n");
+ }
+
+ again:
+ for (i=1,j=0; i < sizeof a; i++)
+ if (a[0] == a[i])
+ j++;
+ if (j+1 == sizeof (a))
+ {
+ if (oops)
+ die ("impossible nonce found\n");
+ oops++;
+ gcry_create_nonce (a, sizeof a);
+ goto again;
+ }
+}
int
main (int argc, char **argv)
@@ -196,7 +232,9 @@ main (int argc, char **argv)
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
/* No valuable keys are create, so we can speed up our RNG. */
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
+
check_rsa_keys ();
+ check_nonce ();
return error_count? 1:0;
}