Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/asn1_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||
3 | static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max); | - | ||||||||||||||||||||||||||||||||||||
4 | static void asn1_put_length(unsigned char **pp, int length); | - | ||||||||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||||||||
6 | static int | - | ||||||||||||||||||||||||||||||||||||
7 | _asn1_check_infinite_end(const unsigned char **p, long len) | - | ||||||||||||||||||||||||||||||||||||
8 | { | - | ||||||||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||||||||
11 | if (len <= 0
| 0 | ||||||||||||||||||||||||||||||||||||
12 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||||||||
13 | else if ((
| 0 | ||||||||||||||||||||||||||||||||||||
14 | (*p) += 2; | - | ||||||||||||||||||||||||||||||||||||
15 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||||||||
16 | } | - | ||||||||||||||||||||||||||||||||||||
17 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
18 | } | - | ||||||||||||||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||||||||||||||
20 | int | - | ||||||||||||||||||||||||||||||||||||
21 | ASN1_check_infinite_end(unsigned char **p, long len) | - | ||||||||||||||||||||||||||||||||||||
22 | { | - | ||||||||||||||||||||||||||||||||||||
23 | return never executed: _asn1_check_infinite_end((const unsigned char **)p, len);return _asn1_check_infinite_end((const unsigned char **)p, len); never executed: return _asn1_check_infinite_end((const unsigned char **)p, len); | 0 | ||||||||||||||||||||||||||||||||||||
24 | } | - | ||||||||||||||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||||||||||||||
26 | int | - | ||||||||||||||||||||||||||||||||||||
27 | ASN1_const_check_infinite_end(const unsigned char **p, long len) | - | ||||||||||||||||||||||||||||||||||||
28 | { | - | ||||||||||||||||||||||||||||||||||||
29 | return never executed: _asn1_check_infinite_end(p, len);return _asn1_check_infinite_end(p, len); never executed: return _asn1_check_infinite_end(p, len); | 0 | ||||||||||||||||||||||||||||||||||||
30 | } | - | ||||||||||||||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||||||||||||||
32 | int | - | ||||||||||||||||||||||||||||||||||||
33 | ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, | - | ||||||||||||||||||||||||||||||||||||
34 | int *pclass, long omax) | - | ||||||||||||||||||||||||||||||||||||
35 | { | - | ||||||||||||||||||||||||||||||||||||
36 | int i, ret; | - | ||||||||||||||||||||||||||||||||||||
37 | long l; | - | ||||||||||||||||||||||||||||||||||||
38 | const unsigned char *p= *pp; | - | ||||||||||||||||||||||||||||||||||||
39 | int tag, xclass, inf; | - | ||||||||||||||||||||||||||||||||||||
40 | long max = omax; | - | ||||||||||||||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||||||||||||||
42 | if (!max
| 0-19196 | ||||||||||||||||||||||||||||||||||||
43 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
44 | ret = (*p & 0x20); | - | ||||||||||||||||||||||||||||||||||||
45 | xclass = (*p & 0xc0); | - | ||||||||||||||||||||||||||||||||||||
46 | i= *p & 0x1f; | - | ||||||||||||||||||||||||||||||||||||
47 | if (i == 0x1f
| 0-19196 | ||||||||||||||||||||||||||||||||||||
48 | p++; | - | ||||||||||||||||||||||||||||||||||||
49 | if (--
| 0 | ||||||||||||||||||||||||||||||||||||
50 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
51 | l = 0; | - | ||||||||||||||||||||||||||||||||||||
52 | while (*
| 0 | ||||||||||||||||||||||||||||||||||||
53 | l <<= 7L; | - | ||||||||||||||||||||||||||||||||||||
54 | l |= *(p++) & 0x7f; | - | ||||||||||||||||||||||||||||||||||||
55 | if (--
| 0 | ||||||||||||||||||||||||||||||||||||
56 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
57 | if (l > (0x7fffffff >> 7L)
| 0 | ||||||||||||||||||||||||||||||||||||
58 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
59 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
60 | l <<= 7L; | - | ||||||||||||||||||||||||||||||||||||
61 | l |= *(p++) & 0x7f; | - | ||||||||||||||||||||||||||||||||||||
62 | tag = (int)l; | - | ||||||||||||||||||||||||||||||||||||
63 | if (--
| 0 | ||||||||||||||||||||||||||||||||||||
64 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
65 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||
66 | tag = i; | - | ||||||||||||||||||||||||||||||||||||
67 | p++; | - | ||||||||||||||||||||||||||||||||||||
68 | if (--
| 0-19196 | ||||||||||||||||||||||||||||||||||||
69 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
70 | } executed 19196 times by 12 tests: end of block Executed by:
| 19196 | ||||||||||||||||||||||||||||||||||||
71 | *ptag = tag; | - | ||||||||||||||||||||||||||||||||||||
72 | *pclass = xclass; | - | ||||||||||||||||||||||||||||||||||||
73 | if (!asn1_get_length(&p, &inf, plength, (int)max)
| 0-19196 | ||||||||||||||||||||||||||||||||||||
74 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||||||||
76 | if (inf
| 0-19196 | ||||||||||||||||||||||||||||||||||||
77 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||||||||||||||
79 | if (*
| 76-19120 | ||||||||||||||||||||||||||||||||||||
80 | ERR_put_error(13,(0xfff),(155),__FILE__,143); | - | ||||||||||||||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||||||||||||||
83 | ret |= 0x80; | - | ||||||||||||||||||||||||||||||||||||
84 | } executed 76 times by 1 test: end of block Executed by:
| 76 | ||||||||||||||||||||||||||||||||||||
85 | *pp = p; | - | ||||||||||||||||||||||||||||||||||||
86 | return executed 19196 times by 12 tests: (ret | inf);return (ret | inf); Executed by:
executed 19196 times by 12 tests: return (ret | inf); Executed by:
| 19196 | ||||||||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||||||||
88 | err: | - | ||||||||||||||||||||||||||||||||||||
89 | ERR_put_error(13,(0xfff),(123),__FILE__,152); | - | ||||||||||||||||||||||||||||||||||||
90 | return never executed: (0x80);return (0x80); never executed: return (0x80); | 0 | ||||||||||||||||||||||||||||||||||||
91 | } | - | ||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||
93 | static int | - | ||||||||||||||||||||||||||||||||||||
94 | asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max) | - | ||||||||||||||||||||||||||||||||||||
95 | { | - | ||||||||||||||||||||||||||||||||||||
96 | const unsigned char *p= *pp; | - | ||||||||||||||||||||||||||||||||||||
97 | unsigned long ret = 0; | - | ||||||||||||||||||||||||||||||||||||
98 | unsigned int i; | - | ||||||||||||||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||||||||||||||
100 | if (max-- < 1
| 0-19196 | ||||||||||||||||||||||||||||||||||||
101 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
102 | if (*
| 0-19196 | ||||||||||||||||||||||||||||||||||||
103 | *inf = 1; | - | ||||||||||||||||||||||||||||||||||||
104 | ret = 0; | - | ||||||||||||||||||||||||||||||||||||
105 | p++; | - | ||||||||||||||||||||||||||||||||||||
106 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||
107 | *inf = 0; | - | ||||||||||||||||||||||||||||||||||||
108 | i= *p & 0x7f; | - | ||||||||||||||||||||||||||||||||||||
109 | if (*(
| 2372-16824 | ||||||||||||||||||||||||||||||||||||
110 | if (max < (int)i
| 0-2372 | ||||||||||||||||||||||||||||||||||||
111 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||||||||||||||
113 | while (i
| 0-2372 | ||||||||||||||||||||||||||||||||||||
114 | p++; | - | ||||||||||||||||||||||||||||||||||||
115 | i--; | - | ||||||||||||||||||||||||||||||||||||
116 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
117 | if (i > sizeof(long)
| 0-2372 | ||||||||||||||||||||||||||||||||||||
118 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
119 | while (i-- > 0
| 2372-4078 | ||||||||||||||||||||||||||||||||||||
120 | ret <<= 8L; | - | ||||||||||||||||||||||||||||||||||||
121 | ret |= *(p++); | - | ||||||||||||||||||||||||||||||||||||
122 | } executed 4078 times by 8 tests: end of block Executed by:
| 4078 | ||||||||||||||||||||||||||||||||||||
123 | } executed 2372 times by 8 tests: elseend of block Executed by:
| 2372 | ||||||||||||||||||||||||||||||||||||
124 | ret = i; executed 16824 times by 12 tests: ret = i; Executed by:
| 16824 | ||||||||||||||||||||||||||||||||||||
125 | } | - | ||||||||||||||||||||||||||||||||||||
126 | if (ret > 0x7fffffffffffffffL
| 0-19196 | ||||||||||||||||||||||||||||||||||||
127 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
128 | *pp = p; | - | ||||||||||||||||||||||||||||||||||||
129 | *rl = (long)ret; | - | ||||||||||||||||||||||||||||||||||||
130 | return executed 19196 times by 12 tests: (1);return (1); Executed by:
executed 19196 times by 12 tests: return (1); Executed by:
| 19196 | ||||||||||||||||||||||||||||||||||||
131 | } | - | ||||||||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||||||||||||||
135 | void | - | ||||||||||||||||||||||||||||||||||||
136 | ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, | - | ||||||||||||||||||||||||||||||||||||
137 | int xclass) | - | ||||||||||||||||||||||||||||||||||||
138 | { | - | ||||||||||||||||||||||||||||||||||||
139 | unsigned char *p= *pp; | - | ||||||||||||||||||||||||||||||||||||
140 | int i, ttag; | - | ||||||||||||||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||||||||||||||
142 | i = (
| 5630-6901 | ||||||||||||||||||||||||||||||||||||
143 | i |= (xclass & 0xc0); | - | ||||||||||||||||||||||||||||||||||||
144 | if (tag < 31
| 0-12531 | ||||||||||||||||||||||||||||||||||||
145 | *( executed 12531 times by 12 tests: p++) = i | (tag & 0x1f);*(p++) = i | (tag & 0x1f); Executed by:
executed 12531 times by 12 tests: *(p++) = i | (tag & 0x1f); Executed by:
| 12531 | ||||||||||||||||||||||||||||||||||||
146 | else { | - | ||||||||||||||||||||||||||||||||||||
147 | *(p++) = i | 0x1f; | - | ||||||||||||||||||||||||||||||||||||
148 | for(i = 0, ttag = tag; ttag > 0
| 0 | ||||||||||||||||||||||||||||||||||||
149 | ttag >>= 7; never executed: ttag >>= 7; | 0 | ||||||||||||||||||||||||||||||||||||
150 | ttag = i; | - | ||||||||||||||||||||||||||||||||||||
151 | while (i-- > 0
| 0 | ||||||||||||||||||||||||||||||||||||
152 | p[i] = tag & 0x7f; | - | ||||||||||||||||||||||||||||||||||||
153 | if (i != (ttag - 1)
| 0 | ||||||||||||||||||||||||||||||||||||
154 | p[i] |= 0x80; never executed: p[i] |= 0x80; | 0 | ||||||||||||||||||||||||||||||||||||
155 | tag >>= 7; | - | ||||||||||||||||||||||||||||||||||||
156 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
157 | p += ttag; | - | ||||||||||||||||||||||||||||||||||||
158 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
159 | if (constructed == 2
| 0-12531 | ||||||||||||||||||||||||||||||||||||
160 | *( never executed: p++) = 0x80;*(p++) = 0x80; never executed: *(p++) = 0x80; | 0 | ||||||||||||||||||||||||||||||||||||
161 | else | - | ||||||||||||||||||||||||||||||||||||
162 | asn1_put_length(&p, length); executed 12531 times by 12 tests: asn1_put_length(&p, length); Executed by:
| 12531 | ||||||||||||||||||||||||||||||||||||
163 | *pp = p; | - | ||||||||||||||||||||||||||||||||||||
164 | } executed 12531 times by 12 tests: end of block Executed by:
| 12531 | ||||||||||||||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||||||||||||||
166 | int | - | ||||||||||||||||||||||||||||||||||||
167 | ASN1_put_eoc(unsigned char **pp) | - | ||||||||||||||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||||||||||||||
169 | unsigned char *p = *pp; | - | ||||||||||||||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||||||||||||||
171 | *p++ = 0; | - | ||||||||||||||||||||||||||||||||||||
172 | *p++ = 0; | - | ||||||||||||||||||||||||||||||||||||
173 | *pp = p; | - | ||||||||||||||||||||||||||||||||||||
174 | return never executed: 2;return 2; never executed: return 2; | 0 | ||||||||||||||||||||||||||||||||||||
175 | } | - | ||||||||||||||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||||||||||||||
177 | static void | - | ||||||||||||||||||||||||||||||||||||
178 | asn1_put_length(unsigned char **pp, int length) | - | ||||||||||||||||||||||||||||||||||||
179 | { | - | ||||||||||||||||||||||||||||||||||||
180 | unsigned char *p= *pp; | - | ||||||||||||||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||||||||||||||
182 | int i, l; | - | ||||||||||||||||||||||||||||||||||||
183 | if (length <= 127
| 1065-11466 | ||||||||||||||||||||||||||||||||||||
184 | *( executed 11466 times by 12 tests: p++) = (unsigned char)length;*(p++) = (unsigned char)length; Executed by:
executed 11466 times by 12 tests: *(p++) = (unsigned char)length; Executed by:
| 11466 | ||||||||||||||||||||||||||||||||||||
185 | else { | - | ||||||||||||||||||||||||||||||||||||
186 | l = length; | - | ||||||||||||||||||||||||||||||||||||
187 | for (i = 0; l > 0
| 1065-1765 | ||||||||||||||||||||||||||||||||||||
188 | l >>= 8; executed 1765 times by 7 tests: l >>= 8; Executed by:
| 1765 | ||||||||||||||||||||||||||||||||||||
189 | *(p++) = i | 0x80; | - | ||||||||||||||||||||||||||||||||||||
190 | l = i; | - | ||||||||||||||||||||||||||||||||||||
191 | while (i-- > 0
| 1065-1765 | ||||||||||||||||||||||||||||||||||||
192 | p[i] = length & 0xff; | - | ||||||||||||||||||||||||||||||||||||
193 | length >>= 8; | - | ||||||||||||||||||||||||||||||||||||
194 | } executed 1765 times by 7 tests: end of block Executed by:
| 1765 | ||||||||||||||||||||||||||||||||||||
195 | p += l; | - | ||||||||||||||||||||||||||||||||||||
196 | } executed 1065 times by 7 tests: end of block Executed by:
| 1065 | ||||||||||||||||||||||||||||||||||||
197 | *pp = p; | - | ||||||||||||||||||||||||||||||||||||
198 | } executed 12531 times by 12 tests: end of block Executed by:
| 12531 | ||||||||||||||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||||||||||||||
200 | int | - | ||||||||||||||||||||||||||||||||||||
201 | ASN1_object_size(int constructed, int length, int tag) | - | ||||||||||||||||||||||||||||||||||||
202 | { | - | ||||||||||||||||||||||||||||||||||||
203 | int ret; | - | ||||||||||||||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||||||||||||||
205 | ret = length; | - | ||||||||||||||||||||||||||||||||||||
206 | ret++; | - | ||||||||||||||||||||||||||||||||||||
207 | if (tag >= 31
| 0-39267 | ||||||||||||||||||||||||||||||||||||
208 | while (tag > 0
| 0 | ||||||||||||||||||||||||||||||||||||
209 | tag >>= 7; | - | ||||||||||||||||||||||||||||||||||||
210 | ret++; | - | ||||||||||||||||||||||||||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
212 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
213 | if (constructed == 2
| 0-39267 | ||||||||||||||||||||||||||||||||||||
214 | return never executed: ret + 3;return ret + 3; never executed: return ret + 3; | 0 | ||||||||||||||||||||||||||||||||||||
215 | ret++; | - | ||||||||||||||||||||||||||||||||||||
216 | if (length > 127
| 2762-36505 | ||||||||||||||||||||||||||||||||||||
217 | while (length > 0
| 2762-4592 | ||||||||||||||||||||||||||||||||||||
218 | length >>= 8; | - | ||||||||||||||||||||||||||||||||||||
219 | ret++; | - | ||||||||||||||||||||||||||||||||||||
220 | } executed 4592 times by 7 tests: end of block Executed by:
| 4592 | ||||||||||||||||||||||||||||||||||||
221 | } executed 2762 times by 7 tests: end of block Executed by:
| 2762 | ||||||||||||||||||||||||||||||||||||
222 | return executed 39267 times by 12 tests: (ret);return (ret); Executed by:
executed 39267 times by 12 tests: return (ret); Executed by:
| 39267 | ||||||||||||||||||||||||||||||||||||
223 | } | - | ||||||||||||||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||||||||||||||
225 | static int | - | ||||||||||||||||||||||||||||||||||||
226 | _asn1_Finish(ASN1_const_CTX *c) | - | ||||||||||||||||||||||||||||||||||||
227 | { | - | ||||||||||||||||||||||||||||||||||||
228 | if ((
| 0 | ||||||||||||||||||||||||||||||||||||
229 | if (!ASN1_const_check_infinite_end(&c->p, c->slen)
| 0 | ||||||||||||||||||||||||||||||||||||
230 | c->error = 63; | - | ||||||||||||||||||||||||||||||||||||
231 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
232 | } | - | ||||||||||||||||||||||||||||||||||||
233 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
234 | if (((
| 0 | ||||||||||||||||||||||||||||||||||||
235 | ((
| 0 | ||||||||||||||||||||||||||||||||||||
236 | c->error = 62; | - | ||||||||||||||||||||||||||||||||||||
237 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
238 | } | - | ||||||||||||||||||||||||||||||||||||
239 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||||||||
240 | } | - | ||||||||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||||||||
242 | int | - | ||||||||||||||||||||||||||||||||||||
243 | asn1_Finish(ASN1_CTX *c) | - | ||||||||||||||||||||||||||||||||||||
244 | { | - | ||||||||||||||||||||||||||||||||||||
245 | return never executed: _asn1_Finish((ASN1_const_CTX *)c);return _asn1_Finish((ASN1_const_CTX *)c); never executed: return _asn1_Finish((ASN1_const_CTX *)c); | 0 | ||||||||||||||||||||||||||||||||||||
246 | } | - | ||||||||||||||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||||||||||||||
248 | int | - | ||||||||||||||||||||||||||||||||||||
249 | asn1_const_Finish(ASN1_const_CTX *c) | - | ||||||||||||||||||||||||||||||||||||
250 | { | - | ||||||||||||||||||||||||||||||||||||
251 | return never executed: _asn1_Finish(c);return _asn1_Finish(c); never executed: return _asn1_Finish(c); | 0 | ||||||||||||||||||||||||||||||||||||
252 | } | - | ||||||||||||||||||||||||||||||||||||
253 | - | |||||||||||||||||||||||||||||||||||||
254 | int | - | ||||||||||||||||||||||||||||||||||||
255 | asn1_GetSequence(ASN1_const_CTX *c, long *length) | - | ||||||||||||||||||||||||||||||||||||
256 | { | - | ||||||||||||||||||||||||||||||||||||
257 | const unsigned char *q; | - | ||||||||||||||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||||||||||||||
259 | q = c->p; | - | ||||||||||||||||||||||||||||||||||||
260 | c->inf = ASN1_get_object(&(c->p), &(c->slen), &(c->tag), &(c->xclass), | - | ||||||||||||||||||||||||||||||||||||
261 | *length); | - | ||||||||||||||||||||||||||||||||||||
262 | if (c->inf & 0x80
| 0 | ||||||||||||||||||||||||||||||||||||
263 | c->error = 60; | - | ||||||||||||||||||||||||||||||||||||
264 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
265 | } | - | ||||||||||||||||||||||||||||||||||||
266 | if (c->tag != 16
| 0 | ||||||||||||||||||||||||||||||||||||
267 | c->error = 61; | - | ||||||||||||||||||||||||||||||||||||
268 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
269 | } | - | ||||||||||||||||||||||||||||||||||||
270 | (*length) -= (c->p - q); | - | ||||||||||||||||||||||||||||||||||||
271 | if (c->max
| 0 | ||||||||||||||||||||||||||||||||||||
272 | c->error = 62; | - | ||||||||||||||||||||||||||||||||||||
273 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
274 | } | - | ||||||||||||||||||||||||||||||||||||
275 | if (c->inf == (1|0x20)
| 0 | ||||||||||||||||||||||||||||||||||||
276 | c->slen= *length+ *(c->pp) - c->p; never executed: c->slen= *length+ *(c->pp) - c->p; | 0 | ||||||||||||||||||||||||||||||||||||
277 | c->eos = 0; | - | ||||||||||||||||||||||||||||||||||||
278 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||||||||
279 | } | - | ||||||||||||||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||||||||||||||
281 | int | - | ||||||||||||||||||||||||||||||||||||
282 | ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) | - | ||||||||||||||||||||||||||||||||||||
283 | { | - | ||||||||||||||||||||||||||||||||||||
284 | if (str ==
| 0-1807 | ||||||||||||||||||||||||||||||||||||
285 | ((void *)0)
| 0-1807 | ||||||||||||||||||||||||||||||||||||
286 | ) | - | ||||||||||||||||||||||||||||||||||||
287 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
288 | dst->type = str->type; | - | ||||||||||||||||||||||||||||||||||||
289 | if (!ASN1_STRING_set(dst, str->data, str->length)
| 0-1807 | ||||||||||||||||||||||||||||||||||||
290 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
291 | dst->flags = str->flags; | - | ||||||||||||||||||||||||||||||||||||
292 | return executed 1807 times by 4 tests: 1;return 1; Executed by:
executed 1807 times by 4 tests: return 1; Executed by:
| 1807 | ||||||||||||||||||||||||||||||||||||
293 | } | - | ||||||||||||||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||||||||||||||
295 | ASN1_STRING * | - | ||||||||||||||||||||||||||||||||||||
296 | ASN1_STRING_dup(const ASN1_STRING *str) | - | ||||||||||||||||||||||||||||||||||||
297 | { | - | ||||||||||||||||||||||||||||||||||||
298 | ASN1_STRING *ret; | - | ||||||||||||||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||||||||||||||
300 | if (!str
| 0-1807 | ||||||||||||||||||||||||||||||||||||
301 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
302 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
303 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
304 | ret = ASN1_STRING_new(); | - | ||||||||||||||||||||||||||||||||||||
305 | if (!ret
| 0-1807 | ||||||||||||||||||||||||||||||||||||
306 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
307 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
308 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
309 | if (!ASN1_STRING_copy(ret, str)
| 0-1807 | ||||||||||||||||||||||||||||||||||||
310 | ASN1_STRING_free(ret); | - | ||||||||||||||||||||||||||||||||||||
311 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
312 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
313 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||
314 | } | - | ||||||||||||||||||||||||||||||||||||
315 | return executed 1807 times by 4 tests: ret;return ret; Executed by:
executed 1807 times by 4 tests: return ret; Executed by:
| 1807 | ||||||||||||||||||||||||||||||||||||
316 | } | - | ||||||||||||||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||||||||||||||
318 | int | - | ||||||||||||||||||||||||||||||||||||
319 | ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) | - | ||||||||||||||||||||||||||||||||||||
320 | { | - | ||||||||||||||||||||||||||||||||||||
321 | const char *data = _data; | - | ||||||||||||||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||||||||||||||
323 | if (len < 0
| 21-8234 | ||||||||||||||||||||||||||||||||||||
324 | if (data ==
| 0-21 | ||||||||||||||||||||||||||||||||||||
325 | ((void *)0)
| 0-21 | ||||||||||||||||||||||||||||||||||||
326 | ) | - | ||||||||||||||||||||||||||||||||||||
327 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
328 | else | - | ||||||||||||||||||||||||||||||||||||
329 | len = strlen(data); executed 21 times by 1 test: len = strlen(data); Executed by:
| 21 | ||||||||||||||||||||||||||||||||||||
330 | } | - | ||||||||||||||||||||||||||||||||||||
331 | if ((
| 0-8249 | ||||||||||||||||||||||||||||||||||||
332 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||||||||||||||
333 | )
| 0-6 | ||||||||||||||||||||||||||||||||||||
334 | unsigned char *tmp; | - | ||||||||||||||||||||||||||||||||||||
335 | tmp = realloc(str->data, len + 1); | - | ||||||||||||||||||||||||||||||||||||
336 | if (tmp ==
| 0-8249 | ||||||||||||||||||||||||||||||||||||
337 | ((void *)0)
| 0-8249 | ||||||||||||||||||||||||||||||||||||
338 | ) { | - | ||||||||||||||||||||||||||||||||||||
339 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,388); | - | ||||||||||||||||||||||||||||||||||||
340 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||
341 | } | - | ||||||||||||||||||||||||||||||||||||
342 | str->data = tmp; | - | ||||||||||||||||||||||||||||||||||||
343 | } executed 8249 times by 10 tests: end of block Executed by:
| 8249 | ||||||||||||||||||||||||||||||||||||
344 | str->length = len; | - | ||||||||||||||||||||||||||||||||||||
345 | if (data !=
| 0-8255 | ||||||||||||||||||||||||||||||||||||
346 | ((void *)0)
| 0-8255 | ||||||||||||||||||||||||||||||||||||
347 | ) { | - | ||||||||||||||||||||||||||||||||||||
348 | memmove(str->data, data, len); | - | ||||||||||||||||||||||||||||||||||||
349 | } executed 8255 times by 11 tests: end of block Executed by:
| 8255 | ||||||||||||||||||||||||||||||||||||
350 | str->data[str->length]='\0'; | - | ||||||||||||||||||||||||||||||||||||
351 | return executed 8255 times by 11 tests: (1);return (1); Executed by:
executed 8255 times by 11 tests: return (1); Executed by:
| 8255 | ||||||||||||||||||||||||||||||||||||
352 | } | - | ||||||||||||||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||||||||||||||
354 | void | - | ||||||||||||||||||||||||||||||||||||
355 | ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) | - | ||||||||||||||||||||||||||||||||||||
356 | { | - | ||||||||||||||||||||||||||||||||||||
357 | freezero(str->data, str->length); | - | ||||||||||||||||||||||||||||||||||||
358 | str->data = data; | - | ||||||||||||||||||||||||||||||||||||
359 | str->length = len; | - | ||||||||||||||||||||||||||||||||||||
360 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||||||||||||||
362 | ASN1_STRING * | - | ||||||||||||||||||||||||||||||||||||
363 | ASN1_STRING_new(void) | - | ||||||||||||||||||||||||||||||||||||
364 | { | - | ||||||||||||||||||||||||||||||||||||
365 | return executed 1837 times by 7 tests: (ASN1_STRING_type_new(4));return (ASN1_STRING_type_new(4)); Executed by:
executed 1837 times by 7 tests: return (ASN1_STRING_type_new(4)); Executed by:
| 1837 | ||||||||||||||||||||||||||||||||||||
366 | } | - | ||||||||||||||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||||||||||||||
368 | ASN1_STRING * | - | ||||||||||||||||||||||||||||||||||||
369 | ASN1_STRING_type_new(int type) | - | ||||||||||||||||||||||||||||||||||||
370 | { | - | ||||||||||||||||||||||||||||||||||||
371 | ASN1_STRING *ret; | - | ||||||||||||||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||||||||||||||
373 | ret = malloc(sizeof(ASN1_STRING)); | - | ||||||||||||||||||||||||||||||||||||
374 | if (ret ==
| 0-8352 | ||||||||||||||||||||||||||||||||||||
375 | ((void *)0)
| 0-8352 | ||||||||||||||||||||||||||||||||||||
376 | ) { | - | ||||||||||||||||||||||||||||||||||||
377 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,422); | - | ||||||||||||||||||||||||||||||||||||
378 | return never executed: (return ( ((void *)0) ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||||||||
379 | ((void *)0) never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||||||||
380 | ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||||||||
381 | } | - | ||||||||||||||||||||||||||||||||||||
382 | ret->length = 0; | - | ||||||||||||||||||||||||||||||||||||
383 | ret->type = type; | - | ||||||||||||||||||||||||||||||||||||
384 | ret->data = | - | ||||||||||||||||||||||||||||||||||||
385 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||
386 | ; | - | ||||||||||||||||||||||||||||||||||||
387 | ret->flags = 0; | - | ||||||||||||||||||||||||||||||||||||
388 | return executed 8352 times by 12 tests: (ret);return (ret); Executed by:
executed 8352 times by 12 tests: return (ret); Executed by:
| 8352 | ||||||||||||||||||||||||||||||||||||
389 | } | - | ||||||||||||||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||||||||||||||
391 | void | - | ||||||||||||||||||||||||||||||||||||
392 | ASN1_STRING_free(ASN1_STRING *a) | - | ||||||||||||||||||||||||||||||||||||
393 | { | - | ||||||||||||||||||||||||||||||||||||
394 | if (a ==
| 2-8235 | ||||||||||||||||||||||||||||||||||||
395 | ((void *)0)
| 2-8235 | ||||||||||||||||||||||||||||||||||||
396 | ) | - | ||||||||||||||||||||||||||||||||||||
397 | return; executed 2 times by 2 tests: return; Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||
398 | if (a->data !=
| 236-7999 | ||||||||||||||||||||||||||||||||||||
399 | ((void *)0)
| 236-7999 | ||||||||||||||||||||||||||||||||||||
400 | && !(a->flags & 0x010)
| 0-7999 | ||||||||||||||||||||||||||||||||||||
401 | freezero(a->data, a->length); executed 7999 times by 12 tests: freezero(a->data, a->length); Executed by:
| 7999 | ||||||||||||||||||||||||||||||||||||
402 | free(a); | - | ||||||||||||||||||||||||||||||||||||
403 | } executed 8235 times by 12 tests: end of block Executed by:
| 8235 | ||||||||||||||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||||||||||||||
405 | int | - | ||||||||||||||||||||||||||||||||||||
406 | ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) | - | ||||||||||||||||||||||||||||||||||||
407 | { | - | ||||||||||||||||||||||||||||||||||||
408 | int i; | - | ||||||||||||||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||||||||||||||
410 | i = (a->length - b->length); | - | ||||||||||||||||||||||||||||||||||||
411 | if (i == 0
| 0-131 | ||||||||||||||||||||||||||||||||||||
412 | i = memcmp(a->data, b->data, a->length); | - | ||||||||||||||||||||||||||||||||||||
413 | if (i == 0
| 0-131 | ||||||||||||||||||||||||||||||||||||
414 | return executed 131 times by 4 tests: (a->type - b->type);return (a->type - b->type); Executed by:
executed 131 times by 4 tests: return (a->type - b->type); Executed by:
| 131 | ||||||||||||||||||||||||||||||||||||
415 | else | - | ||||||||||||||||||||||||||||||||||||
416 | return never executed: (i);return (i); never executed: return (i); | 0 | ||||||||||||||||||||||||||||||||||||
417 | } else | - | ||||||||||||||||||||||||||||||||||||
418 | return never executed: (i);return (i); never executed: return (i); | 0 | ||||||||||||||||||||||||||||||||||||
419 | } | - | ||||||||||||||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||||||||||||||
421 | void | - | ||||||||||||||||||||||||||||||||||||
422 | asn1_add_error(const unsigned char *address, int offset) | - | ||||||||||||||||||||||||||||||||||||
423 | { | - | ||||||||||||||||||||||||||||||||||||
424 | ERR_asprintf_error_data("offset=%d", offset); | - | ||||||||||||||||||||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
426 | - | |||||||||||||||||||||||||||||||||||||
427 | int | - | ||||||||||||||||||||||||||||||||||||
428 | ASN1_STRING_length(const ASN1_STRING *x) | - | ||||||||||||||||||||||||||||||||||||
429 | { | - | ||||||||||||||||||||||||||||||||||||
430 | return executed 23 times by 3 tests: (x->length);return (x->length); Executed by:
executed 23 times by 3 tests: return (x->length); Executed by:
| 23 | ||||||||||||||||||||||||||||||||||||
431 | } | - | ||||||||||||||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||||||||||||||
433 | void | - | ||||||||||||||||||||||||||||||||||||
434 | ASN1_STRING_length_set(ASN1_STRING *x, int len) | - | ||||||||||||||||||||||||||||||||||||
435 | { | - | ||||||||||||||||||||||||||||||||||||
436 | x->length = len; | - | ||||||||||||||||||||||||||||||||||||
437 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||||||||||||||
439 | int | - | ||||||||||||||||||||||||||||||||||||
440 | ASN1_STRING_type(const ASN1_STRING *x) | - | ||||||||||||||||||||||||||||||||||||
441 | { | - | ||||||||||||||||||||||||||||||||||||
442 | return executed 16 times by 1 test: (x->type);return (x->type); Executed by:
executed 16 times by 1 test: return (x->type); Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
443 | } | - | ||||||||||||||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||||||||||||||
445 | unsigned char * | - | ||||||||||||||||||||||||||||||||||||
446 | ASN1_STRING_data(ASN1_STRING *x) | - | ||||||||||||||||||||||||||||||||||||
447 | { | - | ||||||||||||||||||||||||||||||||||||
448 | return executed 21 times by 3 tests: (x->data);return (x->data); Executed by:
executed 21 times by 3 tests: return (x->data); Executed by:
| 21 | ||||||||||||||||||||||||||||||||||||
449 | } | - | ||||||||||||||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||||||||||||||
451 | const unsigned char * | - | ||||||||||||||||||||||||||||||||||||
452 | ASN1_STRING_get0_data(const ASN1_STRING *x) | - | ||||||||||||||||||||||||||||||||||||
453 | { | - | ||||||||||||||||||||||||||||||||||||
454 | return never executed: (x->data);return (x->data); never executed: return (x->data); | 0 | ||||||||||||||||||||||||||||||||||||
455 | } | - | ||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |