summaryrefslogtreecommitdiff
path: root/lib/libkeynote/keynote-sigver.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-11-03 19:52:23 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-11-03 19:52:23 +0000
commit10d80ee8da6c67ecbb42f54778fc1b2b4036d32f (patch)
treefceb4fc79e5fcbd1769dfe3217e4bae3f5b8a6a0 /lib/libkeynote/keynote-sigver.c
parent074acb47bb6c5e0b6a4438c1e4ca2f75dcbfb5f7 (diff)
Handle multiple assertions per file in signature verification, better
detection of malformed credentials, update manpages, sync with release.
Diffstat (limited to 'lib/libkeynote/keynote-sigver.c')
-rw-r--r--lib/libkeynote/keynote-sigver.c78
1 files changed, 49 insertions, 29 deletions
diff --git a/lib/libkeynote/keynote-sigver.c b/lib/libkeynote/keynote-sigver.c
index 3a3e68cec7b..81332a4ff10 100644
--- a/lib/libkeynote/keynote-sigver.c
+++ b/lib/libkeynote/keynote-sigver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keynote-sigver.c,v 1.8 1999/10/26 22:31:38 angelos Exp $ */
+/* $OpenBSD: keynote-sigver.c,v 1.9 1999/11/03 19:52:22 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
*
@@ -56,9 +56,9 @@ sigverusage(void)
void
keynote_sigver(int argc, char *argv[])
{
+ char *buf, **assertlist;
+ int fd, i, n, j;
struct stat sb;
- int fd, i;
- char *buf;
if (argc != 2)
{
@@ -101,41 +101,61 @@ keynote_sigver(int argc, char *argv[])
close(fd);
- i = kn_verify_assertion(buf, sb.st_size);
- if (i == -1)
+ assertlist = kn_read_asserts(buf, sb.st_size, &n);
+ if ((assertlist == NULL) || (n == 0))
{
- switch (keynote_errno)
- {
- case ERROR_MEMORY:
- fprintf(stderr,
- "Out of memory while parsing the assertion.\n");
- break;
-
- case ERROR_SYNTAX:
- fprintf(stderr,
- "Syntax error while parsing the assertion.\n");
- break;
-
- default:
- fprintf(stderr,
- "Unknown error while parsing the assertion.\n");
- }
-
+ if (keynote_errno == ERROR_MEMORY)
+ fprintf(stderr, "Out of memory while allocating memory for "
+ "assertions.\n");
+ else
+ fprintf(stderr, "No assertions found.\n");
exit(-1);
}
free(buf);
- if (i == SIGRESULT_TRUE)
- fprintf(stdout, "Signature verified.\n");
- else
+ for (j = 0; j < n; j++)
{
- if (keynote_errno != 0)
- fprintf(stdout, "Signature could not be verified "
- "(keynote_errno = %d).\n", keynote_errno);
+ i = kn_verify_assertion(assertlist[j], strlen(assertlist[j]));
+ if (i == -1)
+ {
+ switch (keynote_errno)
+ {
+ case ERROR_MEMORY:
+ fprintf(stderr,
+ "Out of memory while parsing assertion %d.\n", j);
+ break;
+
+ case ERROR_SYNTAX:
+ fprintf(stderr,
+ "Syntax error while parsing assertion %d.\n", j);
+ break;
+
+ default:
+ fprintf(stderr,
+ "Unknown error while parsing assertion %d.\n", j);
+ }
+ }
else
- fprintf(stdout, "Signature did not verify!\n");
+ {
+ if (i == SIGRESULT_TRUE)
+ fprintf(stdout, "Signature on assertion %d verified.\n", j);
+ else
+ {
+ if (keynote_errno != 0)
+ fprintf(stdout,
+ "Signature on assertion %d could not be verified "
+ "(keynote_errno = %d).\n", j, keynote_errno);
+ else
+ fprintf(stdout,
+ "Signature on assertion %d did not verify!\n", j);
+ }
+ }
+
+ free(assertlist[j]);
}
+ free(assertlist);
+
exit(0);
}