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