summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ocsp/ocsp_prn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ocsp/ocsp_prn.c')
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_prn.c100
1 files changed, 51 insertions, 49 deletions
diff --git a/src/lib/libcrypto/ocsp/ocsp_prn.c b/src/lib/libcrypto/ocsp/ocsp_prn.c
index 9e4b81f061..b5031cd091 100644
--- a/src/lib/libcrypto/ocsp/ocsp_prn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_prn.c
@@ -15,7 +15,7 @@
15 * are met: 15 * are met:
16 * 16 *
17 * 1. Redistributions of source code must retain the above copyright 17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer. 18 * notice, this list of conditions and the following disclaimer.
19 * 19 *
20 * 2. Redistributions in binary form must reproduce the above copyright 20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in 21 * notice, this list of conditions and the following disclaimer in
@@ -93,7 +93,7 @@ table2string(long s, const OCSP_TBLSTR *ts, int len)
93{ 93{
94 const OCSP_TBLSTR *p; 94 const OCSP_TBLSTR *p;
95 95
96 for (p=ts; p < ts + len; p++) 96 for (p = ts; p < ts + len; p++)
97 if (p->t == s) 97 if (p->t == s)
98 return p->m; 98 return p->m;
99 return "(UNKNOWN)"; 99 return "(UNKNOWN)";
@@ -103,42 +103,42 @@ const char *
103OCSP_response_status_str(long s) 103OCSP_response_status_str(long s)
104{ 104{
105 static const OCSP_TBLSTR rstat_tbl[] = { 105 static const OCSP_TBLSTR rstat_tbl[] = {
106 { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" }, 106 { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" },
107 { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" }, 107 { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" },
108 { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" }, 108 { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" },
109 { OCSP_RESPONSE_STATUS_TRYLATER, "trylater" }, 109 { OCSP_RESPONSE_STATUS_TRYLATER, "trylater" },
110 { OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired" }, 110 { OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired" },
111 { OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized" } 111 { OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized" }
112 }; 112 };
113 return table2string(s, rstat_tbl, 6); 113 return table2string(s, rstat_tbl, 6);
114} 114}
115 115
116const char * 116const char *
117OCSP_cert_status_str(long s) 117OCSP_cert_status_str(long s)
118{ 118{
119 static const OCSP_TBLSTR cstat_tbl[] = { 119 static const OCSP_TBLSTR cstat_tbl[] = {
120 { V_OCSP_CERTSTATUS_GOOD, "good" }, 120 { V_OCSP_CERTSTATUS_GOOD, "good" },
121 { V_OCSP_CERTSTATUS_REVOKED, "revoked" }, 121 { V_OCSP_CERTSTATUS_REVOKED, "revoked" },
122 { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } 122 { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" }
123 }; 123 };
124 return table2string(s, cstat_tbl, 3); 124 return table2string(s, cstat_tbl, 3);
125} 125}
126 126
127const char * 127const char *
128OCSP_crl_reason_str(long s) 128OCSP_crl_reason_str(long s)
129{ 129{
130 static const OCSP_TBLSTR reason_tbl[] = { 130 static const OCSP_TBLSTR reason_tbl[] = {
131 { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" }, 131 { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" },
132 { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" }, 132 { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" },
133 { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" }, 133 { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" },
134 { OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged" }, 134 { OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged" },
135 { OCSP_REVOKED_STATUS_SUPERSEDED, "superseded" }, 135 { OCSP_REVOKED_STATUS_SUPERSEDED, "superseded" },
136 { OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation" }, 136 { OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation" },
137 { OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold" }, 137 { OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold" },
138 { OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL" } 138 { OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL" }
139 }; 139 };
140 return table2string(s, reason_tbl, 8); 140 return table2string(s, reason_tbl, 8);
141} 141}
142 142
143int 143int
144OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags) 144OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
@@ -150,17 +150,17 @@ OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
150 OCSP_REQINFO *inf = o->tbsRequest; 150 OCSP_REQINFO *inf = o->tbsRequest;
151 OCSP_SIGNATURE *sig = o->optionalSignature; 151 OCSP_SIGNATURE *sig = o->optionalSignature;
152 152
153 if (BIO_write(bp,"OCSP Request Data:\n",19) <= 0) 153 if (BIO_write(bp, "OCSP Request Data:\n", 19) <= 0)
154 goto err; 154 goto err;
155 l = ASN1_INTEGER_get(inf->version); 155 l = ASN1_INTEGER_get(inf->version);
156 if (BIO_printf(bp," Version: %lu (0x%lx)",l+1,l) <= 0) 156 if (BIO_printf(bp, " Version: %lu (0x%lx)", l+1, l) <= 0)
157 goto err; 157 goto err;
158 if (inf->requestorName != NULL) { 158 if (inf->requestorName != NULL) {
159 if (BIO_write(bp,"\n Requestor Name: ",21) <= 0) 159 if (BIO_write(bp, "\n Requestor Name: ", 21) <= 0)
160 goto err; 160 goto err;
161 GENERAL_NAME_print(bp, inf->requestorName); 161 GENERAL_NAME_print(bp, inf->requestorName);
162 } 162 }
163 if (BIO_write(bp,"\n Requestor List:\n",21) <= 0) 163 if (BIO_write(bp, "\n Requestor List:\n", 21) <= 0)
164 goto err; 164 goto err;
165 for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++) { 165 for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++) {
166 one = sk_OCSP_ONEREQ_value(inf->requestList, i); 166 one = sk_OCSP_ONEREQ_value(inf->requestList, i);
@@ -176,12 +176,13 @@ OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
176 if (sig) { 176 if (sig) {
177 X509_signature_print(bp, sig->signatureAlgorithm, 177 X509_signature_print(bp, sig->signatureAlgorithm,
178 sig->signature); 178 sig->signature);
179 for (i=0; i<sk_X509_num(sig->certs); i++) { 179 for (i = 0; i < sk_X509_num(sig->certs); i++) {
180 X509_print(bp, sk_X509_value(sig->certs,i)); 180 X509_print(bp, sk_X509_value(sig->certs, i));
181 PEM_write_bio_X509(bp,sk_X509_value(sig->certs,i)); 181 PEM_write_bio_X509(bp, sk_X509_value(sig->certs, i));
182 } 182 }
183 } 183 }
184 return 1; 184 return 1;
185
185err: 186err:
186 return 0; 187 return 0;
187} 188}
@@ -200,20 +201,20 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
200 OCSP_SINGLERESP *single = NULL; 201 OCSP_SINGLERESP *single = NULL;
201 OCSP_RESPBYTES *rb = o->responseBytes; 202 OCSP_RESPBYTES *rb = o->responseBytes;
202 203
203 if (BIO_puts(bp,"OCSP Response Data:\n") <= 0) 204 if (BIO_puts(bp, "OCSP Response Data:\n") <= 0)
204 goto err; 205 goto err;
205 l = ASN1_ENUMERATED_get(o->responseStatus); 206 l = ASN1_ENUMERATED_get(o->responseStatus);
206 if (BIO_printf(bp," OCSP Response Status: %s (0x%lx)\n", 207 if (BIO_printf(bp, " OCSP Response Status: %s (0x%lx)\n",
207 OCSP_response_status_str(l), l) <= 0) 208 OCSP_response_status_str(l), l) <= 0)
208 goto err; 209 goto err;
209 if (rb == NULL) 210 if (rb == NULL)
210 return 1; 211 return 1;
211 if (BIO_puts(bp," Response Type: ") <= 0) 212 if (BIO_puts(bp, " Response Type: ") <= 0)
212 goto err; 213 goto err;
213 if(i2a_ASN1_OBJECT(bp, rb->responseType) <= 0) 214 if (i2a_ASN1_OBJECT(bp, rb->responseType) <= 0)
214 goto err; 215 goto err;
215 if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) { 216 if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) {
216 BIO_puts(bp," (unknown response type)\n"); 217 BIO_puts(bp, " (unknown response type)\n");
217 return 1; 218 return 1;
218 } 219 }
219 220
@@ -222,12 +223,12 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
222 goto err; 223 goto err;
223 rd = br->tbsResponseData; 224 rd = br->tbsResponseData;
224 l = ASN1_INTEGER_get(rd->version); 225 l = ASN1_INTEGER_get(rd->version);
225 if (BIO_printf(bp,"\n Version: %lu (0x%lx)\n", l+1,l) <= 0) 226 if (BIO_printf(bp, "\n Version: %lu (0x%lx)\n", l+1, l) <= 0)
226 goto err; 227 goto err;
227 if (BIO_puts(bp," Responder Id: ") <= 0) 228 if (BIO_puts(bp, " Responder Id: ") <= 0)
228 goto err; 229 goto err;
229 230
230 rid = rd->responderId; 231 rid = rd->responderId;
231 switch (rid->type) { 232 switch (rid->type) {
232 case V_OCSP_RESPID_NAME: 233 case V_OCSP_RESPID_NAME:
233 X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE); 234 X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE);
@@ -237,11 +238,11 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
237 break; 238 break;
238 } 239 }
239 240
240 if (BIO_printf(bp,"\n Produced At: ")<=0) 241 if (BIO_printf(bp, "\n Produced At: ")<=0)
241 goto err; 242 goto err;
242 if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) 243 if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt))
243 goto err; 244 goto err;
244 if (BIO_printf(bp,"\n Responses:\n") <= 0) 245 if (BIO_printf(bp, "\n Responses:\n") <= 0)
245 goto err; 246 goto err;
246 for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++) { 247 for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++) {
247 if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) 248 if (! sk_OCSP_SINGLERESP_value(rd->responses, i))
@@ -251,15 +252,15 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
251 if (ocsp_certid_print(bp, cid, 4) <= 0) 252 if (ocsp_certid_print(bp, cid, 4) <= 0)
252 goto err; 253 goto err;
253 cst = single->certStatus; 254 cst = single->certStatus;
254 if (BIO_printf(bp," Cert Status: %s", 255 if (BIO_printf(bp, " Cert Status: %s",
255 OCSP_cert_status_str(cst->type)) <= 0) 256 OCSP_cert_status_str(cst->type)) <= 0)
256 goto err; 257 goto err;
257 if (cst->type == V_OCSP_CERTSTATUS_REVOKED) { 258 if (cst->type == V_OCSP_CERTSTATUS_REVOKED) {
258 rev = cst->value.revoked; 259 rev = cst->value.revoked;
259 if (BIO_printf(bp, "\n Revocation Time: ") <= 0) 260 if (BIO_printf(bp, "\n Revocation Time: ") <= 0)
260 goto err; 261 goto err;
261 if (!ASN1_GENERALIZEDTIME_print(bp, 262 if (!ASN1_GENERALIZEDTIME_print(bp,
262 rev->revocationTime)) 263 rev->revocationTime))
263 goto err; 264 goto err;
264 if (rev->revocationReason) { 265 if (rev->revocationReason) {
265 l = ASN1_ENUMERATED_get(rev->revocationReason); 266 l = ASN1_ENUMERATED_get(rev->revocationReason);
@@ -269,22 +270,22 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
269 goto err; 270 goto err;
270 } 271 }
271 } 272 }
272 if (BIO_printf(bp,"\n This Update: ") <= 0) 273 if (BIO_printf(bp, "\n This Update: ") <= 0)
273 goto err; 274 goto err;
274 if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)) 275 if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate))
275 goto err; 276 goto err;
276 if (single->nextUpdate) { 277 if (single->nextUpdate) {
277 if (BIO_printf(bp,"\n Next Update: ") <= 0) 278 if (BIO_printf(bp, "\n Next Update: ") <= 0)
278 goto err; 279 goto err;
279 if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate)) 280 if (!ASN1_GENERALIZEDTIME_print(bp, single->nextUpdate))
280 goto err; 281 goto err;
281 } 282 }
282 if (BIO_write(bp,"\n",1) <= 0) 283 if (BIO_write(bp, "\n", 1) <= 0)
283 goto err; 284 goto err;
284 if (!X509V3_extensions_print(bp, "Response Single Extensions", 285 if (!X509V3_extensions_print(bp, "Response Single Extensions",
285 single->singleExtensions, flags, 8)) 286 single->singleExtensions, flags, 8))
286 goto err; 287 goto err;
287 if (BIO_write(bp,"\n",1) <= 0) 288 if (BIO_write(bp, "\n", 1) <= 0)
288 goto err; 289 goto err;
289 } 290 }
290 if (!X509V3_extensions_print(bp, "Response Extensions", 291 if (!X509V3_extensions_print(bp, "Response Extensions",
@@ -296,10 +297,11 @@ OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
296 297
297 for (i = 0; i < sk_X509_num(br->certs); i++) { 298 for (i = 0; i < sk_X509_num(br->certs); i++) {
298 X509_print(bp, sk_X509_value(br->certs, i)); 299 X509_print(bp, sk_X509_value(br->certs, i));
299 PEM_write_bio_X509(bp,sk_X509_value(br->certs, i)); 300 PEM_write_bio_X509(bp, sk_X509_value(br->certs, i));
300 } 301 }
301 302
302 ret = 1; 303 ret = 1;
304
303err: 305err:
304 OCSP_BASICRESP_free(br); 306 OCSP_BASICRESP_free(br);
305 return ret; 307 return ret;