summaryrefslogtreecommitdiff
path: root/crypt/cert.c
diff options
context:
space:
mode:
authorGeoff Keating <geoffk@cygnus.com>2000-02-29 05:21:42 +0000
committerGeoff Keating <geoffk@cygnus.com>2000-02-29 05:21:42 +0000
commit63f791d30309ea038012a135de693721f57edd0f (patch)
tree6c3caf17500aaf82d4d4b61dae45a6cd4918592b /crypt/cert.c
parent178f833f307e19a72a14be5c7b2e4b964169e1dd (diff)
* Makeconfig (all-subdirs): Add 'crypt' subdirectory. * sysdeps/unix/sysv/linux/configure.in (inhibit_glue): Don't complain if there is no crypt add-on. * crypt/configure: Removed.
* crypt/crypt.texi: Update documentation of US export restrictions to match the 14 Jan 2000 regulations. 2000-02-28 Geoff Keating <geoffk@cygnus.com> * Makeconfig (all-subdirs): Add 'crypt' subdirectory. * sysdeps/unix/sysv/linux/configure.in (inhibit_glue): Don't complain if there is no crypt add-on. * crypt/configure: Removed. * crypt/crypt.texi: Update documentation of US export restrictions to match the 14 Jan 2000 regulations. 2000-02-28 Geoff Keating <geoffk@cygnus.com> * crypt: New subdirectory, merged in from the crypt add-on.
Diffstat (limited to 'crypt/cert.c')
-rw-r--r--crypt/cert.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/crypt/cert.c b/crypt/cert.c
new file mode 100644
index 0000000000..49896be1d9
--- /dev/null
+++ b/crypt/cert.c
@@ -0,0 +1,112 @@
+
+/*
+ * This crypt(3) validation program shipped with UFC-crypt
+ * is derived from one distributed with Phil Karns PD DES package.
+ *
+ * @(#)cert.c 1.8 11 Aug 1996
+ */
+
+#include <stdio.h>
+#include "crypt.h"
+
+int totfails = 0;
+
+#if __STDC__ - 0
+int main (int argc, char *argv[]);
+void get8 (char *cp);
+void put8 (char *cp);
+void good_bye (void) __attribute__ ((noreturn));
+#else
+void get8(), put8();
+#endif
+
+void good_bye ()
+{
+ if(totfails == 0) {
+ printf("Passed DES validation suite\n");
+ exit(0);
+ } else {
+ printf("%d failures during DES validation suite!!!\n", totfails);
+ exit(1);
+ }
+}
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char key[64],plain[64],cipher[64],answer[64];
+ int i;
+ int test;
+ int fail;
+
+ for(test=0;!feof(stdin);test++){
+
+ get8(key);
+ printf(" K: "); put8(key);
+ setkey(key);
+
+ get8(plain);
+ printf(" P: "); put8(plain);
+
+ get8(answer);
+ printf(" C: "); put8(answer);
+
+ for(i=0;i<64;i++)
+ cipher[i] = plain[i];
+ encrypt(cipher, 0);
+
+ for(i=0;i<64;i++)
+ if(cipher[i] != answer[i])
+ break;
+ fail = 0;
+ if(i != 64){
+ printf(" Encrypt FAIL");
+ fail++; totfails++;
+ }
+
+ encrypt(cipher, 1);
+
+ for(i=0;i<64;i++)
+ if(cipher[i] != plain[i])
+ break;
+ if(i != 64){
+ printf(" Decrypt FAIL");
+ fail++; totfails++;
+ }
+
+ if(fail == 0)
+ printf(" OK");
+ printf("\n");
+ }
+ good_bye();
+}
+void
+get8(cp)
+char *cp;
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ scanf("%2x",&t);
+ if(feof(stdin))
+ good_bye();
+ for(j=0; j<8 ; j++) {
+ *cp++ = (t & (0x01 << (7-j))) != 0;
+ }
+ }
+}
+void
+put8(cp)
+char *cp;
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ t = 0;
+ for(j = 0; j<8; j++)
+ t = (t<<1) | *cp++;
+ printf("%02x", t);
+ }
+}