diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libssl/src/apps/crl.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libssl/src/apps/crl.c')
-rw-r--r-- | src/lib/libssl/src/apps/crl.c | 96 |
1 files changed, 30 insertions, 66 deletions
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c index 2c18374ee0..f7bdf76676 100644 --- a/src/lib/libssl/src/apps/crl.c +++ b/src/lib/libssl/src/apps/crl.c | |||
@@ -60,10 +60,11 @@ | |||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include "apps.h" | 62 | #include "apps.h" |
63 | #include "bio.h" | 63 | #include <openssl/bio.h> |
64 | #include "err.h" | 64 | #include <openssl/err.h> |
65 | #include "x509.h" | 65 | #include <openssl/x509.h> |
66 | #include "pem.h" | 66 | #include <openssl/x509v3.h> |
67 | #include <openssl/pem.h> | ||
67 | 68 | ||
68 | #undef PROG | 69 | #undef PROG |
69 | #define PROG crl_main | 70 | #define PROG crl_main |
@@ -71,11 +72,6 @@ | |||
71 | #undef POSTFIX | 72 | #undef POSTFIX |
72 | #define POSTFIX ".rvk" | 73 | #define POSTFIX ".rvk" |
73 | 74 | ||
74 | #define FORMAT_UNDEF 0 | ||
75 | #define FORMAT_ASN1 1 | ||
76 | #define FORMAT_TEXT 2 | ||
77 | #define FORMAT_PEM 3 | ||
78 | |||
79 | static char *crl_usage[]={ | 75 | static char *crl_usage[]={ |
80 | "usage: crl args\n", | 76 | "usage: crl args\n", |
81 | "\n", | 77 | "\n", |
@@ -92,24 +88,17 @@ static char *crl_usage[]={ | |||
92 | NULL | 88 | NULL |
93 | }; | 89 | }; |
94 | 90 | ||
95 | #ifndef NOPROTO | ||
96 | static X509_CRL *load_crl(char *file, int format); | 91 | static X509_CRL *load_crl(char *file, int format); |
97 | #else | ||
98 | static X509_CRL *load_crl(); | ||
99 | #endif | ||
100 | |||
101 | static BIO *bio_out=NULL; | 92 | static BIO *bio_out=NULL; |
102 | 93 | ||
103 | int MAIN(argc, argv) | 94 | int MAIN(int argc, char **argv) |
104 | int argc; | ||
105 | char **argv; | ||
106 | { | 95 | { |
107 | X509_CRL *x=NULL; | 96 | X509_CRL *x=NULL; |
108 | int ret=1,i,num,badops=0; | 97 | int ret=1,i,num,badops=0; |
109 | BIO *out=NULL; | 98 | BIO *out=NULL; |
110 | int informat,outformat; | 99 | int informat,outformat; |
111 | char *infile=NULL,*outfile=NULL; | 100 | char *infile=NULL,*outfile=NULL; |
112 | int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0; | 101 | int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; |
113 | char **pp,buf[256]; | 102 | char **pp,buf[256]; |
114 | 103 | ||
115 | apps_startup(); | 104 | apps_startup(); |
@@ -147,10 +136,6 @@ char **argv; | |||
147 | if (--argc < 1) goto bad; | 136 | if (--argc < 1) goto bad; |
148 | outformat=str2fmt(*(++argv)); | 137 | outformat=str2fmt(*(++argv)); |
149 | } | 138 | } |
150 | else if (strcmp(*argv,"-text") == 0) | ||
151 | { | ||
152 | outformat=FORMAT_TEXT; | ||
153 | } | ||
154 | else if (strcmp(*argv,"-in") == 0) | 139 | else if (strcmp(*argv,"-in") == 0) |
155 | { | 140 | { |
156 | if (--argc < 1) goto bad; | 141 | if (--argc < 1) goto bad; |
@@ -161,6 +146,8 @@ char **argv; | |||
161 | if (--argc < 1) goto bad; | 146 | if (--argc < 1) goto bad; |
162 | outfile= *(++argv); | 147 | outfile= *(++argv); |
163 | } | 148 | } |
149 | else if (strcmp(*argv,"-text") == 0) | ||
150 | text = 1; | ||
164 | else if (strcmp(*argv,"-hash") == 0) | 151 | else if (strcmp(*argv,"-hash") == 0) |
165 | hash= ++num; | 152 | hash= ++num; |
166 | else if (strcmp(*argv,"-issuer") == 0) | 153 | else if (strcmp(*argv,"-issuer") == 0) |
@@ -181,14 +168,6 @@ char **argv; | |||
181 | argv++; | 168 | argv++; |
182 | } | 169 | } |
183 | 170 | ||
184 | if (outformat == FORMAT_TEXT) | ||
185 | { | ||
186 | num=0; | ||
187 | issuer= ++num; | ||
188 | lastupdate= ++num; | ||
189 | nextupdate= ++num; | ||
190 | } | ||
191 | |||
192 | if (badops) | 171 | if (badops) |
193 | { | 172 | { |
194 | bad: | 173 | bad: |
@@ -198,6 +177,7 @@ bad: | |||
198 | } | 177 | } |
199 | 178 | ||
200 | ERR_load_crypto_strings(); | 179 | ERR_load_crypto_strings(); |
180 | X509V3_add_standard_extensions(); | ||
201 | x=load_crl(infile,informat); | 181 | x=load_crl(infile,informat); |
202 | if (x == NULL) { goto end; } | 182 | if (x == NULL) { goto end; } |
203 | 183 | ||
@@ -208,34 +188,32 @@ bad: | |||
208 | if (issuer == i) | 188 | if (issuer == i) |
209 | { | 189 | { |
210 | X509_NAME_oneline(x->crl->issuer,buf,256); | 190 | X509_NAME_oneline(x->crl->issuer,buf,256); |
211 | fprintf(stdout,"issuer= %s\n",buf); | 191 | BIO_printf(bio_out,"issuer= %s\n",buf); |
212 | } | 192 | } |
213 | 193 | ||
214 | if (hash == i) | 194 | if (hash == i) |
215 | { | 195 | { |
216 | fprintf(stdout,"%08lx\n", | 196 | BIO_printf(bio_out,"%08lx\n", |
217 | X509_NAME_hash(x->crl->issuer)); | 197 | X509_NAME_hash(x->crl->issuer)); |
218 | } | 198 | } |
219 | if (lastupdate == i) | 199 | if (lastupdate == i) |
220 | { | 200 | { |
221 | fprintf(stdout,"lastUpdate="); | 201 | BIO_printf(bio_out,"lastUpdate="); |
222 | ASN1_UTCTIME_print(bio_out,x->crl->lastUpdate); | 202 | ASN1_TIME_print(bio_out,x->crl->lastUpdate); |
223 | fprintf(stdout,"\n"); | 203 | BIO_printf(bio_out,"\n"); |
224 | } | 204 | } |
225 | if (nextupdate == i) | 205 | if (nextupdate == i) |
226 | { | 206 | { |
227 | fprintf(stdout,"nextUpdate="); | 207 | BIO_printf(bio_out,"nextUpdate="); |
228 | if (x->crl->nextUpdate != NULL) | 208 | if (x->crl->nextUpdate != NULL) |
229 | ASN1_UTCTIME_print(bio_out,x->crl->nextUpdate); | 209 | ASN1_TIME_print(bio_out,x->crl->nextUpdate); |
230 | else | 210 | else |
231 | fprintf(stdout,"NONE"); | 211 | BIO_printf(bio_out,"NONE"); |
232 | fprintf(stdout,"\n"); | 212 | BIO_printf(bio_out,"\n"); |
233 | } | 213 | } |
234 | } | 214 | } |
235 | } | 215 | } |
236 | 216 | ||
237 | if (noout) goto end; | ||
238 | |||
239 | out=BIO_new(BIO_s_file()); | 217 | out=BIO_new(BIO_s_file()); |
240 | if (out == NULL) | 218 | if (out == NULL) |
241 | { | 219 | { |
@@ -254,27 +232,14 @@ bad: | |||
254 | } | 232 | } |
255 | } | 233 | } |
256 | 234 | ||
235 | if (text) X509_CRL_print(out, x); | ||
236 | |||
237 | if (noout) goto end; | ||
238 | |||
257 | if (outformat == FORMAT_ASN1) | 239 | if (outformat == FORMAT_ASN1) |
258 | i=(int)i2d_X509_CRL_bio(out,x); | 240 | i=(int)i2d_X509_CRL_bio(out,x); |
259 | else if (outformat == FORMAT_PEM) | 241 | else if (outformat == FORMAT_PEM) |
260 | i=PEM_write_bio_X509_CRL(out,x); | 242 | i=PEM_write_bio_X509_CRL(out,x); |
261 | else if (outformat == FORMAT_TEXT) | ||
262 | { | ||
263 | X509_REVOKED *r; | ||
264 | STACK *sk; | ||
265 | |||
266 | sk=sk_dup(x->crl->revoked); | ||
267 | while ((r=(X509_REVOKED *)sk_pop(sk)) != NULL) | ||
268 | { | ||
269 | fprintf(stdout,"revoked: serialNumber="); | ||
270 | i2a_ASN1_INTEGER(out,r->serialNumber); | ||
271 | fprintf(stdout," revocationDate="); | ||
272 | ASN1_UTCTIME_print(bio_out,r->revocationDate); | ||
273 | fprintf(stdout,"\n"); | ||
274 | } | ||
275 | sk_free(sk); | ||
276 | i=1; | ||
277 | } | ||
278 | else | 243 | else |
279 | { | 244 | { |
280 | BIO_printf(bio_err,"bad output format specified for outfile\n"); | 245 | BIO_printf(bio_err,"bad output format specified for outfile\n"); |
@@ -283,15 +248,14 @@ bad: | |||
283 | if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; } | 248 | if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; } |
284 | ret=0; | 249 | ret=0; |
285 | end: | 250 | end: |
286 | if (out != NULL) BIO_free(out); | 251 | BIO_free(out); |
287 | if (bio_out != NULL) BIO_free(bio_out); | 252 | BIO_free(bio_out); |
288 | if (x != NULL) X509_CRL_free(x); | 253 | X509_CRL_free(x); |
254 | X509V3_EXT_cleanup(); | ||
289 | EXIT(ret); | 255 | EXIT(ret); |
290 | } | 256 | } |
291 | 257 | ||
292 | static X509_CRL *load_crl(infile, format) | 258 | static X509_CRL *load_crl(char *infile, int format) |
293 | char *infile; | ||
294 | int format; | ||
295 | { | 259 | { |
296 | X509_CRL *x=NULL; | 260 | X509_CRL *x=NULL; |
297 | BIO *in=NULL; | 261 | BIO *in=NULL; |
@@ -316,7 +280,7 @@ int format; | |||
316 | if (format == FORMAT_ASN1) | 280 | if (format == FORMAT_ASN1) |
317 | x=d2i_X509_CRL_bio(in,NULL); | 281 | x=d2i_X509_CRL_bio(in,NULL); |
318 | else if (format == FORMAT_PEM) | 282 | else if (format == FORMAT_PEM) |
319 | x=PEM_read_bio_X509_CRL(in,NULL,NULL); | 283 | x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL); |
320 | else { | 284 | else { |
321 | BIO_printf(bio_err,"bad input format specified for input crl\n"); | 285 | BIO_printf(bio_err,"bad input format specified for input crl\n"); |
322 | goto end; | 286 | goto end; |
@@ -329,7 +293,7 @@ int format; | |||
329 | } | 293 | } |
330 | 294 | ||
331 | end: | 295 | end: |
332 | if (in != NULL) BIO_free(in); | 296 | BIO_free(in); |
333 | return(x); | 297 | return(x); |
334 | } | 298 | } |
335 | 299 | ||