Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/a_bitstr.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||
3 | int | - | ||||||||||||||||||||||||||||||
4 | ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) | - | ||||||||||||||||||||||||||||||
5 | { | - | ||||||||||||||||||||||||||||||
6 | return never executed: ASN1_STRING_set(x, d, len);return ASN1_STRING_set(x, d, len); never executed: return ASN1_STRING_set(x, d, len); | 0 | ||||||||||||||||||||||||||||||
7 | } | - | ||||||||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||||||||
9 | int | - | ||||||||||||||||||||||||||||||
10 | i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) | - | ||||||||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||||||||
12 | int ret, j, bits, len; | - | ||||||||||||||||||||||||||||||
13 | unsigned char *p, *d; | - | ||||||||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||||||||
15 | if (a ==
| 0-1306 | ||||||||||||||||||||||||||||||
16 | ((void *)0)
| 0-1306 | ||||||||||||||||||||||||||||||
17 | ) | - | ||||||||||||||||||||||||||||||
18 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||||||||
20 | len = a->length; | - | ||||||||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||||||||
22 | if (len > 0
| 0-1306 | ||||||||||||||||||||||||||||||
23 | if (a->flags & 0x08
| 0-1306 | ||||||||||||||||||||||||||||||
24 | bits = (int)a->flags & 0x07; | - | ||||||||||||||||||||||||||||||
25 | } executed 1306 times by 6 tests: else {end of block Executed by:
| 1306 | ||||||||||||||||||||||||||||||
26 | for (; len > 0
| 0 | ||||||||||||||||||||||||||||||
27 | if (a->data[len - 1]
| 0 | ||||||||||||||||||||||||||||||
28 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
29 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
30 | j = a->data[len - 1]; | - | ||||||||||||||||||||||||||||||
31 | if (j & 0x01
| 0 | ||||||||||||||||||||||||||||||
32 | bits = 0; never executed: bits = 0; | 0 | ||||||||||||||||||||||||||||||
33 | else if (j & 0x02
| 0 | ||||||||||||||||||||||||||||||
34 | bits = 1; never executed: bits = 1; | 0 | ||||||||||||||||||||||||||||||
35 | else if (j & 0x04
| 0 | ||||||||||||||||||||||||||||||
36 | bits = 2; never executed: bits = 2; | 0 | ||||||||||||||||||||||||||||||
37 | else if (j & 0x08
| 0 | ||||||||||||||||||||||||||||||
38 | bits = 3; never executed: bits = 3; | 0 | ||||||||||||||||||||||||||||||
39 | else if (j & 0x10
| 0 | ||||||||||||||||||||||||||||||
40 | bits = 4; never executed: bits = 4; | 0 | ||||||||||||||||||||||||||||||
41 | else if (j & 0x20
| 0 | ||||||||||||||||||||||||||||||
42 | bits = 5; never executed: bits = 5; | 0 | ||||||||||||||||||||||||||||||
43 | else if (j & 0x40
| 0 | ||||||||||||||||||||||||||||||
44 | bits = 6; never executed: bits = 6; | 0 | ||||||||||||||||||||||||||||||
45 | else if (j & 0x80
| 0 | ||||||||||||||||||||||||||||||
46 | bits = 7; never executed: bits = 7; | 0 | ||||||||||||||||||||||||||||||
47 | else | - | ||||||||||||||||||||||||||||||
48 | bits = 0; never executed: bits = 0; | 0 | ||||||||||||||||||||||||||||||
49 | } | - | ||||||||||||||||||||||||||||||
50 | } else | - | ||||||||||||||||||||||||||||||
51 | bits = 0; never executed: bits = 0; | 0 | ||||||||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||||||||
53 | ret = 1 + len; | - | ||||||||||||||||||||||||||||||
54 | if (pp ==
| 322-984 | ||||||||||||||||||||||||||||||
55 | ((void *)0)
| 322-984 | ||||||||||||||||||||||||||||||
56 | ) | - | ||||||||||||||||||||||||||||||
57 | return executed 984 times by 6 tests: (ret);return (ret); Executed by:
executed 984 times by 6 tests: return (ret); Executed by:
| 984 | ||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||
59 | p= *pp; | - | ||||||||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||||||||
61 | *(p++) = (unsigned char)bits; | - | ||||||||||||||||||||||||||||||
62 | d = a->data; | - | ||||||||||||||||||||||||||||||
63 | memcpy(p, d, len); | - | ||||||||||||||||||||||||||||||
64 | p += len; | - | ||||||||||||||||||||||||||||||
65 | if (len > 0
| 0-322 | ||||||||||||||||||||||||||||||
66 | p[-1]&=(0xff << bits); executed 322 times by 6 tests: p[-1]&=(0xff << bits); Executed by:
| 322 | ||||||||||||||||||||||||||||||
67 | *pp = p; | - | ||||||||||||||||||||||||||||||
68 | return executed 322 times by 6 tests: (ret);return (ret); Executed by:
executed 322 times by 6 tests: return (ret); Executed by:
| 322 | ||||||||||||||||||||||||||||||
69 | } | - | ||||||||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||||||||
71 | ASN1_BIT_STRING * | - | ||||||||||||||||||||||||||||||
72 | c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) | - | ||||||||||||||||||||||||||||||
73 | { | - | ||||||||||||||||||||||||||||||
74 | ASN1_BIT_STRING *ret = | - | ||||||||||||||||||||||||||||||
75 | ((void *)0) | - | ||||||||||||||||||||||||||||||
76 | ; | - | ||||||||||||||||||||||||||||||
77 | const unsigned char *p; | - | ||||||||||||||||||||||||||||||
78 | unsigned char *s; | - | ||||||||||||||||||||||||||||||
79 | int i; | - | ||||||||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||||||||
81 | if (len < 1
| 0-635 | ||||||||||||||||||||||||||||||
82 | ERR_put_error(13,(0xfff),(152),__FILE__,138); | - | ||||||||||||||||||||||||||||||
83 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
84 | } | - | ||||||||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||||||||
86 | if (a ==
| 0-635 | ||||||||||||||||||||||||||||||
87 | ((void *)0)
| 0-635 | ||||||||||||||||||||||||||||||
88 | || *
| 197-438 | ||||||||||||||||||||||||||||||
89 | ((void *)0)
| 197-438 | ||||||||||||||||||||||||||||||
90 | ) { | - | ||||||||||||||||||||||||||||||
91 | if ((
| 0-197 | ||||||||||||||||||||||||||||||
92 | ((void *)0)
| 0-197 | ||||||||||||||||||||||||||||||
93 | ) | - | ||||||||||||||||||||||||||||||
94 | return never executed: (return ( ((void *)0) ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
95 | ((void *)0) never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
96 | ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
97 | } executed 197 times by 5 tests: elseend of block Executed by:
| 197 | ||||||||||||||||||||||||||||||
98 | ret = *a; executed 438 times by 7 tests: ret = *a; Executed by:
| 438 | ||||||||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||||||||
100 | p = *pp; | - | ||||||||||||||||||||||||||||||
101 | i = *(p++); | - | ||||||||||||||||||||||||||||||
102 | if (i > 7
| 0-635 | ||||||||||||||||||||||||||||||
103 | ERR_put_error(13,(0xfff),(220),__FILE__,151); | - | ||||||||||||||||||||||||||||||
104 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||||||||
111 | ret->flags &= ~(0x08 | 0x07); | - | ||||||||||||||||||||||||||||||
112 | ret->flags |= (0x08 | i); | - | ||||||||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||||||||
115 | if (len-- > 1
| 0-635 | ||||||||||||||||||||||||||||||
116 | if ((
| 0-635 | ||||||||||||||||||||||||||||||
117 | ((void *)0)
| 0-635 | ||||||||||||||||||||||||||||||
118 | ) { | - | ||||||||||||||||||||||||||||||
119 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,165); | - | ||||||||||||||||||||||||||||||
120 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
121 | } | - | ||||||||||||||||||||||||||||||
122 | memcpy(s, p, len); | - | ||||||||||||||||||||||||||||||
123 | s[len - 1] &= (0xff << i); | - | ||||||||||||||||||||||||||||||
124 | p += len; | - | ||||||||||||||||||||||||||||||
125 | } executed 635 times by 7 tests: elseend of block Executed by:
| 635 | ||||||||||||||||||||||||||||||
126 | s = never executed: s = ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
127 | ((void *)0) never executed: s = ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
128 | ; never executed: s = ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||
130 | free(ret->data); | - | ||||||||||||||||||||||||||||||
131 | ret->data = s; | - | ||||||||||||||||||||||||||||||
132 | ret->length = (int)len; | - | ||||||||||||||||||||||||||||||
133 | ret->type = 3; | - | ||||||||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||||||||
135 | if (a !=
| 0-635 | ||||||||||||||||||||||||||||||
136 | ((void *)0)
| 0-635 | ||||||||||||||||||||||||||||||
137 | ) | - | ||||||||||||||||||||||||||||||
138 | * executed 635 times by 7 tests: a = ret;*a = ret; Executed by:
executed 635 times by 7 tests: *a = ret; Executed by:
| 635 | ||||||||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||||||||
140 | *pp = p; | - | ||||||||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||||||||
142 | return executed 635 times by 7 tests: (ret);return (ret); Executed by:
executed 635 times by 7 tests: return (ret); Executed by:
| 635 | ||||||||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||||||||
144 | err: | - | ||||||||||||||||||||||||||||||
145 | if (a ==
| 0 | ||||||||||||||||||||||||||||||
146 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
147 | || *
| 0 | ||||||||||||||||||||||||||||||
148 | ASN1_BIT_STRING_free(ret); never executed: ASN1_BIT_STRING_free(ret); | 0 | ||||||||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||||||||
150 | return never executed: (return ( ((void *)0) ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
151 | ((void *)0) never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
152 | ); never executed: return ( ((void *)0) ); | 0 | ||||||||||||||||||||||||||||||
153 | } | - | ||||||||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||||||||
155 | int | - | ||||||||||||||||||||||||||||||
156 | ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) | - | ||||||||||||||||||||||||||||||
157 | { | - | ||||||||||||||||||||||||||||||
158 | int w, v, iv; | - | ||||||||||||||||||||||||||||||
159 | unsigned char *c; | - | ||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||
161 | w = n/8; | - | ||||||||||||||||||||||||||||||
162 | v = 1 << (7 - (n & 0x07)); | - | ||||||||||||||||||||||||||||||
163 | iv = ~v; | - | ||||||||||||||||||||||||||||||
164 | if (!value
| 0 | ||||||||||||||||||||||||||||||
165 | v = 0; never executed: v = 0; | 0 | ||||||||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||||||||
167 | if (a ==
| 0 | ||||||||||||||||||||||||||||||
168 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
169 | ) | - | ||||||||||||||||||||||||||||||
170 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||||||||
172 | a->flags &= ~(0x08 | 0x07); | - | ||||||||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||||||||
174 | if ((
| 0 | ||||||||||||||||||||||||||||||
175 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
176 | )
| 0 | ||||||||||||||||||||||||||||||
177 | if (!value
| 0 | ||||||||||||||||||||||||||||||
178 | return never executed: (1);return(1); never executed: return(1); | 0 | ||||||||||||||||||||||||||||||
179 | if ((
| 0 | ||||||||||||||||||||||||||||||
180 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
181 | ) { | - | ||||||||||||||||||||||||||||||
182 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,214); | - | ||||||||||||||||||||||||||||||
183 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
184 | } | - | ||||||||||||||||||||||||||||||
185 | if (w + 1 - a->length > 0
| 0 | ||||||||||||||||||||||||||||||
186 | memset(c + a->length, 0, w + 1 - a->length); never executed: memset(c + a->length, 0, w + 1 - a->length); | 0 | ||||||||||||||||||||||||||||||
187 | a->data = c; | - | ||||||||||||||||||||||||||||||
188 | a->length = w + 1; | - | ||||||||||||||||||||||||||||||
189 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
190 | a->data[w] = ((a->data[w]) & iv) | v; | - | ||||||||||||||||||||||||||||||
191 | while ((
| 0 | ||||||||||||||||||||||||||||||
192 | a->length--; never executed: a->length--; | 0 | ||||||||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||||||||
194 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
195 | } | - | ||||||||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||||||||
197 | int | - | ||||||||||||||||||||||||||||||
198 | ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) | - | ||||||||||||||||||||||||||||||
199 | { | - | ||||||||||||||||||||||||||||||
200 | int w, v; | - | ||||||||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||||||||
202 | w = n / 8; | - | ||||||||||||||||||||||||||||||
203 | v = 1 << (7 - (n & 0x07)); | - | ||||||||||||||||||||||||||||||
204 | if ((
| 0-9 | ||||||||||||||||||||||||||||||
205 | ((void *)0)
| 0-9 | ||||||||||||||||||||||||||||||
206 | )
| 0-9 | ||||||||||||||||||||||||||||||
207 | ((void *)0)
| 0-8 | ||||||||||||||||||||||||||||||
208 | )
| 0-8 | ||||||||||||||||||||||||||||||
209 | return executed 1 time by 1 test: (0);return (0); Executed by:
executed 1 time by 1 test: return (0); Executed by:
| 1 | ||||||||||||||||||||||||||||||
210 | return executed 8 times by 1 test: ((a->data[w] & v) != 0);return ((a->data[w] & v) != 0); Executed by:
executed 8 times by 1 test: return ((a->data[w] & v) != 0); Executed by:
| 8 | ||||||||||||||||||||||||||||||
211 | } | - | ||||||||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||||||||
219 | int | - | ||||||||||||||||||||||||||||||
220 | ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags, | - | ||||||||||||||||||||||||||||||
221 | int flags_len) | - | ||||||||||||||||||||||||||||||
222 | { | - | ||||||||||||||||||||||||||||||
223 | int i, ok; | - | ||||||||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||||||||
226 | if (!a
| 0 | ||||||||||||||||||||||||||||||
227 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||||||||
230 | ok = 1; | - | ||||||||||||||||||||||||||||||
231 | for (i = 0; i < a->length
| 0 | ||||||||||||||||||||||||||||||
232 | unsigned char mask = i < flags_len
| 0 | ||||||||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||||||||
234 | ok = (a->data[i] & mask) == 0; | - | ||||||||||||||||||||||||||||||
235 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
236 | return never executed: ok;return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |