[BACK]Return to x99token.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / x99token

Diff for /src/usr.bin/x99token/x99token.c between version 1.7 and 1.8

version 1.7, 2007/03/29 10:59:13 version 1.8, 2010/10/15 10:18:42
Line 18 
Line 18 
 #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;
Line 34 
Line 34 
 {  {
         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;
Line 147 
Line 147 
                 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);
Line 171 
Line 171 
 }  }
   
 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]);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8