* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard):
[glibc.git] / crypt / cert.c
blob34d7e4158c2a37224215ba3fc719c9d4371977e4
2 /*
3 * This crypt(3) validation program shipped with UFC-crypt
4 * is derived from one distributed with Phil Karns PD DES package.
6 * @(#)cert.c 1.8 11 Aug 1996
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "crypt.h"
13 int totfails = 0;
15 #if __STDC__ - 0
16 int main (int argc, char *argv[]);
17 void get8 (char *cp);
18 void put8 (char *cp);
19 void good_bye (void) __attribute__ ((noreturn));
20 #else
21 void get8(), put8();
22 #endif
24 void good_bye ()
26 if(totfails == 0) {
27 printf("Passed DES validation suite\n");
28 exit(0);
29 } else {
30 printf("%d failures during DES validation suite!!!\n", totfails);
31 exit(1);
35 int
36 main(argc, argv)
37 int argc;
38 char *argv[];
40 char key[64],plain[64],cipher[64],answer[64];
41 int i;
42 int test;
43 int fail;
45 for(test=0;!feof(stdin);test++){
47 get8(key);
48 printf(" K: "); put8(key);
49 setkey(key);
51 get8(plain);
52 printf(" P: "); put8(plain);
54 get8(answer);
55 printf(" C: "); put8(answer);
57 for(i=0;i<64;i++)
58 cipher[i] = plain[i];
59 encrypt(cipher, 0);
61 for(i=0;i<64;i++)
62 if(cipher[i] != answer[i])
63 break;
64 fail = 0;
65 if(i != 64){
66 printf(" Encrypt FAIL");
67 fail++; totfails++;
70 encrypt(cipher, 1);
72 for(i=0;i<64;i++)
73 if(cipher[i] != plain[i])
74 break;
75 if(i != 64){
76 printf(" Decrypt FAIL");
77 fail++; totfails++;
80 if(fail == 0)
81 printf(" OK");
82 printf("\n");
84 good_bye();
86 void
87 get8(cp)
88 char *cp;
90 int i,j,t;
92 for(i=0;i<8;i++){
93 scanf("%2x",&t);
94 if(feof(stdin))
95 good_bye();
96 for(j=0; j<8 ; j++) {
97 *cp++ = (t & (0x01 << (7-j))) != 0;
101 void
102 put8(cp)
103 char *cp;
105 int i,j,t;
107 for(i=0;i<8;i++){
108 t = 0;
109 for(j = 0; j<8; j++)
110 t = (t<<1) | *cp++;
111 printf("%02x", t);