diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-09-29 21:28:39 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-09-29 21:28:39 +0000 |
commit | 577529f00cd4045a493a0fdd1c53458d9f47e5ab (patch) | |
tree | e779a07174cdadf00f47d3cef6d5d4e3f35d8e84 /usr.bin | |
parent | bb9ee0bcdd99d1c4c105b4f7c7680a8035934681 (diff) |
Towards RFC 1938 compliance. Works with new libskey and supports SHA.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/skey/Makefile | 9 | ||||
-rw-r--r-- | usr.bin/skey/skey.c | 81 |
2 files changed, 49 insertions, 41 deletions
diff --git a/usr.bin/skey/Makefile b/usr.bin/skey/Makefile index 3c0549c4634..eec4851173c 100644 --- a/usr.bin/skey/Makefile +++ b/usr.bin/skey/Makefile @@ -1,7 +1,10 @@ -# $OpenBSD: Makefile,v 1.4 1996/09/28 00:00:40 millert Exp $ +# $OpenBSD: Makefile,v 1.5 1996/09/29 21:28:37 millert Exp $ -PROG= skey -MAN= skey.1 skeyinfo.1 skeyaudit.1 skeyprune.8 +PROG= skey +MAN= skey.1 skeyinfo.1 skeyaudit.1 skeyprune.8 +LINKS= /usr/bin/skey /usr/bin/otp-md5 \ + /usr/bin/skey /usr/bin/otp-md4 \ + /usr/bin/skey /usr/bin/otp-sha1 DPADD= ${LIBSKEY} LDADD= -lskey diff --git a/usr.bin/skey/skey.c b/usr.bin/skey/skey.c index 81752f84938..312a4dc650d 100644 --- a/usr.bin/skey/skey.c +++ b/usr.bin/skey/skey.c @@ -1,4 +1,4 @@ -/* * $OpenBSD: skey.c,v 1.4 1996/09/29 04:33:58 millert Exp $*/ +/* * $OpenBSD: skey.c,v 1.5 1996/09/29 21:28:38 millert Exp $*/ /* * S/KEY v1.1b (skey.c) * @@ -38,59 +38,64 @@ main(argc, argv) int n, i, cnt = 1, pass = 0, hexmode = 0; char passwd[256], key[8], buf[33], *seed, *slash; - while ((i = getopt(argc, argv, "n:p:x45")) != EOF) { - switch (i) { - case 'n': - cnt = atoi(optarg); - break; - case 'p': - strcpy(passwd, optarg); - pass = 1; - break; - case 'x': - hexmode = 1; - break; - case '4': - skey_set_MDX(4); - break; - case '5': - skey_set_MDX(5); - break; - } + /* If we were called as otp-METHOD, set algorithm based on that */ + if (strncmp(argv[0], "otp-", 4) == 0) { + if (skey_set_algorithm(&argv[0][4]) == NULL) + errx(1, "Unknown hash algorithm %s", &argv[0][4]); } - /* check for md4/md5 argument */ - if (argv[optind]) { - if (strcmp(argv[optind], "MD4") == 0) { - skey_set_MDX(4); - optind++; - } else if (strcmp(argv[optind], "MD5") == 0) { - skey_set_MDX(5); - optind++; + for (i = 1; i < argc && argv[i][0] == '-' && strcmp(argv[i], "--");) { + if (argv[i][2] == '\0') { + /* Single character switch */ + switch (argv[i][1]) { + case 'n': + if (i + 1 == argc) + usage(argv[0]); + cnt = atoi(argv[++i]); + break; + case 'p': + if (i + 1 == argc) + usage(argv[0]); + (void)strcpy(passwd, argv[++i]); + pass = 1; + break; + case 'x': + hexmode = 1; + break; + default: + usage(argv[0]); + } + } else { + /* Multi character switches are hash types */ + if (skey_set_algorithm(&argv[i][1]) == NULL) { + warnx("Unknown hash algorithm %s", &argv[i][1]); + usage(argv[0]); + } } + i++; } - /* could be in the form <number>/<seed> */ - if (argc <= optind + 1) { + /* Could be in the form <number>/<seed> */ + if (argc <= i + 1) { /* look for / in it */ - if (argc <= optind) + if (argc <= i) usage(argv[0]); - slash = strchr(argv[optind], '/'); + slash = strchr(argv[i], '/'); if (slash == NULL) usage(argv[0]); *slash++ = '\0'; seed = slash; - if ((n = atoi(argv[optind])) < 0) { - warnx("%s not positive", argv[optind]); + if ((n = atoi(argv[i])) < 0) { + warnx("%s not positive", argv[i]); usage(argv[0]); } } else { - if ((n = atoi(argv[optind])) < 0) { - warnx("%s not positive", argv[optind]); + if ((n = atoi(argv[i])) < 0) { + warnx("%s not positive", argv[i]); usage(argv[0]); } - seed = argv[++optind]; + seed = argv[++i]; } /* Get user's secret password */ @@ -128,6 +133,6 @@ void usage(s) char *s; { - (void)fprintf(stderr, "Usage: %s [-x] [-4|-5] [-n count] [-p password] [MD4|MD5] sequence# [/] key", s); + (void)fprintf(stderr, "Usage: %s [-x] [-md4|-md5|-sha1] [-n count] [-p password] <sequence#>[/] key\n", s); exit(1); } |