version 1.7, 2007/03/29 10:59:13 |
version 1.8, 2010/10/15 10:18:42 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <des.h> |
#include <openssl/des.h> |
|
|
#define KEYFILE ".keyfile.des" |
#define KEYFILE ".keyfile.des" |
#define HEXDIGITS "0123456789abcdef" |
#define HEXDIGITS "0123456789abcdef" |
#define DECDIGITS "0123456789012345" |
#define DECDIGITS "0123456789012345" |
|
|
void predict(des_key_schedule, const char *, int); |
void predict(DES_key_schedule, const char *, int); |
|
|
char *digits = HEXDIGITS; |
char *digits = HEXDIGITS; |
extern char *__progname; |
extern char *__progname; |
|
|
{ |
{ |
int i; |
int i; |
char buf[256]; |
char buf[256]; |
des_key_schedule ks; |
DES_key_schedule ks; |
des_cblock key; |
DES_cblock key; |
char _keyfile[MAXPATHLEN]; |
char _keyfile[MAXPATHLEN]; |
char *keyfile = 0; |
char *keyfile = 0; |
FILE *fp; |
FILE *fp; |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
des_fixup_key_parity(&key); |
DES_fixup_key_parity(&key); |
des_key_sched(&key, ks); |
DES_key_sched(&key, &ks); |
|
|
buf[0] = '\0'; |
buf[0] = '\0'; |
readpassphrase("Enter challenge: ", buf, sizeof(buf), RPP_ECHO_ON); |
readpassphrase("Enter challenge: ", buf, sizeof(buf), RPP_ECHO_ON); |
|
|
} |
} |
|
|
void |
void |
predict(des_key_schedule ks, const char *chal, int cnt) |
predict(DES_key_schedule ks, const char *chal, int cnt) |
{ |
{ |
int i; |
int i; |
des_cblock cb; |
DES_cblock cb; |
|
|
memcpy(&cb, chal, sizeof(cb)); |
memcpy(&cb, chal, sizeof(cb)); |
while (cnt-- > 0) { |
while (cnt-- > 0) { |
printf("%.8s: ", (char *)cb); |
printf("%.8s: ", (char *)cb); |
des_ecb_encrypt(&cb, &cb, ks, DES_ENCRYPT); |
DES_ecb_encrypt(&cb, &cb, &ks, DES_ENCRYPT); |
for (i = 0; i < 4; ++i) { |
for (i = 0; i < 4; ++i) { |
printf("%c", digits[(cb[i]>>4) & 0xf]); |
printf("%c", digits[(cb[i]>>4) & 0xf]); |
printf("%c", digits[(cb[i]>>0) & 0xf]); |
printf("%c", digits[(cb[i]>>0) & 0xf]); |