OpenCoverage

ocsp_prn.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ocsp/ocsp_prn.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2static 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: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2
16}-
17-
18typedef struct {-
19 long t;-
20 const char *m;-
21} OCSP_TBLSTR;-
22-
23static const char *do_table2string(long s, const OCSP_TBLSTR *ts, size_t len)-
24{-
25 size_t i;-
26 for (i = 0; i < len
i < lenDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
; i++, ts++)
0-4
27 if (ts->t == s
ts->t == sDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-4
28 return
executed 4 times by 1 test: return ts->m;
Executed by:
  • libcrypto.so.1.1
ts->m;
executed 4 times by 1 test: return ts->m;
Executed by:
  • libcrypto.so.1.1
4
29 return
never executed: return "(UNKNOWN)";
"(UNKNOWN)";
never executed: return "(UNKNOWN)";
0
30}-
31-
32-
33-
34const 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: return do_table2string(s, rstat_tbl, (sizeof(rstat_tbl)/sizeof((rstat_tbl)[0])));
Executed by:
  • libcrypto.so.1.1
do_table2string(s, rstat_tbl, (sizeof(rstat_tbl)/sizeof((rstat_tbl)[0])));
executed 2 times by 1 test: return do_table2string(s, rstat_tbl, (sizeof(rstat_tbl)/sizeof((rstat_tbl)[0])));
Executed by:
  • libcrypto.so.1.1
2
45}-
46-
47const 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: return do_table2string(s, cstat_tbl, (sizeof(cstat_tbl)/sizeof((cstat_tbl)[0])));
Executed by:
  • libcrypto.so.1.1
do_table2string(s, cstat_tbl, (sizeof(cstat_tbl)/sizeof((cstat_tbl)[0])));
executed 2 times by 1 test: return do_table2string(s, cstat_tbl, (sizeof(cstat_tbl)/sizeof((cstat_tbl)[0])));
Executed by:
  • libcrypto.so.1.1
2
55}-
56-
57const 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: return do_table2string(s, reason_tbl, (sizeof(reason_tbl)/sizeof((reason_tbl)[0])));
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-
72int 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
BIO_write(bp, ...:\n", 19) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
86 goto
never executed: goto err;
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
BIO_printf(bp,...l + 1, l) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
89 goto
never executed: goto err;
err;
never executed: goto err;
0
90 if (inf->requestorName !=
inf->requestor...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
91 ((void *)0)
inf->requestor...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
92 ) {-
93 if (BIO_write(bp, "\n Requestor Name: ", 21) <= 0
BIO_write(bp, ...e: ", 21) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
94 goto
never executed: goto err;
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
BIO_write(bp, ...:\n", 21) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
98 goto
never executed: goto err;
err;
never executed: goto err;
0
99 for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList)
i < sk_OCSP_ON...->requestList)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
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,
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEnever evaluated
0
104 "Request Single Extensions",
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEnever evaluated
0
105 one->singleRequestExtensions, flags, 8)
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
106 goto
never executed: goto err;
err;
never executed: goto err;
0
107 }
never executed: end of block
0
108 if (!X509V3_extensions_print(bp, "Request Extensions",
!X509V3_extens...ons, flags, 4)Description
TRUEnever evaluated
FALSEnever evaluated
0
109 inf->requestExtensions, flags, 4)
!X509V3_extens...ons, flags, 4)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
110 goto
never executed: goto err;
err;
never executed: goto err;
0
111 if (sig
sigDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 X509_signature_print(bp, &sig->signatureAlgorithm, sig->signature);-
113 for (i = 0; i < sk_X509_num(sig->certs)
i < sk_X509_num(sig->certs)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
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: return 1;
1;
never executed: return 1;
0
119 err:-
120 return
never executed: return 0;
0;
never executed: return 0;
0
121}-
122-
123int 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
BIO_puts(bp, "...Data:\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
151 goto
never executed: goto err;
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",
BIO_printf(bp,...tr(l), l) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
154 OCSP_response_status_str(l), l) <= 0
BIO_printf(bp,...tr(l), l) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
155 goto
never executed: goto err;
err;
never executed: goto err;
0
156 if (rb ==
rb == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
157 ((void *)0)
rb == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
158 )-
159 return
never executed: return 1;
1;
never executed: return 1;
0
160 if (BIO_puts(bp, " Response Type: ") <= 0
BIO_puts(bp, "... Type: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
161 goto
never executed: goto err;
err;
never executed: goto err;
0
162 if (i2a_ASN1_OBJECT(bp, rb->responseType) <= 0
i2a_ASN1_OBJEC...onseType) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
163 goto
never executed: goto err;
err;
never executed: goto err;
0
164 if (OBJ_obj2nid(rb->responseType) != 365
OBJ_obj2nid(rb...seType) != 365Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-2
165 BIO_puts(bp, " (unknown response type)\n");-
166 return
never executed: return 1;
1;
never executed: return 1;
0
167 }-
168-
169 if ((
(br = OCSP_res...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
br = OCSP_response_get1_basic(o)) ==
(br = OCSP_res...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
170 ((void *)0)
(br = OCSP_res...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
171 )-
172 goto
never executed: goto err;
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
BIO_printf(bp,...l + 1, l) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
176 goto
never executed: goto err;
err;
never executed: goto err;
0
177 if (BIO_puts(bp, " Responder Id: ") <= 0
BIO_puts(bp, "...er Id: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
178 goto
never executed: goto err;
err;
never executed: goto err;
0
179-
180 rid = &rd->responderId;-
181 switch (rid->type) {-
182 case
executed 2 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
0:
executed 2 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
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:
  • libcrypto.so.1.1
2
185 case
never executed: case 1:
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
BIO_printf(bp,...ed At: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
191 goto
never executed: goto err;
err;
never executed: goto err;
0
192 if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)
!ASN1_GENERALI...d->producedAt)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
193 goto
never executed: goto err;
err;
never executed: goto err;
0
194 if (BIO_printf(bp, "\n Responses:\n") <= 0
BIO_printf(bp,...nses:\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
195 goto
never executed: goto err;
err;
never executed: goto err;
0
196 for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses)
i < sk_OCSP_SI...rd->responses)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
2
197 if (!sk_OCSP_SINGLERESP_value(rd->responses, i)
!sk_OCSP_SINGL...>responses, i)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
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
ocsp_certid_pr..., cid, 4) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
202 goto
never executed: goto err;
err;
never executed: goto err;
0
203 cst = single->certStatus;-
204 if (BIO_printf(bp, " Cert Status: %s",
BIO_printf(bp,...t->type)) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
205 OCSP_cert_status_str(cst->type)) <= 0
BIO_printf(bp,...t->type)) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
206 goto
never executed: goto err;
err;
never executed: goto err;
0
207 if (cst->type == 1
cst->type == 1Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-2
208 rev = cst->value.revoked;-
209 if (BIO_printf(bp, "\n Revocation Time: ") <= 0
BIO_printf(bp,... Time: ") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
210 goto
never executed: goto err;
err;
never executed: goto err;
0
211 if (!ASN1_GENERALIZEDTIME_print(bp, rev->revocationTime)
!ASN1_GENERALI...evocationTime)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
212 goto
never executed: goto err;
err;
never executed: goto err;
0
213 if (rev->revocationReason
rev->revocationReasonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
214 l = ASN1_ENUMERATED_get(rev->revocationReason);-
215 if (BIO_printf(bp,
BIO_printf(bp,...tr(l), l) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
216 "\n Revocation Reason: %s (0x%lx)",
BIO_printf(bp,...tr(l), l) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
217 OCSP_crl_reason_str(l), l) <= 0
BIO_printf(bp,...tr(l), l) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
218 goto
never executed: goto err;
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
BIO_printf(bp,...pdate: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
222 goto
never executed: goto err;
err;
never executed: goto err;
0
223 if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)
!ASN1_GENERALI...e->thisUpdate)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
224 goto
never executed: goto err;
err;
never executed: goto err;
0
225 if (single->nextUpdate
single->nextUpdateDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-2
226 if (BIO_printf(bp, "\n Next Update: ") <= 0
BIO_printf(bp,...pdate: ") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
227 goto
never executed: goto err;
err;
never executed: goto err;
0
228 if (!ASN1_GENERALIZEDTIME_print(bp, single->nextUpdate)
!ASN1_GENERALI...e->nextUpdate)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
229 goto
never executed: goto err;
err;
never executed: goto err;
0
230 }
never executed: end of block
0
231 if (BIO_write(bp, "\n", 1) <= 0
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
232 goto
never executed: goto err;
err;
never executed: goto err;
0
233 if (!X509V3_extensions_print(bp,
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
234 "Response Single Extensions",
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
235 single->singleExtensions, flags, 8)
!X509V3_extens...ons, flags, 8)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
236 goto
never executed: goto err;
err;
never executed: goto err;
0
237 if (BIO_write(bp, "\n", 1) <= 0
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
238 goto
never executed: goto err;
err;
never executed: goto err;
0
239 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
240 if (!X509V3_extensions_print(bp, "Response Extensions",
!X509V3_extens...ons, flags, 4)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
241 rd->responseExtensions, flags, 4)
!X509V3_extens...ons, flags, 4)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
242 goto
never executed: goto err;
err;
never executed: goto err;
0
243 if (X509_signature_print(bp, &br->signatureAlgorithm, br->signature) <= 0
X509_signature...ignature) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
244 goto
never executed: goto err;
err;
never executed: goto err;
0
245-
246 for (i = 0; i < sk_X509_num(br->certs)
i < sk_X509_num(br->certs)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
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:
  • libcrypto.so.1.1
2
250-
251 ret = 1;-
252 err:
code before this statement executed 2 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
2
253 OCSP_BASICRESP_free(br);-
254 return
executed 2 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 2 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
2
255}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2