Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/bio_enc.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | static int enc_write(BIO *h, const char *buf, int num); | - | ||||||||||||||||||
4 | static int enc_read(BIO *h, char *buf, int size); | - | ||||||||||||||||||
5 | static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||||||||
6 | static int enc_new(BIO *h); | - | ||||||||||||||||||
7 | static int enc_free(BIO *data); | - | ||||||||||||||||||
8 | static long enc_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fps); | - | ||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | typedef struct enc_struct { | - | ||||||||||||||||||
14 | int buf_len; | - | ||||||||||||||||||
15 | int buf_off; | - | ||||||||||||||||||
16 | int cont; | - | ||||||||||||||||||
17 | int finished; | - | ||||||||||||||||||
18 | int ok; | - | ||||||||||||||||||
19 | EVP_CIPHER_CTX *cipher; | - | ||||||||||||||||||
20 | unsigned char *read_start, *read_end; | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | - | |||||||||||||||||||
23 | - | |||||||||||||||||||
24 | - | |||||||||||||||||||
25 | unsigned char buf[((256) + 32) + (1024*4)]; | - | ||||||||||||||||||
26 | } BIO_ENC_CTX; | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | static const BIO_METHOD methods_enc = { | - | ||||||||||||||||||
29 | (10|0x0200), | - | ||||||||||||||||||
30 | "cipher", | - | ||||||||||||||||||
31 | - | |||||||||||||||||||
32 | bwrite_conv, | - | ||||||||||||||||||
33 | enc_write, | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | bread_conv, | - | ||||||||||||||||||
36 | enc_read, | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | ((void *)0) | - | ||||||||||||||||||
39 | , | - | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | ((void *)0) | - | ||||||||||||||||||
42 | , | - | ||||||||||||||||||
43 | enc_ctrl, | - | ||||||||||||||||||
44 | enc_new, | - | ||||||||||||||||||
45 | enc_free, | - | ||||||||||||||||||
46 | enc_callback_ctrl, | - | ||||||||||||||||||
47 | }; | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | const BIO_METHOD *BIO_f_cipher(void) | - | ||||||||||||||||||
50 | { | - | ||||||||||||||||||
51 | return executed 37594 times by 1 test: &methods_enc;return &methods_enc; Executed by:
executed 37594 times by 1 test: return &methods_enc; Executed by:
| 37594 | ||||||||||||||||||
52 | } | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | static int enc_new(BIO *bi) | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | if ((
| 0-37594 | ||||||||||||||||||
59 | ((void *)0)
| 0-37594 | ||||||||||||||||||
60 | ) { | - | ||||||||||||||||||
61 | ERR_put_error(6,(199),((1|64)),__FILE__,69); | - | ||||||||||||||||||
62 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
63 | } | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | ctx->cipher = EVP_CIPHER_CTX_new(); | - | ||||||||||||||||||
66 | if (ctx->cipher ==
| 0-37594 | ||||||||||||||||||
67 | ((void *)0)
| 0-37594 | ||||||||||||||||||
68 | ) { | - | ||||||||||||||||||
69 | CRYPTO_free(ctx, __FILE__, 75); | - | ||||||||||||||||||
70 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
71 | } | - | ||||||||||||||||||
72 | ctx->cont = 1; | - | ||||||||||||||||||
73 | ctx->ok = 1; | - | ||||||||||||||||||
74 | ctx->read_end = ctx->read_start = &(ctx->buf[((256) + 32)]); | - | ||||||||||||||||||
75 | BIO_set_data(bi, ctx); | - | ||||||||||||||||||
76 | BIO_set_init(bi, 1); | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | return executed 37594 times by 1 test: 1;return 1; Executed by:
executed 37594 times by 1 test: return 1; Executed by:
| 37594 | ||||||||||||||||||
79 | } | - | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | static int enc_free(BIO *a) | - | ||||||||||||||||||
82 | { | - | ||||||||||||||||||
83 | BIO_ENC_CTX *b; | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | if (a ==
| 0-37594 | ||||||||||||||||||
86 | ((void *)0)
| 0-37594 | ||||||||||||||||||
87 | ) | - | ||||||||||||||||||
88 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | b = BIO_get_data(a); | - | ||||||||||||||||||
91 | if (b ==
| 0-37594 | ||||||||||||||||||
92 | ((void *)0)
| 0-37594 | ||||||||||||||||||
93 | ) | - | ||||||||||||||||||
94 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | EVP_CIPHER_CTX_free(b->cipher); | - | ||||||||||||||||||
97 | CRYPTO_clear_free(b, sizeof(BIO_ENC_CTX), __FILE__, 99); | - | ||||||||||||||||||
98 | BIO_set_data(a, | - | ||||||||||||||||||
99 | ((void *)0) | - | ||||||||||||||||||
100 | ); | - | ||||||||||||||||||
101 | BIO_set_init(a, 0); | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | return executed 37594 times by 1 test: 1;return 1; Executed by:
executed 37594 times by 1 test: return 1; Executed by:
| 37594 | ||||||||||||||||||
104 | } | - | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | static int enc_read(BIO *b, char *out, int outl) | - | ||||||||||||||||||
107 | { | - | ||||||||||||||||||
108 | int ret = 0, i, blocksize; | - | ||||||||||||||||||
109 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
110 | BIO *next; | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | if (out ==
| 0-235890 | ||||||||||||||||||
113 | ((void *)0)
| 0-235890 | ||||||||||||||||||
114 | ) | - | ||||||||||||||||||
115 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
116 | ctx = BIO_get_data(b); | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | next = BIO_next(b); | - | ||||||||||||||||||
119 | if ((
| 0-235890 | ||||||||||||||||||
120 | ((void *)0)
| 0-235890 | ||||||||||||||||||
121 | )
| 0-235890 | ||||||||||||||||||
122 | ((void *)0)
| 0-235890 | ||||||||||||||||||
123 | )
| 0-235890 | ||||||||||||||||||
124 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | - | |||||||||||||||||||
127 | if (ctx->buf_len > 0
| 49178-186712 | ||||||||||||||||||
128 | i = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
129 | if (i > outl
| 64624-122088 | ||||||||||||||||||
130 | i = outl; executed 122088 times by 1 test: i = outl; Executed by:
| 122088 | ||||||||||||||||||
131 | memcpy(out, &(ctx->buf[ctx->buf_off]), i); | - | ||||||||||||||||||
132 | ret = i; | - | ||||||||||||||||||
133 | out += i; | - | ||||||||||||||||||
134 | outl -= i; | - | ||||||||||||||||||
135 | ctx->buf_off += i; | - | ||||||||||||||||||
136 | if (ctx->buf_len == ctx->buf_off
| 64624-122088 | ||||||||||||||||||
137 | ctx->buf_len = 0; | - | ||||||||||||||||||
138 | ctx->buf_off = 0; | - | ||||||||||||||||||
139 | } executed 64624 times by 1 test: end of block Executed by:
| 64624 | ||||||||||||||||||
140 | } executed 186712 times by 1 test: end of block Executed by:
| 186712 | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | blocksize = EVP_CIPHER_CTX_block_size(ctx->cipher); | - | ||||||||||||||||||
143 | if (blocksize == 1
| 39730-196160 | ||||||||||||||||||
144 | blocksize = 0; executed 196160 times by 1 test: blocksize = 0; Executed by:
| 196160 | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | - | |||||||||||||||||||
147 | - | |||||||||||||||||||
148 | - | |||||||||||||||||||
149 | - | |||||||||||||||||||
150 | - | |||||||||||||||||||
151 | while (outl > 0
| 138946-166368 | ||||||||||||||||||
152 | if (ctx->cont <= 0
| 15264-123682 | ||||||||||||||||||
153 | break; executed 15264 times by 1 test: break; Executed by:
| 15264 | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | if (ctx->read_start == ctx->read_end
| 49754-73928 | ||||||||||||||||||
156 | ctx->read_end = ctx->read_start = &(ctx->buf[((256) + 32)]); | - | ||||||||||||||||||
157 | i = BIO_read(next, ctx->read_start, (1024*4)); | - | ||||||||||||||||||
158 | if (i > 0
| 36964 | ||||||||||||||||||
159 | ctx->read_end += i; executed 36964 times by 1 test: ctx->read_end += i; Executed by:
| 36964 | ||||||||||||||||||
160 | } executed 73928 times by 1 test: else {end of block Executed by:
| 73928 | ||||||||||||||||||
161 | i = ctx->read_end - ctx->read_start; | - | ||||||||||||||||||
162 | } executed 49754 times by 1 test: end of block Executed by:
| 49754 | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | if (i <= 0
| 36964-86718 | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | if (!BIO_test_flags(next, 0x08)
| 0-36964 | ||||||||||||||||||
167 | ctx->cont = i; | - | ||||||||||||||||||
168 | i = EVP_CipherFinal_ex(ctx->cipher, | - | ||||||||||||||||||
169 | ctx->buf, &(ctx->buf_len)); | - | ||||||||||||||||||
170 | ctx->ok = i; | - | ||||||||||||||||||
171 | ctx->buf_off = 0; | - | ||||||||||||||||||
172 | } executed 36964 times by 1 test: else {end of block Executed by:
| 36964 | ||||||||||||||||||
173 | ret = (
| 0 | ||||||||||||||||||
174 | break; never executed: break; | 0 | ||||||||||||||||||
175 | } | - | ||||||||||||||||||
176 | } else { | - | ||||||||||||||||||
177 | if (outl > (256)
| 40898-45820 | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | - | |||||||||||||||||||
180 | - | |||||||||||||||||||
181 | - | |||||||||||||||||||
182 | - | |||||||||||||||||||
183 | int j = outl - blocksize, buf_len; | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | if (!EVP_CipherUpdate(ctx->cipher,
| 0-40898 | ||||||||||||||||||
186 | (unsigned char *)out, &buf_len,
| 0-40898 | ||||||||||||||||||
187 | ctx->read_start, i > j ? j : i)
| 0-40898 | ||||||||||||||||||
188 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
189 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
190 | } | - | ||||||||||||||||||
191 | ret += buf_len; | - | ||||||||||||||||||
192 | out += buf_len; | - | ||||||||||||||||||
193 | outl -= buf_len; | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | if ((
| 16156-24742 | ||||||||||||||||||
196 | ctx->read_start = ctx->read_end; | - | ||||||||||||||||||
197 | continue; executed 16156 times by 1 test: continue; Executed by:
| 16156 | ||||||||||||||||||
198 | } | - | ||||||||||||||||||
199 | ctx->read_start += j; | - | ||||||||||||||||||
200 | } executed 24742 times by 1 test: end of block Executed by:
| 24742 | ||||||||||||||||||
201 | if (i > (256)
| 20808-49754 | ||||||||||||||||||
202 | i = (256); executed 49754 times by 1 test: i = (256); Executed by:
| 49754 | ||||||||||||||||||
203 | if (!EVP_CipherUpdate(ctx->cipher,
| 0-70562 | ||||||||||||||||||
204 | ctx->buf, &ctx->buf_len,
| 0-70562 | ||||||||||||||||||
205 | ctx->read_start, i)
| 0-70562 | ||||||||||||||||||
206 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
207 | ctx->ok = 0; | - | ||||||||||||||||||
208 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
209 | } | - | ||||||||||||||||||
210 | ctx->read_start += i; | - | ||||||||||||||||||
211 | ctx->cont = 1; | - | ||||||||||||||||||
212 | - | |||||||||||||||||||
213 | - | |||||||||||||||||||
214 | - | |||||||||||||||||||
215 | - | |||||||||||||||||||
216 | - | |||||||||||||||||||
217 | - | |||||||||||||||||||
218 | if (ctx->buf_len == 0
| 64-70498 | ||||||||||||||||||
219 | continue; executed 64 times by 1 test: continue; Executed by:
| 64 | ||||||||||||||||||
220 | } executed 70498 times by 1 test: end of block Executed by:
| 70498 | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | if (ctx->buf_len <= outl
| 43910-63552 | ||||||||||||||||||
223 | i = ctx->buf_len; executed 43910 times by 1 test: i = ctx->buf_len; Executed by:
| 43910 | ||||||||||||||||||
224 | else | - | ||||||||||||||||||
225 | i = outl; executed 63552 times by 1 test: i = outl; Executed by:
| 63552 | ||||||||||||||||||
226 | if (i <= 0
| 53204-54258 | ||||||||||||||||||
227 | break; executed 54258 times by 1 test: break; Executed by:
| 54258 | ||||||||||||||||||
228 | memcpy(out, ctx->buf, i); | - | ||||||||||||||||||
229 | ret += i; | - | ||||||||||||||||||
230 | ctx->buf_off = i; | - | ||||||||||||||||||
231 | outl -= i; | - | ||||||||||||||||||
232 | out += i; | - | ||||||||||||||||||
233 | } executed 53204 times by 1 test: end of block Executed by:
| 53204 | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
236 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
237 | return executed 235890 times by 1 test: ((return ((ret == 0) ? ctx->cont : ret); Executed by:
executed 235890 times by 1 test: return ((ret == 0) ? ctx->cont : ret); Executed by:
| 12356-235890 | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | static int enc_write(BIO *b, const char *in, int inl) | - | ||||||||||||||||||
241 | { | - | ||||||||||||||||||
242 | int ret = 0, n, i; | - | ||||||||||||||||||
243 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
244 | BIO *next; | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | ctx = BIO_get_data(b); | - | ||||||||||||||||||
247 | next = BIO_next(b); | - | ||||||||||||||||||
248 | if ((
| 0-6255 | ||||||||||||||||||
249 | ((void *)0)
| 0-6255 | ||||||||||||||||||
250 | )
| 0-6255 | ||||||||||||||||||
251 | ((void *)0)
| 0-6255 | ||||||||||||||||||
252 | )
| 0-6255 | ||||||||||||||||||
253 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | ret = inl; | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
258 | n = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
259 | while (n > 0
| 313-6255 | ||||||||||||||||||
260 | i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n); | - | ||||||||||||||||||
261 | if (i <= 0
| 0-313 | ||||||||||||||||||
262 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
263 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||
264 | } | - | ||||||||||||||||||
265 | ctx->buf_off += i; | - | ||||||||||||||||||
266 | n -= i; | - | ||||||||||||||||||
267 | } executed 313 times by 1 test: end of block Executed by:
| 313 | ||||||||||||||||||
268 | - | |||||||||||||||||||
269 | - | |||||||||||||||||||
270 | if ((
| 313-5942 | ||||||||||||||||||
271 | ((void *)0)
| 313-5942 | ||||||||||||||||||
272 | )
| 0-5942 | ||||||||||||||||||
273 | return executed 313 times by 1 test: 0;return 0; Executed by:
executed 313 times by 1 test: return 0; Executed by:
| 313 | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | ctx->buf_off = 0; | - | ||||||||||||||||||
276 | while (inl > 0
| 5942 | ||||||||||||||||||
277 | n = (
| 0-5942 | ||||||||||||||||||
278 | if (!EVP_CipherUpdate(ctx->cipher,
| 0-5942 | ||||||||||||||||||
279 | ctx->buf, &ctx->buf_len,
| 0-5942 | ||||||||||||||||||
280 | (const unsigned char *)in, n)
| 0-5942 | ||||||||||||||||||
281 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
282 | ctx->ok = 0; | - | ||||||||||||||||||
283 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
284 | } | - | ||||||||||||||||||
285 | inl -= n; | - | ||||||||||||||||||
286 | in += n; | - | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | ctx->buf_off = 0; | - | ||||||||||||||||||
289 | n = ctx->buf_len; | - | ||||||||||||||||||
290 | while (n > 0
| 5896-5942 | ||||||||||||||||||
291 | i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n); | - | ||||||||||||||||||
292 | if (i <= 0
| 0-5896 | ||||||||||||||||||
293 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
294 | return never executed: (return (ret == inl) ? i : ret - inl;
never executed: return (ret == inl) ? i : ret - inl; | 0 | ||||||||||||||||||
295 | } | - | ||||||||||||||||||
296 | n -= i; | - | ||||||||||||||||||
297 | ctx->buf_off += i; | - | ||||||||||||||||||
298 | } executed 5896 times by 1 test: end of block Executed by:
| 5896 | ||||||||||||||||||
299 | ctx->buf_len = 0; | - | ||||||||||||||||||
300 | ctx->buf_off = 0; | - | ||||||||||||||||||
301 | } executed 5942 times by 1 test: end of block Executed by:
| 5942 | ||||||||||||||||||
302 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
303 | return executed 5942 times by 1 test: ret;return ret; Executed by:
executed 5942 times by 1 test: return ret; Executed by:
| 5942 | ||||||||||||||||||
304 | } | - | ||||||||||||||||||
305 | - | |||||||||||||||||||
306 | static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||||||||
307 | { | - | ||||||||||||||||||
308 | BIO *dbio; | - | ||||||||||||||||||
309 | BIO_ENC_CTX *ctx, *dctx; | - | ||||||||||||||||||
310 | long ret = 1; | - | ||||||||||||||||||
311 | int i; | - | ||||||||||||||||||
312 | EVP_CIPHER_CTX **c_ctx; | - | ||||||||||||||||||
313 | BIO *next; | - | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | ctx = BIO_get_data(b); | - | ||||||||||||||||||
316 | next = BIO_next(b); | - | ||||||||||||||||||
317 | if (ctx ==
| 0-39033 | ||||||||||||||||||
318 | ((void *)0)
| 0-39033 | ||||||||||||||||||
319 | ) | - | ||||||||||||||||||
320 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | switch (cmd) { | - | ||||||||||||||||||
323 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||||||||
324 | ctx->ok = 1; | - | ||||||||||||||||||
325 | ctx->finished = 0; | - | ||||||||||||||||||
326 | if (!EVP_CipherInit_ex(ctx->cipher,
| 0 | ||||||||||||||||||
327 | ((void *)0)
| 0 | ||||||||||||||||||
328 | ,
| 0 | ||||||||||||||||||
329 | ((void *)0)
| 0 | ||||||||||||||||||
330 | ,
| 0 | ||||||||||||||||||
331 | ((void *)0)
| 0 | ||||||||||||||||||
332 | ,
| 0 | ||||||||||||||||||
333 | ((void *)0)
| 0 | ||||||||||||||||||
334 | ,
| 0 | ||||||||||||||||||
335 | EVP_CIPHER_CTX_encrypting(ctx->cipher))
| 0 | ||||||||||||||||||
336 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
337 | ret = BIO_ctrl(next, cmd, num, ptr); | - | ||||||||||||||||||
338 | break; never executed: break; | 0 | ||||||||||||||||||
339 | case never executed: 2:case 2: never executed: case 2: | 0 | ||||||||||||||||||
340 | if (ctx->cont <= 0
| 0 | ||||||||||||||||||
341 | ret = 1; never executed: ret = 1; | 0 | ||||||||||||||||||
342 | else | - | ||||||||||||||||||
343 | ret = BIO_ctrl(next, cmd, num, ptr); never executed: ret = BIO_ctrl(next, cmd, num, ptr); | 0 | ||||||||||||||||||
344 | break; never executed: break; | 0 | ||||||||||||||||||
345 | case never executed: 13:case 13: never executed: case 13: | 0 | ||||||||||||||||||
346 | ret = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
347 | if (ret <= 0
| 0 | ||||||||||||||||||
348 | ret = BIO_ctrl(next, cmd, num, ptr); never executed: ret = BIO_ctrl(next, cmd, num, ptr); | 0 | ||||||||||||||||||
349 | break; never executed: break; | 0 | ||||||||||||||||||
350 | case never executed: 10:case 10: never executed: case 10: | 0 | ||||||||||||||||||
351 | ret = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
352 | if (ret <= 0
| 0 | ||||||||||||||||||
353 | ret = BIO_ctrl(next, cmd, num, ptr); never executed: ret = BIO_ctrl(next, cmd, num, ptr); | 0 | ||||||||||||||||||
354 | break; never executed: break; | 0 | ||||||||||||||||||
355 | case executed 670 times by 1 test: 11:case 11: Executed by:
executed 670 times by 1 test: case 11: Executed by:
| 670 | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | again: | - | ||||||||||||||||||
358 | while (ctx->buf_len != ctx->buf_off
| 313-1310 | ||||||||||||||||||
359 | i = enc_write(b, | - | ||||||||||||||||||
360 | ((void *)0) | - | ||||||||||||||||||
361 | , 0); | - | ||||||||||||||||||
362 | if (i < 0
| 0-313 | ||||||||||||||||||
363 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||
364 | } executed 313 times by 1 test: end of block Executed by:
| 313 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | if (!ctx->finished
| 642-668 | ||||||||||||||||||
367 | ctx->finished = 1; | - | ||||||||||||||||||
368 | ctx->buf_off = 0; | - | ||||||||||||||||||
369 | ret = EVP_CipherFinal_ex(ctx->cipher, | - | ||||||||||||||||||
370 | (unsigned char *)ctx->buf, | - | ||||||||||||||||||
371 | &(ctx->buf_len)); | - | ||||||||||||||||||
372 | ctx->ok = (int)ret; | - | ||||||||||||||||||
373 | if (ret <= 0
| 2-640 | ||||||||||||||||||
374 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | - | |||||||||||||||||||
377 | goto executed 640 times by 1 test: again;goto again; Executed by:
executed 640 times by 1 test: goto again; Executed by:
| 640 | ||||||||||||||||||
378 | } | - | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | - | |||||||||||||||||||
381 | ret = BIO_ctrl(next, cmd, num, ptr); | - | ||||||||||||||||||
382 | break; executed 668 times by 1 test: break; Executed by:
| 668 | ||||||||||||||||||
383 | case executed 28 times by 1 test: 113:case 113: Executed by:
executed 28 times by 1 test: case 113: Executed by:
| 28 | ||||||||||||||||||
384 | ret = (long)ctx->ok; | - | ||||||||||||||||||
385 | break; executed 28 times by 1 test: break; Executed by:
| 28 | ||||||||||||||||||
386 | case never executed: 101:case 101: never executed: case 101: | 0 | ||||||||||||||||||
387 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
388 | ret = BIO_ctrl(next, cmd, num, ptr); | - | ||||||||||||||||||
389 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
390 | break; never executed: break; | 0 | ||||||||||||||||||
391 | case executed 658 times by 1 test: 129:case 129: Executed by:
executed 658 times by 1 test: case 129: Executed by:
| 658 | ||||||||||||||||||
392 | c_ctx = (EVP_CIPHER_CTX **)ptr; | - | ||||||||||||||||||
393 | *c_ctx = ctx->cipher; | - | ||||||||||||||||||
394 | BIO_set_init(b, 1); | - | ||||||||||||||||||
395 | break; executed 658 times by 1 test: break; Executed by:
| 658 | ||||||||||||||||||
396 | case never executed: 12:case 12: never executed: case 12: | 0 | ||||||||||||||||||
397 | dbio = (BIO *)ptr; | - | ||||||||||||||||||
398 | dctx = BIO_get_data(dbio); | - | ||||||||||||||||||
399 | dctx->cipher = EVP_CIPHER_CTX_new(); | - | ||||||||||||||||||
400 | if (dctx->cipher ==
| 0 | ||||||||||||||||||
401 | ((void *)0)
| 0 | ||||||||||||||||||
402 | ) | - | ||||||||||||||||||
403 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
404 | ret = EVP_CIPHER_CTX_copy(dctx->cipher, ctx->cipher); | - | ||||||||||||||||||
405 | if (ret
| 0 | ||||||||||||||||||
406 | BIO_set_init(dbio, 1); never executed: BIO_set_init(dbio, 1); | 0 | ||||||||||||||||||
407 | break; never executed: break; | 0 | ||||||||||||||||||
408 | default executed 37677 times by 1 test: :default: Executed by:
executed 37677 times by 1 test: default: Executed by:
| 37677 | ||||||||||||||||||
409 | ret = BIO_ctrl(next, cmd, num, ptr); | - | ||||||||||||||||||
410 | break; executed 37677 times by 1 test: break; Executed by:
| 37677 | ||||||||||||||||||
411 | } | - | ||||||||||||||||||
412 | return executed 39033 times by 1 test: ret;return ret; Executed by:
executed 39033 times by 1 test: return ret; Executed by:
| 39033 | ||||||||||||||||||
413 | } | - | ||||||||||||||||||
414 | - | |||||||||||||||||||
415 | static long enc_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) | - | ||||||||||||||||||
416 | { | - | ||||||||||||||||||
417 | long ret = 1; | - | ||||||||||||||||||
418 | BIO *next = BIO_next(b); | - | ||||||||||||||||||
419 | - | |||||||||||||||||||
420 | if (next ==
| 0 | ||||||||||||||||||
421 | ((void *)0)
| 0 | ||||||||||||||||||
422 | ) | - | ||||||||||||||||||
423 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
424 | switch (cmd) { | - | ||||||||||||||||||
425 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
426 | ret = BIO_callback_ctrl(next, cmd, fp); | - | ||||||||||||||||||
427 | break; never executed: break; | 0 | ||||||||||||||||||
428 | } | - | ||||||||||||||||||
429 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
430 | } | - | ||||||||||||||||||
431 | - | |||||||||||||||||||
432 | int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, | - | ||||||||||||||||||
433 | const unsigned char *i, int e) | - | ||||||||||||||||||
434 | { | - | ||||||||||||||||||
435 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
436 | long (*callback) (struct bio_st *, int, const char *, int, long, long); | - | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | ctx = BIO_get_data(b); | - | ||||||||||||||||||
439 | if (ctx ==
| 0-36936 | ||||||||||||||||||
440 | ((void *)0)
| 0-36936 | ||||||||||||||||||
441 | ) | - | ||||||||||||||||||
442 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
443 | - | |||||||||||||||||||
444 | callback = BIO_get_callback(b); | - | ||||||||||||||||||
445 | - | |||||||||||||||||||
446 | if ((
| 0-36936 | ||||||||||||||||||
447 | ((void *)0)
| 0-36936 | ||||||||||||||||||
448 | )
| 0-36936 | ||||||||||||||||||
449 | (
| 0 | ||||||||||||||||||
450 | 0L) <= 0)
| 0 | ||||||||||||||||||
451 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
452 | - | |||||||||||||||||||
453 | BIO_set_init(b, 1); | - | ||||||||||||||||||
454 | - | |||||||||||||||||||
455 | if (!EVP_CipherInit_ex(ctx->cipher, c,
| 0-36936 | ||||||||||||||||||
456 | ((void *)0)
| 0-36936 | ||||||||||||||||||
457 | , k, i, e)
| 0-36936 | ||||||||||||||||||
458 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
459 | - | |||||||||||||||||||
460 | if (callback !=
| 0-36936 | ||||||||||||||||||
461 | ((void *)0)
| 0-36936 | ||||||||||||||||||
462 | ) | - | ||||||||||||||||||
463 | return never executed: callback(b, 0x06, (const char *)c, 4, e, 1L);return callback(b, 0x06, (const char *)c, 4, e, 1L); never executed: return callback(b, 0x06, (const char *)c, 4, e, 1L); | 0 | ||||||||||||||||||
464 | return executed 36936 times by 1 test: 1;return 1; Executed by:
executed 36936 times by 1 test: return 1; Executed by:
| 36936 | ||||||||||||||||||
465 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |