OpenCoverage

ct_oct.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ct/ct_oct.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#ifdef OPENSSL_NO_CT-
11# error "CT is disabled"-
12#endif-
13-
14#include <limits.h>-
15#include <string.h>-
16-
17#include <openssl/asn1.h>-
18#include <openssl/buffer.h>-
19#include <openssl/ct.h>-
20#include <openssl/err.h>-
21-
22#include "ct_locl.h"-
23-
24int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len)-
25{-
26 size_t siglen;-
27 size_t len_remaining = len;-
28 const unsigned char *p;-
29-
30 if (sct->version != SCT_VERSION_V1) {
sct->version != SCT_VERSION_V1Description
TRUEnever evaluated
FALSEevaluated 3007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3007
31 CTerr(CT_F_O2I_SCT_SIGNATURE, CT_R_UNSUPPORTED_VERSION);-
32 return -1;
never executed: return -1;
0
33 }-
34 /*-
35 * digitally-signed struct header: (1 byte) Hash algorithm (1 byte)-
36 * Signature algorithm (2 bytes + ?) Signature-
37 *-
38 * This explicitly rejects empty signatures: they're invalid for-
39 * all supported algorithms.-
40 */-
41 if (len <= 4) {
len <= 4Description
TRUEevaluated 475 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2532 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
475-2532
42 CTerr(CT_F_O2I_SCT_SIGNATURE, CT_R_SCT_INVALID_SIGNATURE);-
43 return -1;
executed 475 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
475
44 }-
45-
46 p = *in;-
47 /* Get hash and signature algorithm */-
48 sct->hash_alg = *p++;-
49 sct->sig_alg = *p++;-
50 if (SCT_get_signature_nid(sct) == NID_undef) {
SCT_get_signat..._nid(sct) == 0Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2435 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
97-2435
51 CTerr(CT_F_O2I_SCT_SIGNATURE, CT_R_SCT_INVALID_SIGNATURE);-
52 return -1;
executed 97 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
97
53 }-
54 /* Retrieve signature and check it is consistent with the buffer length */-
55 n2s(p, siglen);-
56 len_remaining -= (p - *in);-
57 if (siglen > len_remaining) {
siglen > len_remainingDescription
TRUEevaluated 73 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2362 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
73-2362
58 CTerr(CT_F_O2I_SCT_SIGNATURE, CT_R_SCT_INVALID_SIGNATURE);-
59 return -1;
executed 73 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
73
60 }-
61-
62 if (SCT_set1_signature(sct, p, siglen) != 1)
SCT_set1_signa..., siglen) != 1Description
TRUEnever evaluated
FALSEevaluated 2362 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2362
63 return -1;
never executed: return -1;
0
64 len_remaining -= siglen;-
65 *in = p + siglen;-
66-
67 return len - len_remaining;
executed 2362 times by 1 test: return len - len_remaining;
Executed by:
  • libcrypto.so.1.1
2362
68}-
69-
70SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len)-
71{-
72 SCT *sct = NULL;-
73 const unsigned char *p;-
74-
75 if (len == 0 || len > MAX_SCT_SIZE) {
len == 0Description
TRUEnever evaluated
FALSEevaluated 14202 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
len > 65535Description
TRUEnever evaluated
FALSEevaluated 14202 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14202
76 CTerr(CT_F_O2I_SCT, CT_R_SCT_INVALID);-
77 goto err;
never executed: goto err;
0
78 }-
79-
80 if ((sct = SCT_new()) == NULL)
(sct = SCT_new...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14202 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14202
81 goto err;
never executed: goto err;
0
82-
83 p = *in;-
84-
85 sct->version = *p;-
86 if (sct->version == SCT_VERSION_V1) {
sct->version == SCT_VERSION_V1Description
TRUEevaluated 3365 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10837 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3365-10837
87 int sig_len;-
88 size_t len2;-
89 /*--
90 * Fixed-length header:-
91 * struct {-
92 * Version sct_version; (1 byte)-
93 * log_id id; (32 bytes)-
94 * uint64 timestamp; (8 bytes)-
95 * CtExtensions extensions; (2 bytes + ?)-
96 * }-
97 */-
98 if (len < 43) {
len < 43Description
TRUEevaluated 267 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3098 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
267-3098
99 CTerr(CT_F_O2I_SCT, CT_R_SCT_INVALID);-
100 goto err;
executed 267 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
267
101 }-
102 len -= 43;-
103 p++;-
104 sct->log_id = BUF_memdup(p, CT_V1_HASHLEN);-
105 if (sct->log_id == NULL)
sct->log_id == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3098 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3098
106 goto err;
never executed: goto err;
0
107 sct->log_id_len = CT_V1_HASHLEN;-
108 p += CT_V1_HASHLEN;-
109-
110 n2l8(p, sct->timestamp);-
111-
112 n2s(p, len2);-
113 if (len < len2) {
len < len2Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
92-3006
114 CTerr(CT_F_O2I_SCT, CT_R_SCT_INVALID);-
115 goto err;
executed 92 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
92
116 }-
117 if (len2 > 0) {
len2 > 0Description
TRUEevaluated 597 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2409 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
597-2409
118 sct->ext = BUF_memdup(p, len2);-
119 if (sct->ext == NULL)
sct->ext == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 597 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-597
120 goto err;
never executed: goto err;
0
121 }
executed 597 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
597
122 sct->ext_len = len2;-
123 p += len2;-
124 len -= len2;-
125-
126 sig_len = o2i_SCT_signature(sct, &p, len);-
127 if (sig_len <= 0) {
sig_len <= 0Description
TRUEevaluated 645 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
645-2361
128 CTerr(CT_F_O2I_SCT, CT_R_SCT_INVALID);-
129 goto err;
executed 645 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
645
130 }-
131 len -= sig_len;-
132 *in = p + len;-
133 } else {
executed 2361 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2361
134 /* If not V1 just cache encoding */-
135 sct->sct = BUF_memdup(p, len);-
136 if (sct->sct == NULL)
sct->sct == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10837 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10837
137 goto err;
never executed: goto err;
0
138 sct->sct_len = len;-
139 *in = p + len;-
140 }
executed 10837 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10837
141-
142 if (psct != NULL) {
psct != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13198 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13198
143 SCT_free(*psct);-
144 *psct = sct;-
145 }
never executed: end of block
0
146-
147 return sct;
executed 13198 times by 1 test: return sct;
Executed by:
  • libcrypto.so.1.1
13198
148err:-
149 SCT_free(sct);-
150 return NULL;
executed 1004 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1004
151}-
152-
153int i2o_SCT_signature(const SCT *sct, unsigned char **out)-
154{-
155 size_t len;-
156 unsigned char *p = NULL, *pstart = NULL;-
157-
158 if (!SCT_signature_is_complete(sct)) {
!SCT_signature..._complete(sct)Description
TRUEnever evaluated
FALSEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-549
159 CTerr(CT_F_I2O_SCT_SIGNATURE, CT_R_SCT_INVALID_SIGNATURE);-
160 goto err;
never executed: goto err;
0
161 }-
162-
163 if (sct->version != SCT_VERSION_V1) {
sct->version != SCT_VERSION_V1Description
TRUEnever evaluated
FALSEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-549
164 CTerr(CT_F_I2O_SCT_SIGNATURE, CT_R_UNSUPPORTED_VERSION);-
165 goto err;
never executed: goto err;
0
166 }-
167-
168 /*-
169 * (1 byte) Hash algorithm-
170 * (1 byte) Signature algorithm-
171 * (2 bytes + ?) Signature-
172 */-
173 len = 4 + sct->sig_len;-
174-
175 if (out != NULL) {
out != ((void *)0)Description
TRUEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-549
176 if (*out != NULL) {
*out != ((void *)0)Description
TRUEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-549
177 p = *out;-
178 *out += len;-
179 } else {
executed 549 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
549
180 pstart = p = OPENSSL_malloc(len);-
181 if (p == NULL) {
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
182 CTerr(CT_F_I2O_SCT_SIGNATURE, ERR_R_MALLOC_FAILURE);-
183 goto err;
never executed: goto err;
0
184 }-
185 *out = p;-
186 }
never executed: end of block
0
187-
188 *p++ = sct->hash_alg;-
189 *p++ = sct->sig_alg;-
190 s2n(sct->sig_len, p);-
191 memcpy(p, sct->sig, sct->sig_len);-
192 }
executed 549 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
549
193-
194 return len;
executed 549 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
549
195err:-
196 OPENSSL_free(pstart);-
197 return -1;
never executed: return -1;
0
198}-
199-
200int i2o_SCT(const SCT *sct, unsigned char **out)-
201{-
202 size_t len;-
203 unsigned char *p = NULL, *pstart = NULL;-
204-
205 if (!SCT_is_complete(sct)) {
!SCT_is_complete(sct)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9985 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-9985
206 CTerr(CT_F_I2O_SCT, CT_R_SCT_NOT_SET);-
207 goto err;
executed 20 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
20
208 }-
209 /*-
210 * Fixed-length header: struct { (1 byte) Version sct_version; (32 bytes)-
211 * log_id id; (8 bytes) uint64 timestamp; (2 bytes + ?) CtExtensions-
212 * extensions; (1 byte) Hash algorithm (1 byte) Signature algorithm (2-
213 * bytes + ?) Signature-
214 */-
215 if (sct->version == SCT_VERSION_V1)
sct->version == SCT_VERSION_V1Description
TRUEevaluated 1125 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8860 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1125-8860
216 len = 43 + sct->ext_len + 4 + sct->sig_len;
executed 1125 times by 1 test: len = 43 + sct->ext_len + 4 + sct->sig_len;
Executed by:
  • libcrypto.so.1.1
1125
217 else-
218 len = sct->sct_len;
executed 8860 times by 1 test: len = sct->sct_len;
Executed by:
  • libcrypto.so.1.1
8860
219-
220 if (out == NULL)
out == ((void *)0)Description
TRUEevaluated 5035 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4950 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4950-5035
221 return len;
executed 5035 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
5035
222-
223 if (*out != NULL) {
*out != ((void *)0)Description
TRUEevaluated 4950 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4950
224 p = *out;-
225 *out += len;-
226 } else {
executed 4950 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4950
227 pstart = p = OPENSSL_malloc(len);-
228 if (p == NULL) {
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
229 CTerr(CT_F_I2O_SCT, ERR_R_MALLOC_FAILURE);-
230 goto err;
never executed: goto err;
0
231 }-
232 *out = p;-
233 }
never executed: end of block
0
234-
235 if (sct->version == SCT_VERSION_V1) {
sct->version == SCT_VERSION_V1Description
TRUEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4401 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
549-4401
236 *p++ = sct->version;-
237 memcpy(p, sct->log_id, CT_V1_HASHLEN);-
238 p += CT_V1_HASHLEN;-
239 l2n8(sct->timestamp, p);-
240 s2n(sct->ext_len, p);-
241 if (sct->ext_len > 0) {
sct->ext_len > 0Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 460 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
89-460
242 memcpy(p, sct->ext, sct->ext_len);-
243 p += sct->ext_len;-
244 }
executed 89 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
89
245 if (i2o_SCT_signature(sct, &p) <= 0)
i2o_SCT_signat...(sct, &p) <= 0Description
TRUEnever evaluated
FALSEevaluated 549 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-549
246 goto err;
never executed: goto err;
0
247 } else {
executed 549 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
549
248 memcpy(p, sct->sct, len);-
249 }
executed 4401 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4401
250-
251 return len;
executed 4950 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
4950
252err:-
253 OPENSSL_free(pstart);-
254 return -1;
executed 20 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
20
255}-
256-
257STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,-
258 size_t len)-
259{-
260 STACK_OF(SCT) *sk = NULL;-
261 size_t list_len, sct_len;-
262-
263 if (len < 2 || len > MAX_SCT_LIST_SIZE) {
len < 2Description
TRUEevaluated 410 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5121 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
len > 65535Description
TRUEnever evaluated
FALSEevaluated 5121 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5121
264 CTerr(CT_F_O2I_SCT_LIST, CT_R_SCT_LIST_INVALID);-
265 return NULL;
executed 410 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
410
266 }-
267-
268 n2s(*pp, list_len);-
269 if (list_len != len - 2) {
list_len != len - 2Description
TRUEevaluated 428 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4693 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
428-4693
270 CTerr(CT_F_O2I_SCT_LIST, CT_R_SCT_LIST_INVALID);-
271 return NULL;
executed 428 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
428
272 }-
273-
274 if (a == NULL || *a == NULL) {
a == ((void *)0)Description
TRUEevaluated 4692 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
*a == ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4692
275 sk = sk_SCT_new_null();-
276 if (sk == NULL)
sk == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4693 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4693
277 return NULL;
never executed: return ((void *)0) ;
0
278 } else {
executed 4693 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4693
279 SCT *sct;-
280-
281 /* Use the given stack, but empty it first. */-
282 sk = *a;-
283 while ((sct = sk_SCT_pop(sk)) != NULL)
(sct = sk_SCT_...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
284 SCT_free(sct);
never executed: SCT_free(sct);
0
285 }
never executed: end of block
0
286-
287 while (list_len > 0) {
list_len > 0Description
TRUEevaluated 15150 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2741 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2741-15150
288 SCT *sct;-
289-
290 if (list_len < 2) {
list_len < 2Description
TRUEevaluated 395 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14755 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
395-14755
291 CTerr(CT_F_O2I_SCT_LIST, CT_R_SCT_LIST_INVALID);-
292 goto err;
executed 395 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
395
293 }-
294 n2s(*pp, sct_len);-
295 list_len -= 2;-
296-
297 if (sct_len == 0 || sct_len > list_len) {
sct_len == 0Description
TRUEevaluated 134 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14621 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sct_len > list_lenDescription
TRUEevaluated 419 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14202 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
134-14621
298 CTerr(CT_F_O2I_SCT_LIST, CT_R_SCT_LIST_INVALID);-
299 goto err;
executed 553 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
553
300 }-
301 list_len -= sct_len;-
302-
303 if ((sct = o2i_SCT(NULL, pp, sct_len)) == NULL)
(sct = o2i_SCT...== ((void *)0)Description
TRUEevaluated 1004 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13198 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1004-13198
304 goto err;
executed 1004 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1004
305 if (!sk_SCT_push(sk, sct)) {
!sk_SCT_push(sk, sct)Description
TRUEnever evaluated
FALSEevaluated 13198 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13198
306 SCT_free(sct);-
307 goto err;
never executed: goto err;
0
308 }-
309 }
executed 13198 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
13198
310-
311 if (a != NULL && *a == NULL)
a != ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2740 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*a == ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2740
312 *a = sk;
executed 1 time by 1 test: *a = sk;
Executed by:
  • libcrypto.so.1.1
1
313 return sk;
executed 2741 times by 1 test: return sk;
Executed by:
  • libcrypto.so.1.1
2741
314-
315 err:-
316 if (a == NULL || *a == NULL)
a == ((void *)0)Description
TRUEevaluated 1952 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
*a == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0-1952
317 SCT_LIST_free(sk);
executed 1952 times by 1 test: SCT_LIST_free(sk);
Executed by:
  • libcrypto.so.1.1
1952
318 return NULL;
executed 1952 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1952
319}-
320-
321int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp)-
322{-
323 int len, sct_len, i, is_pp_new = 0;-
324 size_t len2;-
325 unsigned char *p = NULL, *p2;-
326-
327 if (pp != NULL) {
pp != ((void *)0)Description
TRUEevaluated 104 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 104 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
104
328 if (*pp == NULL) {
*pp == ((void *)0)Description
TRUEevaluated 104 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-104
329 if ((len = i2o_SCT_LIST(a, NULL)) == -1) {
(len = i2o_SCT... *)0) )) == -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-84
330 CTerr(CT_F_I2O_SCT_LIST, CT_R_SCT_LIST_INVALID);-
331 return -1;
executed 20 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
20
332 }-
333 if ((*pp = OPENSSL_malloc(len)) == NULL) {
(*pp = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-84
334 CTerr(CT_F_I2O_SCT_LIST, ERR_R_MALLOC_FAILURE);-
335 return -1;
never executed: return -1;
0
336 }-
337 is_pp_new = 1;-
338 }
executed 84 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
84
339 p = *pp + 2;-
340 }
executed 84 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
84
341-
342 len2 = 2;-
343 for (i = 0; i < sk_SCT_num(a); i++) {
i < sk_SCT_num(a)Description
TRUEevaluated 10005 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 168 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
168-10005
344 if (pp != NULL) {
pp != ((void *)0)Description
TRUEevaluated 4950 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5055 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4950-5055
345 p2 = p;-
346 p += 2;-
347 if ((sct_len = i2o_SCT(sk_SCT_value(a, i), &p)) == -1)
(sct_len = i2o...i), &p)) == -1Description
TRUEnever evaluated
FALSEevaluated 4950 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4950
348 goto err;
never executed: goto err;
0
349 s2n(sct_len, p2);-
350 } else {
executed 4950 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4950
351 if ((sct_len = i2o_SCT(sk_SCT_value(a, i), NULL)) == -1)
(sct_len = i2o... *)0) )) == -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5035 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-5035
352 goto err;
executed 20 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
20
353 }
executed 5035 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5035
354 len2 += 2 + sct_len;-
355 }
executed 9985 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
9985
356-
357 if (len2 > MAX_SCT_LIST_SIZE)
len2 > 65535Description
TRUEnever evaluated
FALSEevaluated 168 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-168
358 goto err;
never executed: goto err;
0
359-
360 if (pp != NULL) {
pp != ((void *)0)Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
84
361 p = *pp;-
362 s2n(len2 - 2, p);-
363 if (!is_pp_new)
!is_pp_newDescription
TRUEnever evaluated
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-84
364 *pp += len2;
never executed: *pp += len2;
0
365 }
executed 84 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
84
366 return len2;
executed 168 times by 1 test: return len2;
Executed by:
  • libcrypto.so.1.1
168
367-
368 err:-
369 if (is_pp_new) {
is_pp_newDescription
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-20
370 OPENSSL_free(*pp);-
371 *pp = NULL;-
372 }
never executed: end of block
0
373 return -1;
executed 20 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
20
374}-
375-
376STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,-
377 long len)-
378{-
379 ASN1_OCTET_STRING *oct = NULL;-
380 STACK_OF(SCT) *sk = NULL;-
381 const unsigned char *p;-
382-
383 p = *pp;-
384 if (d2i_ASN1_OCTET_STRING(&oct, &p, len) == NULL)
d2i_ASN1_OCTET...== ((void *)0)Description
TRUEevaluated 959 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5528 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
959-5528
385 return NULL;
executed 959 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
959
386-
387 p = oct->data;-
388 if ((sk = o2i_SCT_LIST(a, &p, oct->length)) != NULL)
(sk = o2i_SCT_...!= ((void *)0)Description
TRUEevaluated 2739 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2789 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2739-2789
389 *pp += len;
executed 2739 times by 1 test: *pp += len;
Executed by:
  • libcrypto.so.1.1
2739
390-
391 ASN1_OCTET_STRING_free(oct);-
392 return sk;
executed 5528 times by 1 test: return sk;
Executed by:
  • libcrypto.so.1.1
5528
393}-
394-
395int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **out)-
396{-
397 ASN1_OCTET_STRING oct;-
398 int len;-
399-
400 oct.data = NULL;-
401 if ((oct.length = i2o_SCT_LIST(a, &oct.data)) == -1)
(oct.length = ...t.data)) == -1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 83 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-83
402 return -1;
executed 20 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
20
403-
404 len = i2d_ASN1_OCTET_STRING(&oct, out);-
405 OPENSSL_free(oct.data);-
406 return len;
executed 83 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
83
407}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2