5 * Verify signatures on distribuitions of files
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Header files ------------------------------------------------------*/
32 #define _FILE_OFFSET_BITS 64
42 #include <mLib/alloc.h>
43 #include <mLib/base64.h>
44 #include <mLib/mdwopt.h>
45 #include <mLib/quis.h>
46 #include <mLib/report.h>
57 /*----- Data formatting ---------------------------------------------------*/
59 /* --- Binary data structure --- *
61 * The binary format, which is used for hashing and for the optional binary
62 * output, consists of a sequence of tagged blocks. The tag describes the
63 * format and meaining of the following data.
67 /* --- Block tags --- */
69 T_IDENT
= 0, /* An identifying marker */
70 T_KEYID
, /* Key identifier */
71 T_BEGIN
, /* Begin hashing here */
72 T_COMMENT
= T_BEGIN
, /* A textual comment */
73 T_DATE
, /* Creation date of signature */
74 T_EXPIRE
, /* Expiry date of signature */
75 T_FILE
, /* File and corresponding hash */
76 T_SIGNATURE
, /* Final signature block */
78 /* --- Error messages --- */
86 /* --- Name translation table --- */
88 static const char *tagtab
[] = {
90 "comment:", "date:", "expires:", "file:",
95 static const char *errtab
[] = {
97 "Unexpected end-of-file",
98 "Binary object too large",
103 /* --- Memory representation of block types --- */
105 typedef struct block
{
106 int tag
; /* Type tag */
107 dstr d
; /* String data */
108 dstr b
; /* Binary data */
109 time_t t
; /* Timestamp */
110 uint32 k
; /* Keyid */
113 /* --- @getstring@ --- *
115 * Arguments: @FILE *fp@ = stream from which to read
116 * @dstr *d@ = destination string
117 * @unsigned raw@ = raw or cooked read
119 * Returns: Zero if OK, nonzero on end-of-file.
121 * Use: Reads a filename (or something similar) from a stream.
124 static int getstring(FILE *fp
, dstr
*d
, unsigned raw
)
129 /* --- Raw: just read exactly what's written up to a null byte --- */
132 if ((ch
= getc(fp
)) == EOF
)
138 if ((ch
= getc(fp
)) == EOF
)
145 /* --- Skip as far as whitespace --- *
147 * Also skip past comments.
155 do ch
= getc(fp
); while (ch
!= '\n' && ch
!= EOF
);
161 /* --- If the character is a quote then read a quoted string --- */
173 /* --- Now read all sorts of interesting things --- */
177 /* --- Handle an escaped thing --- */
184 case 'a': ch
= '\a'; break;
185 case 'b': ch
= '\b'; break;
186 case 'f': ch
= '\f'; break;
187 case 'n': ch
= '\n'; break;
188 case 'r': ch
= '\r'; break;
189 case 't': ch
= '\t'; break;
190 case 'v': ch
= '\v'; break;
197 /* --- If it's a quote or some other end marker then stop --- */
199 if (ch
== q
|| (!q
&& isspace((unsigned char)ch
)))
202 /* --- Otherwise contribute and continue --- */
205 if ((ch
= getc(fp
)) == EOF
)
215 /* --- @putstring@ --- *
217 * Arguments: @FILE *fp@ = stream to write on
218 * @const char *p@ = pointer to text
219 * @unsigned raw@ = whether the string is to be written raw
223 * Use: Emits a string to a stream.
226 static void putstring(FILE *fp
, const char *p
, unsigned raw
)
228 size_t sz
= strlen(p
);
232 /* --- Just write the string null terminated if raw --- */
235 fwrite(p
, 1, sz
+ 1, fp
);
239 /* --- Check for any dodgy characters --- */
242 for (q
= p
; *q
; q
++) {
243 if (isspace((unsigned char)*q
)) {
252 /* --- Emit the string --- */
254 for (q
= p
; *q
; q
++) {
256 case '\a': fputc('\\', fp
); fputc('a', fp
); break;
257 case '\b': fputc('\\', fp
); fputc('b', fp
); break;
258 case '\f': fputc('\\', fp
); fputc('f', fp
); break;
259 case '\n': fputc('\\', fp
); fputc('n', fp
); break;
260 case '\r': fputc('\\', fp
); fputc('r', fp
); break;
261 case '\t': fputc('\\', fp
); fputc('t', fp
); break;
262 case '\v': fputc('\\', fp
); fputc('v', fp
); break;
263 case '`': fputc('\\', fp
); fputc('`', fp
); break;
264 case '\'': fputc('\\', fp
); fputc('\'', fp
); break;
265 case '\"': fputc('\\', fp
); fputc('\"', fp
); break;
278 /* --- @timestring@ --- *
280 * Arguments: @time_t t@ = a timestamp
281 * @dstr *d@ = a string to write on
285 * Use: Writes a textual representation of the timestamp to the
289 static void timestring(time_t t
, dstr
*d
)
291 if (t
== KEXP_FOREVER
)
294 struct tm
*tm
= localtime(&t
);
296 d
->len
+= strftime(d
->buf
+ d
->len
, 32, "%Y-%m-%d %H:%M:%S %Z", tm
);
301 /* --- @breset@ --- *
303 * Arguments: @block *b@ = block to reset
307 * Use: Resets a block so that more stuff can be put in it.
310 static void breset(block
*b
)
321 * Arguments: @block *b@ = block to initialize
325 * Use: Initializes a block as something to read into.
328 static void binit(block
*b
)
335 /* --- @bdestroy@ --- *
337 * Arguments: @block *b@ = block to destroy
341 * Use: Destroys a block's contents.
344 static void bdestroy(block
*b
)
352 * Arguments: @block *b@ = pointer to block
353 * @FILE *fp@ = stream to read from
354 * @unsigned bin@ = binary switch
356 * Returns: Tag of block, or an error tag.
358 * Use: Reads a block from a stream.
361 static int bget(block
*b
, FILE *fp
, unsigned bin
)
365 /* --- Read the tag --- */
371 if (getstring(fp
, &d
, 0))
373 for (tag
= 0; tagtab
[tag
]; tag
++) {
374 if (strcmp(tagtab
[tag
], d
.buf
) == 0)
381 /* --- Decide what to do next --- */
387 /* --- Reading of strings --- */
391 if (getstring(fp
, &b
->d
, bin
))
395 /* --- Timestamps --- */
401 if (fread(buf
, sizeof(buf
), 1, fp
) < 1)
403 b
->t
= ((time_t)(((LOAD32(buf
+ 0) << 16) << 16) & ~MASK32
) |
404 (time_t)LOAD32(buf
+ 4));
406 if (getstring(fp
, &b
->d
, 0))
408 if (strcmp(b
->d
.buf
, "forever") == 0)
410 else if ((b
->t
= get_date(b
->d
.buf
, 0)) == -1)
415 /* --- Key ids --- */
420 if (fread(buf
, sizeof(buf
), 1, fp
) < 1)
424 if (getstring(fp
, &b
->d
, 0))
426 b
->k
= strtoul(b
->d
.buf
, 0, 16);
430 /* --- Reading of binary data --- */
437 if (fread(buf
, sizeof(buf
), 1, fp
) < 1)
443 if (fread(b
->b
.buf
+ b
->b
.len
, 1, sz
, fp
) < sz
)
448 if (getstring(fp
, &b
->d
, 0))
451 base64_decode(&b64
, b
->d
.buf
, b
->d
.len
, &b
->b
);
452 base64_decode(&b64
, 0, 0, &b
->b
);
455 if (tag
== T_FILE
&& getstring(fp
, &b
->d
, bin
))
459 /* --- Anything else --- */
470 * Arguments: @block *b@ = pointer to block to emit
471 * @dstr *d@ = output buffer
475 * Use: Encodes a block in a binary format.
478 static void blob(block
*b
, dstr
*d
)
490 if (b
->t
== KEXP_FOREVER
) {
491 STORE32(d
->buf
+ d
->len
, 0xffffffff);
492 STORE32(d
->buf
+ d
->len
+ 4, 0xffffffff);
494 STORE32(d
->buf
+ d
->len
, ((b
->t
& ~MASK32
) >> 16) >> 16);
495 STORE32(d
->buf
+ d
->len
+ 4, b
->t
);
501 STORE32(d
->buf
+ d
->len
, b
->k
);
507 STORE16(d
->buf
+ d
->len
, b
->b
.len
);
510 if (b
->tag
== T_FILE
) {
518 /* --- @bwrite@ --- *
520 * Arguments: @block *b@ = pointer to block to write
521 * @FILE *fp@ = stream to write on
525 * Use: Writes a block on a stream in a textual format.
528 static void bwrite(block
*b
, FILE *fp
)
530 fputs(tagtab
[b
->tag
], fp
);
535 putstring(fp
, b
->d
.buf
, 0);
540 timestring(b
->t
, &d
);
541 putstring(fp
, d
.buf
, 0);
545 fprintf(fp
, "%08lx", (unsigned long)b
->k
);
553 base64_encode(&b64
, b
->b
.buf
, b
->b
.len
, &d
);
554 base64_encode(&b64
, 0, 0, &d
);
556 if (b
->tag
== T_FILE
) {
558 putstring(fp
, b
->d
.buf
, 0);
567 * Arguments: @block *b@ = pointer to block to write
568 * @FILE *fp@ = file to write on
569 * @ghash *h@ = pointer to hash function
570 * @unsigned bin@ = binary/text flag
574 * Use: Spits out a block properly.
577 static void bemit(block
*b
, FILE *fp
, ghash
*h
, unsigned bin
)
579 if (h
|| (fp
&& bin
)) {
583 GH_HASH(h
, d
.buf
, d
.len
);
585 fwrite(d
.buf
, d
.len
, 1, fp
);
591 /*----- Static variables --------------------------------------------------*/
593 static const char *keyring
= "keyring";
595 /*----- Other shared functions --------------------------------------------*/
599 * Arguments: @const gchash *c@ = pointer to hash class
600 * @unsigned f@ = flags
601 * @const char *file@ = file to hash
602 * @void *b@ = pointer to output buffer
604 * Returns: Zero if it worked, or nonzero for a system error.
606 * Use: Hashes a file.
609 #define FHF_PROGRESS 256u
611 static int fhash(const gchash
*c
, unsigned f
, const char *file
, void *b
)
613 FILE *fp
= fopen(file
, "rb");
615 ghash
*h
= GH_INIT(c
);
622 if (f
& FHF_PROGRESS
) {
623 if (fprogress_init(&ff
, file
, fp
)) return (-1);
625 while ((sz
= fread(buf
, 1, sizeof(buf
), fp
)) > 0) {
627 if (f
& FHF_PROGRESS
) fprogress_update(&ff
, sz
);
631 if (f
& FHF_PROGRESS
) fprogress_done(&ff
);
640 * Arguments: @FILE *fp@ = file to write on
641 * @const void *p@ = pointer to data to be written
642 * @size_t sz@ = size of the data to write
646 * Use: Emits a hex dump to a stream.
649 static void fhex(FILE *fp
, const void *p
, size_t sz
)
655 fprintf(fp
, "%02x", *q
++);
662 /*----- Signature generation ----------------------------------------------*/
664 static int sign(int argc
, char *argv
[])
672 const char *ki
= "dsig";
676 time_t exp
= KEXP_EXPIRE
;
678 const char *ifile
= 0;
679 const char *ofile
= 0;
688 static struct option opts
[] = {
689 { "null", 0, 0, '0' },
690 { "binary", 0, 0, 'b' },
691 { "verbose", 0, 0, 'v' },
692 { "progress", 0, 0, 'p' },
693 { "quiet", 0, 0, 'q' },
694 { "comment", OPTF_ARGREQ
, 0, 'c' },
695 { "file", OPTF_ARGREQ
, 0, 'f' },
696 { "output", OPTF_ARGREQ
, 0, 'o' },
697 { "key", OPTF_ARGREQ
, 0, 'k' },
698 { "expire", OPTF_ARGREQ
, 0, 'e' },
699 { "nocheck", OPTF_ARGREQ
, 0, 'C' },
702 int i
= mdwopt(argc
, argv
, "+0vpqbC" "c:" "f:o:" "k:e:", opts
, 0, 0, 0);
738 if (strcmp(optarg
, "forever") == 0)
740 else if ((exp
= get_date(optarg
, 0)) == -1)
741 die(EXIT_FAILURE
, "bad expiry time");
748 if (optind
!= argc
|| (f
& f_bogus
))
749 die(EXIT_FAILURE
, "Usage: sign [-OPTIONS]");
751 /* --- Locate the signing key --- */
753 if (key_open(&kf
, keyring
, KOPEN_WRITE
, key_moan
, 0))
754 die(EXIT_FAILURE
, "couldn't open keyring `%s'", keyring
);
755 if ((k
= key_bytag(&kf
, ki
)) == 0)
756 die(EXIT_FAILURE
, "couldn't find key `%s'", ki
);
758 if (exp
== KEXP_FOREVER
&& k
->exp
!= KEXP_FOREVER
) {
759 die(EXIT_FAILURE
, "key `%s' expires: can't create nonexpiring signature",
762 s
= getsig(k
, "dsig", 1);
764 /* --- Check the key --- */
766 if (!(f
& f_nocheck
) && (err
= s
->ops
->check(s
)) != 0)
767 moan("key `%s' fails check: %s", d
.buf
, err
);
769 /* --- Open files --- */
771 if (!ifile
|| strcmp(ifile
, "-") == 0)
773 else if ((ifp
= fopen(ifile
, (f
& f_raw
) ?
"rb" : "r")) == 0) {
774 die(EXIT_FAILURE
, "couldn't open input file `%s': %s",
775 ifile
, strerror(errno
));
778 if (!ofile
|| strcmp(ofile
, "-") == 0)
780 else if ((ofp
= fopen(ofile
, (f
& f_bin
) ?
"wb" : "w")) == 0) {
781 die(EXIT_FAILURE
, "couldn't open output file `%s': %s",
782 ofile
, strerror(errno
));
785 /* --- Emit the start of the output --- */
787 binit(&b
); b
.tag
= T_IDENT
;
788 dstr_putf(&b
.d
, "%s, Catacomb version " VERSION
, QUIS
);
789 bemit(&b
, ofp
, 0, f
& f_bin
);
791 breset(&b
); b
.tag
= T_KEYID
; b
.k
= k
->id
;
792 bemit(&b
, ofp
, 0, f
& f_bin
);
794 /* --- Start hashing, and emit the datestamps and things --- */
797 time_t now
= time(0);
799 breset(&b
); b
.tag
= T_DATE
; b
.t
= now
; bemit(&b
, ofp
, s
->h
, f
& f_bin
);
800 if (exp
== KEXP_EXPIRE
)
801 exp
= now
+ 86400 * 28;
802 breset(&b
); b
.tag
= T_EXPIRE
; b
.t
= exp
; bemit(&b
, ofp
, s
->h
, f
& f_bin
);
804 breset(&b
); b
.tag
= T_COMMENT
; DPUTS(&b
.d
, c
);
805 bemit(&b
, ofp
, s
->h
, f
& f_bin
);
812 /* --- Now hash the various files --- */
816 /* --- Stop on an output error --- */
823 /* --- Read the next filename to hash --- */
826 if (getstring(ifp
, &b
.d
, f
& f_raw
))
829 DENSURE(&b
.b
, GH_CLASS(s
->h
)->hashsz
);
830 if (fhash(GH_CLASS(s
->h
), f
, b
.d
.buf
, b
.b
.buf
)) {
831 moan("Error reading `%s': %s", b
.d
.buf
, strerror(errno
));
834 b
.b
.len
+= GH_CLASS(s
->h
)->hashsz
;
836 fhex(stderr
, b
.b
.buf
, b
.b
.len
);
837 fprintf(stderr
, " %s\n", b
.d
.buf
);
839 bemit(&b
, ofp
, s
->h
, f
& f_bin
);
843 /* --- Create the signature --- */
845 if (!(f
& f_bogus
)) {
848 if ((e
= s
->ops
->doit(s
, &b
.b
)) != 0) {
849 moan("error creating signature: %s", key_strerror(e
));
852 if (!(f
& f_bogus
)) {
853 bemit(&b
, ofp
, 0, f
& f_bin
);
854 key_used(&kf
, k
, exp
);
858 /* --- Tidy up at the end --- */
871 if ((e
= key_close(&kf
)) != 0) {
874 die(EXIT_FAILURE
, "couldn't write file `%s': %s",
875 keyring
, strerror(errno
));
877 die(EXIT_FAILURE
, "keyring file `%s' broken: %s (repair manually)",
878 keyring
, strerror(errno
));
882 die(EXIT_FAILURE
, "error(s) occurred while creating signature");
883 return (EXIT_SUCCESS
);
891 /*----- Signature verification --------------------------------------------*/
893 static int verify(int argc
, char *argv
[])
911 /* --- Parse the options --- */
914 static struct option opts
[] = {
915 { "verbose", 0, 0, 'v' },
916 { "progress", 0, 0, 'p' },
917 { "quiet", 0, 0, 'q' },
918 { "nocheck", 0, 0, 'C' },
921 int i
= mdwopt(argc
, argv
, "+vpqC", opts
, 0, 0, 0);
945 if ((f
& f_bogus
) || argc
> 1)
946 die(EXIT_FAILURE
, "Usage: verify [-qvC] [FILE]");
948 /* --- Open the key file, and start reading the input file --- */
950 if (key_open(&kf
, keyring
, KOPEN_READ
, key_moan
, 0))
951 die(EXIT_FAILURE
, "couldn't open keyring `%s'\n", keyring
);
955 if ((fp
= fopen(argv
[0], "rb")) == 0) {
956 die(EXIT_FAILURE
, "couldn't open file `%s': %s\n",
957 argv
[0], strerror(errno
));
964 if ((fp
= fopen(argv
[0], "r")) == 0) {
965 die(EXIT_FAILURE
, "couldn't open file `%s': %s\n",
966 argv
[0], strerror(errno
));
971 /* --- Read the introductory matter --- */
976 e
= bget(&b
, fp
, f
& f_bin
);
978 die(EXIT_FAILURE
, "error reading packet: %s", errtab
[-e
]);
984 printf("INFO ident: `%s'\n", b
.d
.buf
);
987 if ((k
= key_byid(&kf
, b
.k
)) == 0) {
989 printf("FAIL key %08lx not found\n", (unsigned long)b
.k
);
994 key_fulltag(k
, &b
.d
);
995 printf("INFO key: %s\n", b
.d
.buf
);
999 die(EXIT_FAILURE
, "(internal) unknown packet type\n");
1004 /* --- Initialize the hash function and start reading hashed packets --- */
1008 puts("FAIL no keyid packet found");
1012 s
= getsig(k
, "dsig", 0);
1013 if (!(f
& f_nocheck
) && verb
&& (err
= s
->ops
->check(s
)) != 0)
1014 printf("WARN public key fails check: %s", err
);
1020 printf("INFO comment: `%s'\n", b
.d
.buf
);
1021 bemit(&b
, 0, s
->h
, 0);
1026 timestring(b
.t
, &b
.d
);
1027 printf("INFO date: %s\n", b
.d
.buf
);
1029 bemit(&b
, 0, s
->h
, 0);
1032 time_t now
= time(0);
1033 if (b
.t
!= KEXP_FOREVER
&& b
.t
< now
) {
1035 puts("BAD signature has expired");
1040 timestring(b
.t
, &b
.d
);
1041 printf("INFO expires: %s\n", b
.d
.buf
);
1043 bemit(&b
, 0, s
->h
, 0);
1047 DENSURE(&d
, GH_CLASS(s
->h
)->hashsz
);
1048 if (fhash(GH_CLASS(s
->h
), f
, b
.d
.buf
, d
.buf
)) {
1050 printf("BAD error reading file `%s': %s\n",
1051 b
.d
.buf
, strerror(errno
));
1054 } else if (b
.b
.len
!= GH_CLASS(s
->h
)->hashsz
||
1055 memcmp(d
.buf
, b
.b
.buf
, b
.b
.len
) != 0) {
1057 printf("BAD file `%s' has incorrect hash\n", b
.d
.buf
);
1059 } else if (verb
> 3) {
1060 fputs("INFO hash: ", stdout
);
1061 fhex(stdout
, b
.b
.buf
, b
.b
.len
);
1062 printf(" %s\n", b
.d
.buf
);
1064 bemit(&b
, 0, s
->h
, 0);
1067 if (s
->ops
->doit(s
, &b
.b
)) {
1069 puts("BAD bad signature");
1071 } else if (verb
> 2)
1072 puts("INFO good signature");
1076 printf("FAIL invalid packet type %i\n", e
);
1081 e
= bget(&b
, fp
, f
& f_bin
);
1084 printf("FAIL error reading packet: %s\n", errtab
[-e
]);
1097 puts("FAIL signature invalid");
1099 puts("OK signature verified");
1101 return (f
& f_bogus ? EXIT_FAILURE
: EXIT_SUCCESS
);
1109 /*----- Main code ---------------------------------------------------------*/
1113 listtab[i].name, listtab[i].name) \
1114 LI("Signature schemes", sig, \
1115 sigtab[i].name, sigtab[i].name) \
1116 LI("Hash functions", hash, \
1117 ghashtab[i], ghashtab[i]->name)
1119 MAKELISTTAB(listtab
, LISTS
)
1121 int cmd_show(int argc
, char *argv
[])
1123 return (displaylists(listtab
, argv
+ 1));
1126 static int cmd_help(int, char **);
1128 static cmd cmdtab
[] = {
1129 { "help", cmd_help
, "help [COMMAND...]" },
1130 { "show", cmd_show
, "show [ITEM...]" },
1132 "sign [-0bpqvC] [-c COMMENT] [-k TAG] [-e EXPIRE]\n\t\
1133 [-f FILE] [-o OUTPUT]",
1137 -0, --null Read null-terminated filenames from stdin.\n\
1138 -b, --binary Produce a binary output file.\n\
1139 -q, --quiet Produce fewer messages while working.\n\
1140 -v, --verbose Produce more messages while working.\n\
1141 -p, --progress Show progress on large files.\n\
1142 -C, --nocheck Don't check the private key.\n\
1143 -c, --comment=COMMENT Include COMMENT in the output file.\n\
1144 -f, --file=FILE Read filenames to hash from FILE.\n\
1145 -o, --output=FILE Write the signed result to FILE.\n\
1146 -k, --key=TAG Use a key named by TAG.\n\
1147 -e, --expire=TIME The signature should expire after TIME.\n\
1150 "verify [-pqvC] [FILE]", "\
1153 -q, --quiet Produce fewer messages while working.\n\
1154 -v, --verbose Produce more messages while working.\n\
1155 -p, --progress Show progress on large files.\n\
1156 -C, --nocheck Don't check the public key.\n\
1161 static int cmd_help(int argc
, char **argv
)
1163 sc_help(cmdtab
, stdout
, argv
+ 1);
1167 void version(FILE *fp
)
1169 pquis(fp
, "$, Catacomb version " VERSION
"\n");
1172 static void usage(FILE *fp
)
1174 pquis(fp
, "Usage: $ [-k KEYRING] COMMAND [ARGS]\n");
1177 void help_global(FILE *fp
)
1181 Create and verify signatures on lists of files.\n\
1183 Global command-line options:\n\
1185 -h, --help [COMMAND...] Show this help message, or help for COMMANDs.\n\
1186 -v, --version Show program version number.\n\
1187 -u, --usage Show a terse usage message.\n\
1189 -k, --keyring=FILE Read keys from FILE.\n",
1195 * Arguments: @int argc@ = number of command line arguments
1196 * @char *argv[]@ = vector of command line arguments
1198 * Returns: Zero if successful, nonzero otherwise.
1200 * Use: Signs or verifies signatures on lists of files. Useful for
1201 * ensuring that a distribution is unmolested.
1204 int main(int argc
, char *argv
[])
1210 /* --- Initialize the library --- */
1214 rand_noisesrc(RAND_GLOBAL
, &noise_source
);
1215 rand_seed(RAND_GLOBAL
, 160);
1217 /* --- Parse options --- */
1220 static struct option opts
[] = {
1221 { "help", 0, 0, 'h' },
1222 { "version", 0, 0, 'v' },
1223 { "usage", 0, 0, 'u' },
1224 { "keyring", OPTF_ARGREQ
, 0, 'k' },
1227 int i
= mdwopt(argc
, argv
, "+hvu k:", opts
, 0, 0, 0);
1232 sc_help(cmdtab
, stdout
, argv
+ optind
);
1254 if (f
& f_bogus
|| argc
< 1) {
1259 /* --- Dispatch to the correct subcommand handler --- */
1261 return (findcmd(cmdtab
, argv
[0])->cmd(argc
, argv
));
1266 /*----- That's all, folks -------------------------------------------------*/