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

Diff for /src/usr.bin/skey/skey.c between version 1.2 and 1.3

version 1.2, 1996/06/26 05:39:20 version 1.3, 1996/09/27 15:41:36
Line 21 
Line 21 
  *   *
  */   */
   
 #include <sys/cdefs.h>  
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <fcntl.h>  #include <err.h>
 #include <sgtty.h>  #include <unistd.h>
 #include "md4.h"  #include <skey.h>
 #include "skey.h"  
   
 void    usage __P((char *));  void    usage __P((char *));
   
Line 37 
Line 35 
         int     argc;          int     argc;
         char    *argv[];          char    *argv[];
 {  {
         int     n, cnt, i, pass = 0;          int     n, i, cnt = 1, pass = 0, hexmode = 0;
         char    passwd[256], key[8], buf[33], *seed, *slash;          char    passwd[256], key[8], buf[33], *seed, *slash;
         extern int optind;  
         extern char *optarg;  
   
         cnt = 1;          while ((i = getopt(argc, argv, "n:p:x45")) != EOF) {
   
         while ((i = getopt(argc, argv, "n:p:")) != EOF) {  
                 switch (i) {                  switch (i) {
                 case 'n':                  case 'n':
                         cnt = atoi(optarg);                          cnt = atoi(optarg);
Line 53 
Line 47 
                         strcpy(passwd, optarg);                          strcpy(passwd, optarg);
                         pass = 1;                          pass = 1;
                         break;                          break;
                   case 'x':
                           hexmode = 1;
                           break;
                   case '4':
                           skey_set_MDX(4);
                           break;
                   case '5':
                           skey_set_MDX(5);
                           break;
                 }                  }
         }          }
   
Line 69 
Line 72 
                 seed = slash;                  seed = slash;
   
                 if ((n = atoi(argv[optind])) < 0) {                  if ((n = atoi(argv[optind])) < 0) {
                         fprintf(stderr, "%s not positive\n", argv[optind]);                          warnx("%s not positive", argv[optind]);
                         usage(argv[0]);                          usage(argv[0]);
                 }                  }
         } else {          } else {
   
                 if ((n = atoi(argv[optind])) < 0) {                  if ((n = atoi(argv[optind])) < 0) {
                         fprintf(stderr, "%s not positive\n", argv[optind]);                          warnx("%s not positive", argv[optind]);
                         usage(argv[0]);                          usage(argv[0]);
                 }                  }
                 seed = argv[++optind];                  seed = argv[++optind];
Line 83 
Line 85 
   
         /* Get user's secret password */          /* Get user's secret password */
         if (!pass) {          if (!pass) {
                 fprintf(stderr, "Enter secret password: ");                  (void)fputs("Reminder - Do not use this program while logged in via telnet or rlogin.\n", stderr);
                   (void)fputs("Enter secret password: ", stderr);
                 readpass(passwd, sizeof(passwd));                  readpass(passwd, sizeof(passwd));
         }          }
         rip(passwd);          rip(passwd);
   
         /* Crunch seed and password into starting key */          /* Crunch seed and password into starting key */
         if (keycrunch(key, seed, passwd) != 0) {          if (keycrunch(key, seed, passwd) != 0)
                 fprintf(stderr, "%s: key crunch failed\n", argv[0]);                  errx(1, "key crunch failed");
                 exit(1);  
         }  
         if (cnt == 1) {          if (cnt == 1) {
                 while (n-- != 0)                  while (n-- != 0)
                         f(key);                          f(key);
                 printf("%s\n", btoe(buf, key));                  (void)puts(hexmode ? put8(buf, key) : btoe(buf, key));
 #ifdef  HEXIN  
                 printf("%s\n", put8(buf, key));  
 #endif  
         } else {          } else {
                 for (i = 0; i <= n - cnt; i++)                  for (i = 0; i <= n - cnt; i++)
                         f(key);                          f(key);
                 for (; i <= n; i++) {                  for (; i <= n; i++) {
 #ifdef  HEXIN                          if (hexmode)
                         printf("%d: %-29s  %s\n", i, btoe(buf, key), put8(buf, key));                                  (void)printf("%d: %-29s  %s\n", i,
 #else                                      btoe(buf, key), put8(buf, key));
                         printf("%d: %-29s\n", i, btoe(buf, key));                          else
 #endif                                  (void)printf("%d: %-29s\n", i, btoe(buf, key));
                         f(key);                          f(key);
                 }                  }
         }          }
Line 119 
Line 118 
 usage(s)  usage(s)
         char   *s;          char   *s;
 {  {
           (void)fprintf(stderr, "Usage: %s [-x] [-4|-5] [-n count] [-p password ] sequence# [/] key", s);
         fprintf(stderr,  
             "Usage: %s [-n count] [-p password ] sequence# [/] key\n", s);  
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3