summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto/crc32
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1990-11-29 15:47:55 +0000
committerJohn Kohl <jtkohl@mit.edu>1990-11-29 15:47:55 +0000
commit8058b31c26fa81311c5881887887bece7b931323 (patch)
tree2d739f42df5bb83e2c4505f9ae112f88b4db4802 /src/lib/crypto/crc32
parentf3f634917a6a1e7936ce8ff301163d60ba20f9c6 (diff)
downloadkrb5-8058b31c26fa81311c5881887887bece7b931323.tar.gz
krb5-8058b31c26fa81311c5881887887bece7b931323.tar.xz
krb5-8058b31c26fa81311c5881887887bece7b931323.zip
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1517 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/crc32')
-rw-r--r--src/lib/crypto/crc32/crc-test58
-rw-r--r--src/lib/crypto/crc32/crctest.c86
2 files changed, 144 insertions, 0 deletions
diff --git a/src/lib/crypto/crc32/crc-test b/src/lib/crypto/crc32/crc-test
new file mode 100644
index 0000000000..22920e629a
--- /dev/null
+++ b/src/lib/crypto/crc32/crc-test
@@ -0,0 +1,58 @@
+01 77073096
+02 ee0e612c
+04 076dc419
+08 0edb8832
+10 1db71064
+20 3b6e20c8
+40 76dc4190
+80 edb88320
+
+0001 191b3141
+0002 32366282
+0004 646cc504
+0008 c8d98a08
+0010 4ac21251
+0020 958424a2
+0040 f0794f05
+0080 3b83984b
+0100 77073096
+0200 ee0e612c
+0400 076dc419
+0800 0edb8832
+1000 1db71064
+2000 3b6e20c8
+4000 76dc4190
+8000 edb88320
+
+00000001 b8bc6765
+00000002 aa09c88b
+00000004 8f629757
+00000008 c5b428ef
+00000010 5019579f
+00000020 a032af3e
+00000040 9b14583d
+00000080 ed59b63b
+00000100 01c26a37
+00000200 0384d46e
+00000400 0709a8dc
+00000800 0e1351b8
+00001000 1c26a370
+00002000 384d46e0
+00004000 709a8dc0
+00008000 e1351b80
+00010000 191b3141
+00020000 32366282
+00040000 646cc504
+00080000 c8d98a08
+00100000 4ac21251
+00200000 958424a2
+00400000 f0794f05
+00800000 3b83984b
+01000000 77073096
+02000000 ee0e612c
+04000000 076dc419
+08000000 0edb8832
+10000000 1db71064
+20000000 3b6e20c8
+40000000 76dc4190
+80000000 edb88320
diff --git a/src/lib/crypto/crc32/crctest.c b/src/lib/crypto/crc32/crctest.c
new file mode 100644
index 0000000000..aed2391fd5
--- /dev/null
+++ b/src/lib/crypto/crc32/crctest.c
@@ -0,0 +1,86 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * CRC test driver program.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_crctest_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/crc-32.h>
+#include <stdio.h>
+
+void
+main()
+{
+ unsigned char ckout[4];
+ krb5_checksum outck;
+
+ char input[16], expected_crc[16];
+ unsigned char inbytes[4], outbytes[4];
+ int in_length;
+ unsigned int expect;
+
+ int bad = 0;
+
+ outck.contents = ckout;
+
+ while (scanf("%s %s", input, expected_crc) == 2) {
+ in_length = strlen(input);
+ if (in_length % 2) {
+ fprintf(stderr, "bad input '%s', not hex data\n", input);
+ exit(1);
+ }
+ in_length = in_length / 2;
+ if (strlen(expected_crc) != 8) {
+ fprintf(stderr, "bad expectation '%s', not 8 chars\n",
+ expected_crc);
+ exit(1);
+ }
+ if (sscanf(expected_crc, "%lx", &expect) != 1) {
+ fprintf(stderr, "bad expectation '%s', not 4bytes hex\n",
+ expected_crc);
+ exit(1);
+ }
+ outbytes[0] = expect & 0xff;
+ outbytes[1] = (expect >> 8) & 0xff;
+ outbytes[2] = (expect >> 16) & 0xff;
+ outbytes[3] = (expect >> 24) & 0xff;
+
+ if (sscanf(input, "%lx", &expect) != 1) {
+ fprintf(stderr, "bad expectation '%s', not hex\n",
+ expected_crc);
+ exit(1);
+ }
+ inbytes[0] = expect & 0xff;
+ inbytes[1] = (expect >> 8) & 0xff;
+ inbytes[2] = (expect >> 16) & 0xff;
+ inbytes[3] = (expect >> 24) & 0xff;
+
+ (*crc32_cksumtable_entry.sum_func)((krb5_pointer)inbytes,
+ in_length, 0, 0, &outck);
+ if (memcmp(outbytes, ckout, 4)) {
+ printf("mismatch: input '%s', output '%02x%02x%02x%02x', \
+expected '%s'\n",
+ input, ckout[3], ckout[2], ckout[1], ckout[0],
+ expected_crc);
+ bad = 1;
+ }
+ }
+ if (bad)
+ printf("crctest: failed to pass the test\n");
+ else
+ printf("crctest: test is passed successfully\n");
+
+ exit(bad);
+}