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.3 2003/10/04 20:36:46 hmp Exp $
24 #else /* Assume BSD Unix */
30 static void usage(void);
33 main(int argc
, char **argv
)
36 char passwd
[256] /* ,passwd2[256] */;
43 while((i
= getopt(argc
,argv
,"n:")) != -1){
50 /* could be in the form <number>/<seed> */
51 if(argc
<= optind
+ 1){
56 slash
= strchr(argv
[optind
], '/');
62 if((n
= atoi(argv
[optind
])) < 0){
63 warnx("%s not positive",argv
[optind
]);
69 if((n
= atoi(argv
[optind
])) < 0){
70 warnx("%s not positive",argv
[optind
]);
73 seed
= argv
[++optind
];
75 fprintf(stderr
,"Reminder - Do not use this program while logged in via telnet or rlogin.\n");
77 /* Get user's secret password */
79 fprintf(stderr
,"Enter secret password: ");
80 readpass(passwd
,sizeof(passwd
));
83 fprintf(stderr,"Again secret password: ");
84 readpass(passwd2,sizeof(passwd));
85 if(strcmp(passwd,passwd2) == 0) break;
86 fprintf(stderr, "Sorry no match\n");
91 /* Crunch seed and password into starting key */
92 if(keycrunch(key
,seed
,passwd
) != 0)
93 errx(1, "key crunch failed");
97 printf("%s\n",btoe(buf
,key
));
99 printf("%s\n",put8(buf
,key
));
102 for(i
=0;i
<=n
-cnt
;i
++)
106 printf("%d: %-29s %s\n",i
,btoe(buf
,key
),put8(buf
,key
));
108 printf("%d: %-29s\n",i
,btoe(buf
,key
));
119 fprintf(stderr
,"usage: key [-n count] <sequence #>[/] <key>\n");