summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-10 17:06:53 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-10 17:06:53 +0000
commit32db52eeb07fc0762873048cd4d39e3d4f159ea4 (patch)
treef91a3d36c3cfab86aa26d437f07c8d7765afcb29
parentf5e1a74a9482a71aa477bb8c267000abfacc24ca (diff)
predict() was broken for n > 1 in rev 1.2; this fixes it and closes PR 3306
-rw-r--r--usr.bin/x99token/x99token.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/x99token/x99token.c b/usr.bin/x99token/x99token.c
index 4f739b6bdb7..9bb4c840d4f 100644
--- a/usr.bin/x99token/x99token.c
+++ b/usr.bin/x99token/x99token.c
@@ -20,7 +20,7 @@
#define HEXDIGITS "0123456789abcdef"
#define DECDIGITS "0123456789012345"
-void predict(des_key_schedule, char *, int);
+void predict(des_key_schedule, const char *, int);
char *digits = HEXDIGITS;
extern char *__progname;
@@ -92,11 +92,10 @@ main(int argc, char **argv)
char *b = buf;
/* Assume octal input */
for (i = 0; i < 8; ++i) {
- if (!*b) {
+ if (!*b)
fprintf(stderr, "%s: invalid key\n", buf);
- }
while (isdigit(*b))
- key[i] = key[i] << 3 | *b++ - '0';
+ key[i] = key[i] << 3 | (*b++ - '0');
while (*b && !isdigit(*b))
++b;
}
@@ -167,14 +166,15 @@ main(int argc, char **argv)
}
void
-predict(des_key_schedule ks, char *chal, int cnt)
+predict(des_key_schedule ks, const char *chal, int cnt)
{
int i;
des_cblock cb;
+ memcpy(&cb, chal, sizeof(cb));
while (cnt-- > 0) {
- printf("%.8s: ", chal);
- des_ecb_encrypt((des_cblock *)chal, &cb, ks, DES_ENCRYPT);
+ printf("%.8s: ", (char *)cb);
+ des_ecb_encrypt(&cb, &cb, ks, DES_ENCRYPT);
for (i = 0; i < 4; ++i) {
printf("%c", digits[(cb[i]>>4) & 0xf]);
printf("%c", digits[(cb[i]>>0) & 0xf]);