Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/ocsp/ocsp_prn.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | static int | - | ||||||
3 | ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent) | - | ||||||
4 | { | - | ||||||
5 | BIO_printf(bp, "%*sCertificate ID:\n", indent, ""); | - | ||||||
6 | indent += 2; | - | ||||||
7 | BIO_printf(bp, "%*sHash Algorithm: ", indent, ""); | - | ||||||
8 | i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm); | - | ||||||
9 | BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, ""); | - | ||||||
10 | i2a_ASN1_STRING(bp, a->issuerNameHash, 4); | - | ||||||
11 | BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, ""); | - | ||||||
12 | i2a_ASN1_STRING(bp, a->issuerKeyHash, 4); | - | ||||||
13 | BIO_printf(bp, "\n%*sSerial Number: ", indent, ""); | - | ||||||
14 | i2a_ASN1_INTEGER(bp, a->serialNumber); | - | ||||||
15 | BIO_printf(bp, "\n"); | - | ||||||
16 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
17 | } | - | ||||||
18 | - | |||||||
19 | typedef struct { | - | ||||||
20 | long t; | - | ||||||
21 | const char *m; | - | ||||||
22 | } OCSP_TBLSTR; | - | ||||||
23 | - | |||||||
24 | static const char * | - | ||||||
25 | table2string(long s, const OCSP_TBLSTR *ts, int len) | - | ||||||
26 | { | - | ||||||
27 | const OCSP_TBLSTR *p; | - | ||||||
28 | - | |||||||
29 | for (p = ts; p < ts + len
| 0 | ||||||
30 | if (p->t == s
| 0 | ||||||
31 | return never executed: p->m;return p->m; never executed: return p->m; | 0 | ||||||
32 | return never executed: "(UNKNOWN)";return "(UNKNOWN)"; never executed: return "(UNKNOWN)"; | 0 | ||||||
33 | } | - | ||||||
34 | - | |||||||
35 | const char * | - | ||||||
36 | OCSP_response_status_str(long s) | - | ||||||
37 | { | - | ||||||
38 | static const OCSP_TBLSTR rstat_tbl[] = { | - | ||||||
39 | { 0, "successful" }, | - | ||||||
40 | { 1, "malformedrequest" }, | - | ||||||
41 | { 2, "internalerror" }, | - | ||||||
42 | { 3, "trylater" }, | - | ||||||
43 | { 5, "sigrequired" }, | - | ||||||
44 | { 6, "unauthorized" } | - | ||||||
45 | }; | - | ||||||
46 | return never executed: table2string(s, rstat_tbl, 6);return table2string(s, rstat_tbl, 6); never executed: return table2string(s, rstat_tbl, 6); | 0 | ||||||
47 | } | - | ||||||
48 | - | |||||||
49 | const char * | - | ||||||
50 | OCSP_cert_status_str(long s) | - | ||||||
51 | { | - | ||||||
52 | static const OCSP_TBLSTR cstat_tbl[] = { | - | ||||||
53 | { 0, "good" }, | - | ||||||
54 | { 1, "revoked" }, | - | ||||||
55 | { 2, "unknown" } | - | ||||||
56 | }; | - | ||||||
57 | return never executed: table2string(s, cstat_tbl, 3);return table2string(s, cstat_tbl, 3); never executed: return table2string(s, cstat_tbl, 3); | 0 | ||||||
58 | } | - | ||||||
59 | - | |||||||
60 | const char * | - | ||||||
61 | OCSP_crl_reason_str(long s) | - | ||||||
62 | { | - | ||||||
63 | static const OCSP_TBLSTR reason_tbl[] = { | - | ||||||
64 | { 0, "unspecified" }, | - | ||||||
65 | { 1, "keyCompromise" }, | - | ||||||
66 | { 2, "cACompromise" }, | - | ||||||
67 | { 3, "affiliationChanged" }, | - | ||||||
68 | { 4, "superseded" }, | - | ||||||
69 | { 5, "cessationOfOperation" }, | - | ||||||
70 | { 6, "certificateHold" }, | - | ||||||
71 | { 8, "removeFromCRL" } | - | ||||||
72 | }; | - | ||||||
73 | return never executed: table2string(s, reason_tbl, 8);return table2string(s, reason_tbl, 8); never executed: return table2string(s, reason_tbl, 8); | 0 | ||||||
74 | } | - | ||||||
75 | - | |||||||
76 | int | - | ||||||
77 | OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags) | - | ||||||
78 | { | - | ||||||
79 | int i; | - | ||||||
80 | long l; | - | ||||||
81 | OCSP_CERTID* cid = | - | ||||||
82 | ((void *)0) | - | ||||||
83 | ; | - | ||||||
84 | OCSP_ONEREQ *one = | - | ||||||
85 | ((void *)0) | - | ||||||
86 | ; | - | ||||||
87 | OCSP_REQINFO *inf = o->tbsRequest; | - | ||||||
88 | OCSP_SIGNATURE *sig = o->optionalSignature; | - | ||||||
89 | - | |||||||
90 | if (BIO_write(bp, "OCSP Request Data:\n", 19) <= 0
| 0 | ||||||
91 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
92 | l = ASN1_INTEGER_get(inf->version); | - | ||||||
93 | if (BIO_printf(bp, " Version: %lu (0x%lx)", l+1, l) <= 0
| 0 | ||||||
94 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
95 | if (inf->requestorName !=
| 0 | ||||||
96 | ((void *)0)
| 0 | ||||||
97 | ) { | - | ||||||
98 | if (BIO_write(bp, "\n Requestor Name: ", 21) <= 0
| 0 | ||||||
99 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
100 | GENERAL_NAME_print(bp, inf->requestorName); | - | ||||||
101 | } never executed: end of block | 0 | ||||||
102 | if (BIO_write(bp, "\n Requestor List:\n", 21) <= 0
| 0 | ||||||
103 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
104 | for (i = 0; i < sk_num(((_STACK*) (1 ? (inf->requestList) : (struct stack_st_OCSP_ONEREQ*)0)))
| 0 | ||||||
105 | one = ((OCSP_ONEREQ *)sk_value(((_STACK*) (1 ? (inf->requestList) : (struct stack_st_OCSP_ONEREQ*)0)), (i))); | - | ||||||
106 | cid = one->reqCert; | - | ||||||
107 | ocsp_certid_print(bp, cid, 8); | - | ||||||
108 | if (!X509V3_extensions_print(bp, "Request Single Extensions",
| 0 | ||||||
109 | one->singleRequestExtensions, flags, 8)
| 0 | ||||||
110 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
111 | } never executed: end of block | 0 | ||||||
112 | if (!X509V3_extensions_print(bp, "Request Extensions",
| 0 | ||||||
113 | inf->requestExtensions, flags, 4)
| 0 | ||||||
114 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
115 | if (sig
| 0 | ||||||
116 | if (X509_signature_print(bp, sig->signatureAlgorithm,
| 0 | ||||||
117 | sig->signature) == 0
| 0 | ||||||
118 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
119 | for (i = 0; i < sk_num(((_STACK*) (1 ? (sig->certs) : (struct stack_st_X509*)0)))
| 0 | ||||||
120 | if (X509_print(bp, ((X509 *)sk_value(((_STACK*) (1 ? (sig->certs) : (struct stack_st_X509*)0)), (i)))) == 0
| 0 | ||||||
121 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
122 | if (PEM_write_bio_X509(bp,
| 0 | ||||||
123 | ((X509 *)sk_value(((_STACK*) (1 ? (sig->certs) : (struct stack_st_X509*)0)), (i)))) == 0
| 0 | ||||||
124 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
125 | } never executed: end of block | 0 | ||||||
126 | } never executed: end of block | 0 | ||||||
127 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
128 | - | |||||||
129 | err: | - | ||||||
130 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
131 | } | - | ||||||
132 | - | |||||||
133 | int | - | ||||||
134 | OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags) | - | ||||||
135 | { | - | ||||||
136 | int i, ret = 0; | - | ||||||
137 | long l; | - | ||||||
138 | OCSP_CERTID *cid = | - | ||||||
139 | ((void *)0) | - | ||||||
140 | ; | - | ||||||
141 | OCSP_BASICRESP *br = | - | ||||||
142 | ((void *)0) | - | ||||||
143 | ; | - | ||||||
144 | OCSP_RESPID *rid = | - | ||||||
145 | ((void *)0) | - | ||||||
146 | ; | - | ||||||
147 | OCSP_RESPDATA *rd = | - | ||||||
148 | ((void *)0) | - | ||||||
149 | ; | - | ||||||
150 | OCSP_CERTSTATUS *cst = | - | ||||||
151 | ((void *)0) | - | ||||||
152 | ; | - | ||||||
153 | OCSP_REVOKEDINFO *rev = | - | ||||||
154 | ((void *)0) | - | ||||||
155 | ; | - | ||||||
156 | OCSP_SINGLERESP *single = | - | ||||||
157 | ((void *)0) | - | ||||||
158 | ; | - | ||||||
159 | OCSP_RESPBYTES *rb = o->responseBytes; | - | ||||||
160 | - | |||||||
161 | if (BIO_puts(bp, "OCSP Response Data:\n") <= 0
| 0 | ||||||
162 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
163 | l = ASN1_ENUMERATED_get(o->responseStatus); | - | ||||||
164 | if (BIO_printf(bp, " OCSP Response Status: %s (0x%lx)\n",
| 0 | ||||||
165 | OCSP_response_status_str(l), l) <= 0
| 0 | ||||||
166 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
167 | if (rb ==
| 0 | ||||||
168 | ((void *)0)
| 0 | ||||||
169 | ) | - | ||||||
170 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
171 | if (BIO_puts(bp, " Response Type: ") <= 0
| 0 | ||||||
172 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
173 | if (i2a_ASN1_OBJECT(bp, rb->responseType) <= 0
| 0 | ||||||
174 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
175 | if (OBJ_obj2nid(rb->responseType) != 365
| 0 | ||||||
176 | BIO_puts(bp, " (unknown response type)\n"); | - | ||||||
177 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
178 | } | - | ||||||
179 | - | |||||||
180 | i = ASN1_STRING_length(rb->response); | - | ||||||
181 | if (!(br = OCSP_response_get1_basic(o))
| 0 | ||||||
182 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
183 | rd = br->tbsResponseData; | - | ||||||
184 | l = ASN1_INTEGER_get(rd->version); | - | ||||||
185 | if (BIO_printf(bp, "\n Version: %lu (0x%lx)\n", l+1, l) <= 0
| 0 | ||||||
186 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
187 | if (BIO_puts(bp, " Responder Id: ") <= 0
| 0 | ||||||
188 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
189 | - | |||||||
190 | rid = rd->responderId; | - | ||||||
191 | switch (rid->type) { | - | ||||||
192 | case never executed: 0:case 0: never executed: case 0: | 0 | ||||||
193 | X509_NAME_print_ex(bp, rid->value.byName, 0, ((1 | 2 | 4 | 0x10 | 0x100 | 0x200) | 8 | (2 << 16) | (1 << 23) | 0)); | - | ||||||
194 | break; never executed: break; | 0 | ||||||
195 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||
196 | i2a_ASN1_STRING(bp, rid->value.byKey, 4); | - | ||||||
197 | break; never executed: break; | 0 | ||||||
198 | } | - | ||||||
199 | - | |||||||
200 | if (BIO_printf(bp, "\n Produced At: ")<=0
| 0 | ||||||
201 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
202 | if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)
| 0 | ||||||
203 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
204 | if (BIO_printf(bp, "\n Responses:\n") <= 0
| 0 | ||||||
205 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
206 | for (i = 0; i < sk_num(((_STACK*) (1 ? (rd->responses) : (struct stack_st_OCSP_SINGLERESP*)0)))
| 0 | ||||||
207 | if (! ((OCSP_SINGLERESP *)sk_value(((_STACK*) (1 ? (rd->responses) : (struct stack_st_OCSP_SINGLERESP*)0)), (i)))
| 0 | ||||||
208 | continue; never executed: continue; | 0 | ||||||
209 | single = ((OCSP_SINGLERESP *)sk_value(((_STACK*) (1 ? (rd->responses) : (struct stack_st_OCSP_SINGLERESP*)0)), (i))); | - | ||||||
210 | cid = single->certId; | - | ||||||
211 | if (ocsp_certid_print(bp, cid, 4) <= 0
| 0 | ||||||
212 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
213 | cst = single->certStatus; | - | ||||||
214 | if (BIO_printf(bp, " Cert Status: %s",
| 0 | ||||||
215 | OCSP_cert_status_str(cst->type)) <= 0
| 0 | ||||||
216 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
217 | if (cst->type == 1
| 0 | ||||||
218 | rev = cst->value.revoked; | - | ||||||
219 | if (BIO_printf(bp, "\n Revocation Time: ") <= 0
| 0 | ||||||
220 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
221 | if (!ASN1_GENERALIZEDTIME_print(bp,
| 0 | ||||||
222 | rev->revocationTime)
| 0 | ||||||
223 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
224 | if (rev->revocationReason
| 0 | ||||||
225 | l = ASN1_ENUMERATED_get(rev->revocationReason); | - | ||||||
226 | if (BIO_printf(bp,
| 0 | ||||||
227 | "\n Revocation Reason: %s (0x%lx)",
| 0 | ||||||
228 | OCSP_crl_reason_str(l), l) <= 0
| 0 | ||||||
229 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
230 | } never executed: end of block | 0 | ||||||
231 | } never executed: end of block | 0 | ||||||
232 | if (BIO_printf(bp, "\n This Update: ") <= 0
| 0 | ||||||
233 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
234 | if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)
| 0 | ||||||
235 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
236 | if (single->nextUpdate
| 0 | ||||||
237 | if (BIO_printf(bp, "\n Next Update: ") <= 0
| 0 | ||||||
238 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
239 | if (!ASN1_GENERALIZEDTIME_print(bp, single->nextUpdate)
| 0 | ||||||
240 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
241 | } never executed: end of block | 0 | ||||||
242 | if (BIO_write(bp, "\n", 1) <= 0
| 0 | ||||||
243 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
244 | if (!X509V3_extensions_print(bp, "Response Single Extensions",
| 0 | ||||||
245 | single->singleExtensions, flags, 8)
| 0 | ||||||
246 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
247 | if (BIO_write(bp, "\n", 1) <= 0
| 0 | ||||||
248 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
249 | } never executed: end of block | 0 | ||||||
250 | if (!X509V3_extensions_print(bp, "Response Extensions",
| 0 | ||||||
251 | rd->responseExtensions, flags, 4)
| 0 | ||||||
252 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
253 | if (X509_signature_print(bp, br->signatureAlgorithm, br->signature) <=
| 0 | ||||||
254 | 0
| 0 | ||||||
255 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||
256 | - | |||||||
257 | for (i = 0; i < sk_num(((_STACK*) (1 ? (br->certs) : (struct stack_st_X509*)0)))
| 0 | ||||||
258 | X509_print(bp, ((X509 *)sk_value(((_STACK*) (1 ? (br->certs) : (struct stack_st_X509*)0)), (i)))); | - | ||||||
259 | PEM_write_bio_X509(bp, ((X509 *)sk_value(((_STACK*) (1 ? (br->certs) : (struct stack_st_X509*)0)), (i)))); | - | ||||||
260 | } never executed: end of block | 0 | ||||||
261 | - | |||||||
262 | ret = 1; | - | ||||||
263 | - | |||||||
264 | err: code before this statement never executed: err: | 0 | ||||||
265 | OCSP_BASICRESP_free(br); | - | ||||||
266 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||
267 | } | - | ||||||
Switch to Source code | Preprocessed file |