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
12 * $FreeBSD: src/usr.bin/key/skey.c,v 1.6.6.1 2001/03/04 08:35:48 kris Exp $
13 * $DragonFly: src/usr.bin/key/skey.c,v 1.2 2003/06/17 04:29:27 dillon Exp $
24 #else /* Assume BSD Unix */
30 static void usage __P((void));
38 char passwd[256] /* ,passwd2[256] */;
45 while((i = getopt(argc,argv,"n:")) != -1){
52 /* could be in the form <number>/<seed> */
53 if(argc <= optind + 1){
58 slash = strchr(argv[optind], '/');
64 if((n = atoi(argv[optind])) < 0){
65 warnx("%s not positive",argv[optind]);
71 if((n = atoi(argv[optind])) < 0){
72 warnx("%s not positive",argv[optind]);
75 seed = argv[++optind];
77 fprintf(stderr,"Reminder - Do not use this program while logged in via telnet or rlogin.\n");
79 /* Get user's secret password */
81 fprintf(stderr,"Enter secret password: ");
82 readpass(passwd,sizeof(passwd));
85 fprintf(stderr,"Again secret password: ");
86 readpass(passwd2,sizeof(passwd));
87 if(strcmp(passwd,passwd2) == 0) break;
88 fprintf(stderr, "Sorry no match\n");
93 /* Crunch seed and password into starting key */
94 if(keycrunch(key,seed,passwd) != 0)
95 errx(1, "key crunch failed");
99 printf("%s\n",btoe(buf,key));
101 printf("%s\n",put8(buf,key));
104 for(i=0;i<=n-cnt;i++)
108 printf("%d: %-29s %s\n",i,btoe(buf,key),put8(buf,key));
110 printf("%d: %-29s\n",i,btoe(buf,key));
121 fprintf(stderr,"usage: key [-n count] <sequence #>[/] <key>\n");