new test case for afs string2key
authorKen Raeburn <raeburn@mit.edu>
Sat, 20 Jan 2001 13:08:45 +0000 (13:08 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 20 Jan 2001 13:08:45 +0000 (13:08 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12924 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/des/ChangeLog
src/lib/crypto/des/Makefile.in
src/lib/crypto/des/t_afss2k.c [new file with mode: 0644]

index 0dab08cede9aeb143a6595b75e9ea26ca746c179..718653b3dd4e3300f309df63278c4a53babb9648 100644 (file)
@@ -1,3 +1,11 @@
+2001-01-20  Ken Raeburn  <raeburn@mit.edu>
+
+       * t_afss2k.c: New file.
+       * Makefile.in (t_afss2k): New target.
+       (TAFSS2KOBJS): New variable.
+       (check-unix): Run t_afss2k.
+       (clean): Get rid of t_afss2k binaries.
+
 2000-10-17  Ezra Peisach  <epeisach@mit.edu>
 
        * des_int.h: Change prototypes for mit_des_cbc_encrypt(),
index 2634584f7283db58f94fcc9428e5de2ba80e36f5..4091f9690e382975aab222906dc667e1c2f0b90d 100644 (file)
@@ -69,16 +69,24 @@ verify$(EXEEXT): t_verify.$(OBJEXT) $(TOBJS) f_parity.$(OBJEXT) \
 destest$(EXEEXT): destest.$(OBJEXT) $(TOBJS)
        $(CC_LINK) -o $@ destest.$(OBJEXT) $(TOBJS)
 
-check-unix:: verify destest
+TAFSS2KOBJS =                                                          \
+       t_afss2k.$(OBJEXT) $(TOBJS)                                     \
+       afsstring2key.$(OBJEXT) f_parity.$(OBJEXT) weak_key.$(OBJEXT)
+
+t_afss2k$(EXEEXT): $(TAFSS2KOBJS) $(COM_ERR_DEPLIB)
+       $(CC_LINK) -o $@ $(TAFSS2KOBJS) -lcom_err
+
+check-unix:: verify destest t_afss2k
        $(RUN_SETUP) ./verify -z
        $(RUN_SETUP) ./verify -m
        $(RUN_SETUP) ./verify
        $(RUN_SETUP) ./destest < $(srcdir)/keytest.data
+       $(RUN_SETUP) ./t_afss2k
 
 check-windows::
 
 clean:: 
        $(RM) destest$(EXEEXT) verify$(EXEEXT) destest.$(OBJEXT) \
-       t_verify.$(OBJEXT)
+       t_verify.$(OBJEXT) t_afss2k.$(OBJEXT) t_afss2k$(EXEEXT)
 
 clean-unix:: clean-libobjs
diff --git a/src/lib/crypto/des/t_afss2k.c b/src/lib/crypto/des/t_afss2k.c
new file mode 100644 (file)
index 0000000..23546c7
--- /dev/null
@@ -0,0 +1,88 @@
+#include "des_int.h"
+
+static const char *me;
+
+struct test_case {
+       char *saltstr;
+       int saltlen;
+       unsigned char keys[12][8];
+};
+
+struct test_case test_cases[] = {
+       {
+               "Sodium Chloride", -1,
+               {
+                       { 0xa4, 0xd0, 0xd0, 0x9b, 0x86, 0x92, 0xb0, 0xc2, },
+                       { 0xf1, 0xf2, 0x9e, 0xab, 0xd0, 0xef, 0xdf, 0x73, },
+                       { 0xd6, 0x85, 0x61, 0xc4, 0xf2, 0x94, 0xf4, 0xa1, },
+                       { 0xd0, 0xe3, 0xa7, 0x83, 0x94, 0x61, 0xe0, 0xd0, },
+                       { 0xd5, 0x62, 0xcd, 0x94, 0x61, 0xcb, 0x97, 0xdf, },
+                       { 0x9e, 0xa2, 0xa2, 0xec, 0xa8, 0x8c, 0x6b, 0x8f, },
+                       { 0xe3, 0x91, 0x6d, 0xd3, 0x85, 0xf1, 0x67, 0xc4, },
+                       { 0xf4, 0xc4, 0x73, 0xc8, 0x8a, 0xe9, 0x94, 0x6d, },
+                       { 0xa1, 0x9e, 0xb3, 0xad, 0x6b, 0xe3, 0xab, 0xd9, },
+                       { 0xad, 0xa1, 0xce, 0x10, 0x37, 0x83, 0xa7, 0x8c, },
+                       { 0xd3, 0x01, 0xd0, 0xf7, 0x3e, 0x7a, 0x49, 0x0b, },
+                       { 0xb6, 0x2a, 0x4a, 0xec, 0x9d, 0x4c, 0x68, 0xdf, },
+               }
+       },
+       {
+               "NaCl", -1,
+               {
+                       { 0x61, 0xef, 0xe6, 0x83, 0xe5, 0x8a, 0x6b, 0x98 },
+                       { 0x68, 0xcd, 0x68, 0xad, 0xc4, 0x86, 0xcd, 0xe5 },
+                       { 0x83, 0xa1, 0xc8, 0x86, 0x8f, 0x67, 0xd0, 0x62 },
+                       { 0x9e, 0xc7, 0x8f, 0xa4, 0xa4, 0xb3, 0xe0, 0xd5 },
+                       { 0xd9, 0x92, 0x86, 0x8f, 0x9d, 0x8c, 0x85, 0xe6 },
+                       { 0xda, 0xf2, 0x92, 0x83, 0xf4, 0x9b, 0xa7, 0xad },
+                       { 0x91, 0xcd, 0xad, 0xef, 0x86, 0xdf, 0xd3, 0xa2 },
+                       { 0x73, 0xd3, 0x67, 0x68, 0x8f, 0x6e, 0xe3, 0x73 },
+                       { 0xc4, 0x61, 0x85, 0x9d, 0xad, 0xf4, 0xdc, 0xb0 },
+                       { 0xe9, 0x02, 0x83, 0x16, 0x2c, 0xec, 0xe0, 0x08 },
+                       { 0x61, 0xc8, 0x26, 0x29, 0xd9, 0x73, 0x6e, 0xb6 },
+                       { 0x8c, 0xa8, 0x9e, 0xc4, 0xa8, 0xdc, 0x31, 0x73 },
+               }
+       },
+};
+
+static void
+do_it (struct test_case *tcase)
+{
+       unsigned char keydata[8];
+       krb5_data salt, passwd;
+       krb5_keyblock key;
+       krb5_error_code err;
+       int i;
+
+       key.contents = keydata;
+       key.length = sizeof (keydata);
+
+       salt.data = tcase->saltstr;
+       if (tcase->saltlen == -1)
+               salt.length = strlen (tcase->saltstr);
+       else
+               salt.length = tcase->saltlen;
+
+       passwd.data = "My Password";
+       for (i = 0; i < 12; i++) {
+               passwd.length = i;
+               err = mit_afs_string_to_key (&key, &passwd, &salt);
+               if (err != 0) {
+                       com_err (me, err, "");
+                       exit (1);
+               }
+               if (memcmp (tcase->keys[i], keydata, 8) != 0)
+                       abort ();
+       }
+}
+
+int
+main (int argc, char *argv[])
+{
+       int i;
+
+       me = argv[0];
+       for (i = 0; i < sizeof (test_cases) / sizeof (struct test_case); i++)
+               do_it (&test_cases[i]);
+       return 0;
+}