-.\" $OpenBSD: signify.1,v 1.8 2014/01/09 15:36:40 tedu Exp $
+.\" $OpenBSD: signify.1,v 1.9 2014/01/10 04:15:38 tedu Exp $
.\"
.\"Copyright (c) 2013 Marc Espie <espie@openbsd.org>
.\"Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
.\"WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\"ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\"OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.Dd $Mdocdate: January 9 2014 $
+.Dd $Mdocdate: January 10 2014 $
.Dt SIGNIFY 1
.Os
.Sh NAME
.Fl s Ar seckey
.Fl G
.Nm signify
+.Op Fl o Ar signature
+.Op Fl p Ar pubkey
+.Op Fl s Ar seckey
+.Fl I
+.Nm signify
.Op Fl e
.Op Fl o Ar output
.Fl s Ar seckey
For verification, extract the message from the signature.
.It Fl G
Generate a new keypair.
+.It Fl I
+Inspect the specified keys or signature and print their fingerprint.
.It Fl n
Do not ask for a passphrase during key generation.
Otherwise,
-/* $OpenBSD: signify.c,v 1.21 2014/01/09 21:19:38 jmc Exp $ */
+/* $OpenBSD: signify.c,v 1.22 2014/01/10 04:15:38 tedu Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
fprintf(stderr, "usage:"
#ifndef VERIFYONLY
"\t%s [-n] -p pubkey -s seckey -G\n"
+ "\t%s [-o sig] [-p pubkey] [-s seckey] -I\n"
"\t%s [-e] [-o output] -s seckey -S message\n"
#endif
"\t%s [-e] [-o output] -p pubkey -V message\n",
#ifndef VERIFYONLY
- __progname, __progname,
+ __progname, __progname, __progname,
#endif
__progname);
exit(1);
free(msg);
}
+
+static void
+inspect(const char *seckeyfile, const char *pubkeyfile, const char *sigfile)
+{
+ struct sig sig;
+ struct enckey enckey;
+ struct pubkey pubkey;
+ char fp[(FPLEN + 2) / 3 * 4 + 1];
+
+ if (seckeyfile) {
+ readb64file(seckeyfile, &enckey, sizeof(enckey), NULL);
+ b64_ntop(enckey.fingerprint, FPLEN, fp, sizeof(fp));
+ printf("sec fp: %s\n", fp);
+ }
+ if (pubkeyfile) {
+ readb64file(pubkeyfile, &pubkey, sizeof(pubkey), NULL);
+ b64_ntop(pubkey.fingerprint, FPLEN, fp, sizeof(fp));
+ printf("pub fp: %s\n", fp);
+ }
+ if (sigfile) {
+ readb64file(sigfile, &sig, sizeof(sig), NULL);
+ b64_ntop(sig.fingerprint, FPLEN, fp, sizeof(fp));
+ printf("sig fp: %s\n", fp);
+ }
+}
#endif
static void
readb64file(sigfile, &sig, sizeof(sig), NULL);
}
- if (memcmp(pubkey.fingerprint, sig.fingerprint, FPLEN))
+ if (memcmp(pubkey.fingerprint, sig.fingerprint, FPLEN)) {
+#ifndef VERIFYONLY
+ inspect(NULL, pubkeyfile, sigfile);
+#endif
errx(1, "verification failed: checked against wrong key");
+ }
verifymsg(pubkey.pubkey, msg, msglen, sig.sig);
if (embedded) {
enum {
NONE,
GENERATE,
+ INSPECT,
SIGN,
VERIFY
} verb = NONE;
rounds = 42;
- while ((ch = getopt(argc, argv, "GSVeno:p:s:")) != -1) {
+ while ((ch = getopt(argc, argv, "GISVeno:p:s:")) != -1) {
switch (ch) {
#ifndef VERIFYONLY
case 'G':
usage();
verb = GENERATE;
break;
+ case 'I':
+ if (verb)
+ usage();
+ verb = INSPECT;
+ break;
case 'S':
if (verb)
usage();
if (!pubkeyfile || !seckeyfile || argc != 0)
usage();
generate(pubkeyfile, seckeyfile, rounds);
+ } else if (verb == INSPECT) {
+ if (argc != 0)
+ usage();
+ inspect(seckeyfile, pubkeyfile, sigfile);
} else
#endif
{