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
13 /* This file tests the deprecated setkey/encrypt interface. */
14 #include <shlib-compat.h>
15 #if TEST_COMPAT (libcrypt, GLIBC_2_0, GLIBC_2_28)
17 #define libcrypt_version_reference(symbol, version) \
18 _libcrypt_version_reference (symbol, VERSION_libcrypt_##version)
19 #define _libcrypt_version_reference(symbol, version) \
20 __libcrypt_version_reference (symbol, version)
21 #define __libcrypt_version_reference(symbol, version) \
22 __asm__ (".symver " #symbol ", " #symbol "@" #version)
24 extern void setkey (const char *);
25 extern void encrypt (const char *, int);
26 libcrypt_version_reference (setkey
, GLIBC_2_0
);
27 libcrypt_version_reference (encrypt
, GLIBC_2_0
);
31 int main (int argc
, char *argv
[]);
34 void good_bye (void) __attribute__ ((noreturn
));
40 printf("Passed DES validation suite\n");
43 printf("%d failures during DES validation suite!!!\n", totfails
);
49 main (int argc
, char *argv
[])
51 char key
[64],plain
[64],cipher
[64],answer
[64];
56 for(test
=0;!feof(stdin
);test
++){
59 printf(" K: "); put8(key
);
63 printf(" P: "); put8(plain
);
66 printf(" C: "); put8(answer
);
73 if(cipher
[i
] != answer
[i
])
77 printf(" Encrypt FAIL");
84 if(cipher
[i
] != plain
[i
])
87 printf(" Decrypt FAIL");
106 for(j
=0; j
<8 ; j
++) {
107 *cp
++ = (t
& (0x01 << (7-j
))) != 0;
124 #else /* encrypt and setkey are not available. */
129 return 77; /* UNSUPPORTED */