summaryrefslogtreecommitdiffstats
path: root/src/lib/des425
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2001-04-07 04:45:22 +0000
committerKen Raeburn <raeburn@mit.edu>2001-04-07 04:45:22 +0000
commite8855363194dc68093492a4ec6fb93805d4174ce (patch)
tree8cf20131474d7df0ed8b40502842c36e9036936d /src/lib/des425
parentb556bada8946fa2d0754b03af82d9eb1c9912884 (diff)
downloadkrb5-e8855363194dc68093492a4ec6fb93805d4174ce.tar.gz
krb5-e8855363194dc68093492a4ec6fb93805d4174ce.tar.xz
krb5-e8855363194dc68093492a4ec6fb93805d4174ce.zip
add quad_cksum test case
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13147 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/des425')
-rw-r--r--src/lib/des425/ChangeLog6
-rw-r--r--src/lib/des425/Makefile.in6
-rw-r--r--src/lib/des425/t_quad.c101
3 files changed, 112 insertions, 1 deletions
diff --git a/src/lib/des425/ChangeLog b/src/lib/des425/ChangeLog
index 49265173d5..2cc9e3f53f 100644
--- a/src/lib/des425/ChangeLog
+++ b/src/lib/des425/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-07 Ken Raeburn <raeburn@mit.edu>
+
+ * t_quad.c: New file.
+ * Makefile.in (t_quad): New target.
+ (check-unix): Depend on and run t_quad.
+
2000-10-17 Ezra Peisach <epeisach@mit.edu>
* cksum.c (des_cbc_cksum): Length is unsigned long.
diff --git a/src/lib/des425/Makefile.in b/src/lib/des425/Makefile.in
index 863a34d237..8e1ce31b72 100644
--- a/src/lib/des425/Makefile.in
+++ b/src/lib/des425/Makefile.in
@@ -88,10 +88,14 @@ shared:
verify: verify.o $(DES425_DEPLIB) $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o $@ verify.o $(DES425_LIB) $(KRB5_BASE_LIBS)
-check-unix:: verify
+t_quad: t_quad.o quad_cksum.o
+ $(CC_LINK) -o $@ t_quad.o quad_cksum.o
+
+check-unix:: verify t_quad
$(RUN_SETUP) ./verify -z
$(RUN_SETUP) ./verify -m
$(RUN_SETUP) ./verify
+ $(RUN_SETUP) ./t_quad
check-windows::
diff --git a/src/lib/des425/t_quad.c b/src/lib/des425/t_quad.c
new file mode 100644
index 0000000000..106b674373
--- /dev/null
+++ b/src/lib/des425/t_quad.c
@@ -0,0 +1,101 @@
+/*
+ * lib/des425/t_quad.c
+ *
+ * Copyright 2001 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.
+ */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include "des.h"
+
+extern char *errmsg();
+extern int errno;
+extern unsigned long quad_cksum();
+char *progname;
+int des_debug;
+unsigned DES_INT32 out[8];
+struct {
+ unsigned char text[64];
+ unsigned DES_INT32 out[8];
+} tests[] = {
+ {
+ "Now is the time for all ",
+ {
+ 0x6c6240c5, 0x77db9b1c, 0x7991d316, 0x4e688989,
+ 0x27a0ae6a, 0x13be2da4, 0x4a2fdfc6, 0x7dfc494c,
+ }
+ }, {
+ "7654321 Now is the time for ",
+ {
+ 0x36839db5, 0x4d7be717, 0x15b0f5b6, 0x2304ff9c,
+ 0x75472d26, 0x6a5f833c, 0x7399a4ee, 0x1170fdfb,
+ }
+ }, {
+ {2,0,0,0, 1,0,0,0},
+ {
+ 0x7c81f205, 0x63d38e38, 0x314ece44, 0x05d3a4f8,
+ 0x6e10db76, 0x3eda7685, 0x2e841332, 0x1bdc7fd3,
+ }
+ },
+};
+
+/* 0x0123456789abcdef */
+unsigned char default_key[8] = {
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef
+};
+
+int
+main(argc,argv)
+ int argc;
+ char *argv[];
+{
+ int i;
+ int fail=0;
+
+ progname=argv[0]; /* salt away invoking program */
+
+ /* use known input and key */
+
+ for (i = 0; i < 3; i++) {
+ int wrong = 0, j;
+ des_quad_cksum (tests[i].text, out, 64L, 4, default_key);
+ if (tests[i].text[0] == 2)
+ printf ("quad_cksum(<binary blob 1>) = {");
+ else
+ printf ("quad_cksum(\"%s\"...zero fill...) = {", tests[i].text);
+ for (j = 0; j < 8; j++) {
+ if (j == 0 || j == 4)
+ printf ("\n\t");
+ printf (" 0x%lx,", (unsigned long) out[j]);
+ if (out[j] != tests[i].out[j])
+ wrong = 1;
+ }
+ printf ("\n}\n");
+ if (wrong) {
+ printf ("wrong result!\n");
+ fail = 1;
+ }
+ }
+ return fail;
+}