| @@ -85,56 +85,60 @@ getstdin(ssize_t *cc, size_t *size) | | | @@ -85,56 +85,60 @@ getstdin(ssize_t *cc, size_t *size) |
85 | return in; | | 85 | return in; |
86 | } | | 86 | } |
87 | | | 87 | |
88 | /* verify memory or file */ | | 88 | /* verify memory or file */ |
89 | static int | | 89 | static int |
90 | verify_data(pgpv_t *pgp, const char *cmd, const char *inname, char *in, ssize_t cc) | | 90 | verify_data(pgpv_t *pgp, const char *cmd, const char *inname, char *in, ssize_t cc) |
91 | { | | 91 | { |
92 | pgpv_cursor_t *cursor; | | 92 | pgpv_cursor_t *cursor; |
93 | const char *modifiers; | | 93 | const char *modifiers; |
94 | size_t size; | | 94 | size_t size; |
95 | size_t cookie; | | 95 | size_t cookie; |
96 | char *data; | | 96 | char *data; |
97 | int el; | | 97 | int el; |
| | | 98 | int ok; |
98 | | | 99 | |
99 | cursor = pgpv_new_cursor(); | | 100 | cursor = pgpv_new_cursor(); |
| | | 101 | ok = 0; |
100 | if (strcasecmp(cmd, "cat") == 0) { | | 102 | if (strcasecmp(cmd, "cat") == 0) { |
101 | if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) { | | 103 | if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) { |
102 | if ((size = pgpv_get_verified(cursor, cookie, &data)) > 0) { | | 104 | if ((size = pgpv_get_verified(cursor, cookie, &data)) > 0) { |
103 | write(STDOUT_FILENO, data, size); | | 105 | write(STDOUT_FILENO, data, size); |
104 | } | | 106 | } |
105 | return 1; | | 107 | ok = 1; |
106 | } | | 108 | } |
107 | } else if (strcasecmp(cmd, "dump") == 0) { | | 109 | } else if (strcasecmp(cmd, "dump") == 0) { |
108 | if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) { | | 110 | if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) { |
109 | size = pgpv_dump(pgp, &data); | | 111 | size = pgpv_dump(pgp, &data); |
110 | write(STDOUT_FILENO, data, size); | | 112 | write(STDOUT_FILENO, data, size); |
111 | return 1; | | 113 | ok = 1; |
112 | } | | 114 | } |
113 | } else if (strcasecmp(cmd, "verify") == 0 || strcasecmp(cmd, "trust") == 0) { | | 115 | } else if (strcasecmp(cmd, "verify") == 0 || strcasecmp(cmd, "trust") == 0) { |
114 | modifiers = (strcasecmp(cmd, "trust") == 0) ? "trust" : NULL; | | 116 | modifiers = (strcasecmp(cmd, "trust") == 0) ? "trust" : NULL; |
115 | if (pgpv_verify(cursor, pgp, in, cc)) { | | 117 | if (pgpv_verify(cursor, pgp, in, cc)) { |
116 | printf("Good signature for %s made ", inname); | | 118 | printf("Good signature for %s made ", inname); |
117 | ptime(pgpv_get_cursor_num(cursor, "sigtime")); | | 119 | ptime(pgpv_get_cursor_num(cursor, "sigtime")); |
118 | el = pgpv_get_cursor_element(cursor, 0); | | 120 | el = pgpv_get_cursor_element(cursor, 0); |
119 | pentry(pgp, el, modifiers); | | 121 | pentry(pgp, el, modifiers); |
120 | return 1; | | 122 | ok = 1; |
| | | 123 | } else { |
| | | 124 | fprintf(stderr, "Signature did not match contents -- %s\n", |
| | | 125 | pgpv_get_cursor_str(cursor, "why")); |
121 | } | | 126 | } |
122 | fprintf(stderr, "Signature did not match contents -- %s\n", | | | |
123 | pgpv_get_cursor_str(cursor, "why")); | | | |
124 | } else { | | 127 | } else { |
125 | fprintf(stderr, "unrecognised command \"%s\"\n", cmd); | | 128 | fprintf(stderr, "unrecognised command \"%s\"\n", cmd); |
126 | } | | 129 | } |
127 | return 0; | | 130 | pgpv_cursor_close(cursor); |
| | | 131 | return ok; |
128 | } | | 132 | } |
129 | | | 133 | |
130 | int | | 134 | int |
131 | main(int argc, char **argv) | | 135 | main(int argc, char **argv) |
132 | { | | 136 | { |
133 | const char *keyring; | | 137 | const char *keyring; |
134 | const char *cmd; | | 138 | const char *cmd; |
135 | ssize_t cc; | | 139 | ssize_t cc; |
136 | size_t size; | | 140 | size_t size; |
137 | pgpv_t *pgp; | | 141 | pgpv_t *pgp; |
138 | char *in; | | 142 | char *in; |
139 | int ssh; | | 143 | int ssh; |
140 | int ok; | | 144 | int ok; |