1 /* Stand-alone program for computing responses to S/Key challenges.
2 * Takes the iteration count and seed as command line args, prompts
3 * for the user's key, and produces both word and hex format responses.
8 * OMEN US HORN OMIT BACK AHOY
14 static const char rcsid[] =
15 "$FreeBSD: src/usr.bin/key/skey.c,v 1.6.6.1 2001/03/04 08:35:48 kris Exp $";
26 #else /* Assume BSD Unix */
32 static void usage __P((void));
40 char passwd[256] /* ,passwd2[256] */;
47 while((i = getopt(argc,argv,"n:")) != -1){
54 /* could be in the form <number>/<seed> */
55 if(argc <= optind + 1){
60 slash = strchr(argv[optind], '/');
66 if((n = atoi(argv[optind])) < 0){
67 warnx("%s not positive",argv[optind]);
73 if((n = atoi(argv[optind])) < 0){
74 warnx("%s not positive",argv[optind]);
77 seed = argv[++optind];
79 fprintf(stderr,"Reminder - Do not use this program while logged in via telnet or rlogin.\n");
81 /* Get user's secret password */
83 fprintf(stderr,"Enter secret password: ");
84 readpass(passwd,sizeof(passwd));
87 fprintf(stderr,"Again secret password: ");
88 readpass(passwd2,sizeof(passwd));
89 if(strcmp(passwd,passwd2) == 0) break;
90 fprintf(stderr, "Sorry no match\n");
95 /* Crunch seed and password into starting key */
96 if(keycrunch(key,seed,passwd) != 0)
97 errx(1, "key crunch failed");
101 printf("%s\n",btoe(buf,key));
103 printf("%s\n",put8(buf,key));
106 for(i=0;i<=n-cnt;i++)
110 printf("%d: %-29s %s\n",i,btoe(buf,key),put8(buf,key));
112 printf("%d: %-29s\n",i,btoe(buf,key));
123 fprintf(stderr,"usage: key [-n count] <sequence #>[/] <key>\n");