summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto/crypto_tests
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2011-03-05 13:36:53 +0000
committerGreg Hudson <ghudson@mit.edu>2011-03-05 13:36:53 +0000
commitb2ae990817b9ccfcaabf550fc0a6c200342e42d1 (patch)
tree2e08e168bafd71226ce3a7331e0c939f90b10579 /src/lib/crypto/crypto_tests
parent624e6a7b3f59fd76a92f556b679f9d872167853b (diff)
downloadkrb5-b2ae990817b9ccfcaabf550fc0a6c200342e42d1.tar.gz
krb5-b2ae990817b9ccfcaabf550fc0a6c200342e42d1.tar.xz
krb5-b2ae990817b9ccfcaabf550fc0a6c200342e42d1.zip
Move t_cf2 from lib/crypto/builtin to lib/crypto/crypto_tests, as it
is not specific to the builtin module. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24680 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/crypto_tests')
-rw-r--r--src/lib/crypto/crypto_tests/Makefile.in16
-rw-r--r--src/lib/crypto/crypto_tests/deps2
-rw-r--r--src/lib/crypto/crypto_tests/t_cf2.c89
-rw-r--r--src/lib/crypto/crypto_tests/t_cf2.comments6
-rw-r--r--src/lib/crypto/crypto_tests/t_cf2.expected5
-rw-r--r--src/lib/crypto/crypto_tests/t_cf2.in25
6 files changed, 137 insertions, 6 deletions
diff --git a/src/lib/crypto/crypto_tests/Makefile.in b/src/lib/crypto/crypto_tests/Makefile.in
index e137083ec..23e6c06de 100644
--- a/src/lib/crypto/crypto_tests/Makefile.in
+++ b/src/lib/crypto/crypto_tests/Makefile.in
@@ -19,6 +19,7 @@ EXTRADEPSRCS=\
$(srcdir)/vectors.c \
$(srcdir)/aes-test.c \
$(srcdir)/camellia-test.c \
+ $(srcdir)/t_cf2.c \
$(srcdir)/t_cksum.c \
$(srcdir)/t_cksums.c \
$(srcdir)/t_crc.c \
@@ -39,7 +40,7 @@ check-unix:: t_nfold t_encrypt t_decrypt t_prf t_prng t_cmac t_hmac \
aes-test \
camellia-test \
t_mddriver4 t_mddriver \
- t_crc t_cts t_short t_str2key t_derive t_fork
+ t_crc t_cts t_short t_str2key t_derive t_fork t_cf2
$(RUN_SETUP) $(VALGRIND) ./t_nfold
$(RUN_SETUP) $(VALGRIND) ./t_encrypt
$(RUN_SETUP) $(VALGRIND) ./t_decrypt
@@ -66,10 +67,8 @@ check-unix:: t_nfold t_encrypt t_decrypt t_prf t_prng t_cmac t_hmac \
$(RUN_SETUP) $(VALGRIND) ./t_str2key
$(RUN_SETUP) $(VALGRIND) ./t_derive
$(RUN_SETUP) $(VALGRIND) ./t_fork
-
-
-
-
+ $(RUN_SETUP) $(VALGRIND) ./t_cf2 <$(srcdir)/t_cf2.in >t_cf2.output
+ diff t_cf2.output $(srcdir)/t_cf2.expected
# $(RUN_SETUP) $(VALGRIND) ./t_pkcs5
t_nfold$(EXEEXT): t_nfold.$(OBJEXT) nfold.$(OBJEXT) $(SUPPORT_DEPLIB)
@@ -155,6 +154,9 @@ t_derive$(EXEEXT): t_derive.$(OBJEXT) $(SUPPORT_DEPLIB)
t_fork$(EXEEXT): t_fork.$(OBJEXT) $(SUPPORT_DEPLIB)
$(CC_LINK) -o $@ t_fork.$(OBJEXT) -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB)
+t_cf2$(EXEEXT): t_cf2.$(OBJEXT) $(SUPPORT_DEPLIB)
+ $(CC_LINK) -o $@ t_cf2.$(OBJEXT) -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB)
+
clean::
$(RM) t_nfold.o t_nfold nfold.$(OBJEXT) t_encrypt t_encrypt.o \
t_decrypt.o t_decrypt t_prng.o t_prng t_cmac.o t_cmac \
@@ -165,7 +167,9 @@ clean::
t_cksum4 t_cksum4.o t_cksum5 t_cksum5.o t_cksums t_cksums.o \
t_kperf.o t_kperf t_short t_short.o t_str2key t_str2key.o \
t_derive t_derive.o t_fork t_fork.o \
- t_mddriver$(EXEEXT) $(OUTPRE)t_mddriver.$(OBJEXT)
+ t_mddriver$(EXEEXT) $(OUTPRE)t_mddriver.$(OBJEXT) \
+ camellia-test camellia-test.o camellia-vt.txt \
+ t_cf2 t_cf2.o t_cf2.output
-$(RM) t_prng.output
-$(RM) t_prf.output
diff --git a/src/lib/crypto/crypto_tests/deps b/src/lib/crypto/crypto_tests/deps
index 01aa2dc0f..5d006d6a8 100644
--- a/src/lib/crypto/crypto_tests/deps
+++ b/src/lib/crypto/crypto_tests/deps
@@ -147,6 +147,8 @@ $(OUTPRE)camellia-test.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
$(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
$(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
camellia-test.c
+$(OUTPRE)t_cf2.$(OBJEXT): $(BUILDTOP)/include/krb5/krb5.h \
+ $(COM_ERR_DEPS) $(top_srcdir)/include/krb5.h t_cf2.c
$(OUTPRE)t_cksum.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
$(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
$(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
diff --git a/src/lib/crypto/crypto_tests/t_cf2.c b/src/lib/crypto/crypto_tests/t_cf2.c
new file mode 100644
index 000000000..550192c44
--- /dev/null
+++ b/src/lib/crypto/crypto_tests/t_cf2.c
@@ -0,0 +1,89 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * lib/crypto/t_cf2.c
+ *
+ * Copyright (C) 2004, 2009 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * This file contains tests for theKRB-FX-CF2 code in Kerberos, based
+ *on the PRF regression tests. It reads an input file, and writes an
+ *output file. It is assumed that the output file will be diffed
+ *against expected output to see whether regression tests pass. The
+ *input file is a very primitive format.
+ *First line: enctype
+ *second line: key to pass to string2key; also used as salt
+ *Third line: second key to pass to string2key
+ *fourth line: pepper1
+ *fifth line: pepper2
+ *scanf is used to read the file, so interior spaces are not permitted. The program outputs the hex bytes of the key.
+ */
+#include <krb5.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+int main () {
+ char pepper1[1024], pepper2[1024];
+ krb5_keyblock *k1 = NULL, *k2 = NULL, *out = NULL;
+ krb5_data s2k;
+ unsigned int i;
+ while (1) {
+ krb5_enctype enctype;
+ char s[1025];
+
+ if (scanf( "%d", &enctype) == EOF)
+ break;
+ if (scanf("%1024s", &s[0]) == EOF)
+ break;
+ assert (krb5_init_keyblock(0, enctype, 0, &k1) == 0);
+ s2k.data = &s[0];
+ s2k.length = strlen(s);
+ assert(krb5_c_string_to_key (0, enctype, &s2k, &s2k, k1) == 0);
+ if (scanf("%1024s", &s[0]) == EOF)
+ break;
+ assert (krb5_init_keyblock(0, enctype, 0, &k2) == 0);
+ s2k.data = &s[0];
+ s2k.length = strlen(s);
+ assert(krb5_c_string_to_key (0, enctype, &s2k, &s2k, k2) == 0);
+ if (scanf("%1024s %1024s", pepper1, pepper2) == EOF)
+ break;
+ assert(krb5_c_fx_cf2_simple(0, k1, pepper1,
+ k2, pepper2, &out) ==0);
+ i = out->length;
+ for (; i > 0; i--) {
+ printf ("%02x",
+ (unsigned int) ((unsigned char) out->contents[out->length-i]));
+ }
+ printf ("\n");
+
+ krb5_free_keyblock(0,out);
+ out = NULL;
+
+ krb5_free_keyblock(0, k1);
+ k1 = NULL;
+ krb5_free_keyblock(0, k2);
+ k2 = NULL;
+ }
+
+ return (0);
+}
diff --git a/src/lib/crypto/crypto_tests/t_cf2.comments b/src/lib/crypto/crypto_tests/t_cf2.comments
new file mode 100644
index 000000000..0643b6507
--- /dev/null
+++ b/src/lib/crypto/crypto_tests/t_cf2.comments
@@ -0,0 +1,6 @@
+The first test mirrors the first two tests in t_prf.in.
+
+The second test mirrors the following four tests in t_prf.in.
+
+The third and fourth tests are simple tests of the DES and 3DES PRF.
+The fifth test is the same simple test for RC4.
diff --git a/src/lib/crypto/crypto_tests/t_cf2.expected b/src/lib/crypto/crypto_tests/t_cf2.expected
new file mode 100644
index 000000000..007000f21
--- /dev/null
+++ b/src/lib/crypto/crypto_tests/t_cf2.expected
@@ -0,0 +1,5 @@
+97df97e4b798b29eb31ed7280287a92a
+4d6ca4e629785c1f01baf55e2e548566b9617ae3a96868c337cb93b5e72b1c7b
+43bae3738c9467e6
+e58f9eb643862c13ad38e529313462a7f73e62834fe54a01
+24d7f6b6bae4e5c00d2082c5ebab3672
diff --git a/src/lib/crypto/crypto_tests/t_cf2.in b/src/lib/crypto/crypto_tests/t_cf2.in
new file mode 100644
index 000000000..094c2392f
--- /dev/null
+++ b/src/lib/crypto/crypto_tests/t_cf2.in
@@ -0,0 +1,25 @@
+17
+key1
+key2
+a
+b
+18
+key1
+key2
+a
+b
+1
+key1
+key2
+a
+b
+16
+key1
+key2
+a
+b
+23
+key1
+key2
+a
+b