summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorBarry Jaspan <bjaspan@mit.edu>1997-05-05 21:12:33 +0000
committerBarry Jaspan <bjaspan@mit.edu>1997-05-05 21:12:33 +0000
commitaeea6a838e995040a6978fcdcee85c8f740cdd17 (patch)
treef3b0c0c7582b37e3761024d545929014fb6979f0 /src/lib
parent3dd97b8bbb66cbbd2c9656c837e4fdd9b0c77d51 (diff)
downloadkrb5-aeea6a838e995040a6978fcdcee85c8f740cdd17.tar.gz
krb5-aeea6a838e995040a6978fcdcee85c8f740cdd17.tar.xz
krb5-aeea6a838e995040a6978fcdcee85c8f740cdd17.zip
* setkey-test.c, configure.in: add rules to test for correct
random()-equivlant function git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10085 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kadm5/unit-test/ChangeLog5
-rw-r--r--src/lib/kadm5/unit-test/configure.in1
-rw-r--r--src/lib/kadm5/unit-test/setkey-test.c20
3 files changed, 24 insertions, 2 deletions
diff --git a/src/lib/kadm5/unit-test/ChangeLog b/src/lib/kadm5/unit-test/ChangeLog
index 4401065c92..23c7500153 100644
--- a/src/lib/kadm5/unit-test/ChangeLog
+++ b/src/lib/kadm5/unit-test/ChangeLog
@@ -1,3 +1,8 @@
+Mon May 5 17:11:44 1997 Barry Jaspan <bjaspan@mit.edu>
+
+ * setkey-test.c, configure.in: add rules to test for correct
+ random()-equivlant function
+
Mon Mar 31 17:39:52 1997 Barry Jaspan <bjaspan@mit.edu>
* Makefile.in, setkey-test.c: add support for setkey
diff --git a/src/lib/kadm5/unit-test/configure.in b/src/lib/kadm5/unit-test/configure.in
index fb32f917e6..d49a2bba7e 100644
--- a/src/lib/kadm5/unit-test/configure.in
+++ b/src/lib/kadm5/unit-test/configure.in
@@ -4,6 +4,7 @@ AC_CANONICAL_HOST
dnl The following are tests for the presence of programs required for testing
AC_CHECK_PROG(RUNTEST,runtest,runtest)
AC_CHECK_PROG(PERL,perl,perl)
+AC_CHECK_FUNCS(srand48 srand srandom)
AC_KRB5_TCL
if test "$PERL" = perl -a "$RUNTEST" = runtest -a "$TCL_LIBS" != ""; then
DO_TEST=ok
diff --git a/src/lib/kadm5/unit-test/setkey-test.c b/src/lib/kadm5/unit-test/setkey-test.c
index e329fce25e..fed4e0e74e 100644
--- a/src/lib/kadm5/unit-test/setkey-test.c
+++ b/src/lib/kadm5/unit-test/setkey-test.c
@@ -2,6 +2,22 @@
#include <krb5.h>
#include <kadm5/admin.h>
+#if HAVE_SRAND48
+#define RAND() lrand48()
+#define SRAND(a) srand48(a)
+#define RAND_TYPE long
+#elif HAVE_SRAND
+#define RAND() rand()
+#define SRAND(a) srand(a)
+#define RAND_TYPE int
+#elif HAVE_SRANDOM
+#define RAND() random()
+#define SRAND(a) srandom(a)
+#define RAND_TYPE long
+#else /* no random */
+need a random number generator
+#endif /* no random */
+
krb5_keyblock test1[] = {
0, ENCTYPE_DES_CBC_CRC, 0, 0,
-1,
@@ -107,7 +123,7 @@ main(int argc, char **argv)
}
/* these pw's don't need to be secure, just different every time */
- srandom(getpid() ^ time(0));
+ SRAND((RAND_TYPE)time((void *) NULL));
pwdata.data = pw;
pwdata.length = sizeof(pw);
@@ -127,7 +143,7 @@ main(int argc, char **argv)
for (encnum = 0; testp[encnum].magic != -1; encnum++) {
for (i = 0; i < sizeof(pw); i++)
- pw[i] = (random() % 26) + '0'; /* XXX */
+ pw[i] = (RAND() % 26) + '0'; /* XXX */
krb5_use_enctype(context, &eblock, testp[encnum].enctype);
if (ret = krb5_string_to_key(context, &eblock, &testp[encnum],