summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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]);