Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/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 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||||||||
8 | static int enc_new(BIO *h); | - | ||||||||||||||||||
9 | static int enc_free(BIO *data); | - | ||||||||||||||||||
10 | static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps); | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | typedef struct enc_struct { | - | ||||||||||||||||||
15 | int buf_len; | - | ||||||||||||||||||
16 | int buf_off; | - | ||||||||||||||||||
17 | int cont; | - | ||||||||||||||||||
18 | int finished; | - | ||||||||||||||||||
19 | int ok; | - | ||||||||||||||||||
20 | EVP_CIPHER_CTX cipher; | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | - | |||||||||||||||||||
23 | - | |||||||||||||||||||
24 | char buf[(1024*4) + (32*2) + 2]; | - | ||||||||||||||||||
25 | } BIO_ENC_CTX; | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | static const BIO_METHOD methods_enc = { | - | ||||||||||||||||||
28 | .type = (10|0x0200), | - | ||||||||||||||||||
29 | .name = "cipher", | - | ||||||||||||||||||
30 | .bwrite = enc_write, | - | ||||||||||||||||||
31 | .bread = enc_read, | - | ||||||||||||||||||
32 | .ctrl = enc_ctrl, | - | ||||||||||||||||||
33 | .create = enc_new, | - | ||||||||||||||||||
34 | .destroy = enc_free, | - | ||||||||||||||||||
35 | .callback_ctrl = enc_callback_ctrl | - | ||||||||||||||||||
36 | }; | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | const BIO_METHOD * | - | ||||||||||||||||||
39 | BIO_f_cipher(void) | - | ||||||||||||||||||
40 | { | - | ||||||||||||||||||
41 | return executed 198 times by 2 tests: (&methods_enc);return (&methods_enc); Executed by:
executed 198 times by 2 tests: return (&methods_enc); Executed by:
| 198 | ||||||||||||||||||
42 | } | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | static int | - | ||||||||||||||||||
45 | enc_new(BIO *bi) | - | ||||||||||||||||||
46 | { | - | ||||||||||||||||||
47 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | ctx = malloc(sizeof(BIO_ENC_CTX)); | - | ||||||||||||||||||
50 | if (ctx ==
| 0-198 | ||||||||||||||||||
51 | ((void *)0)
| 0-198 | ||||||||||||||||||
52 | ) | - | ||||||||||||||||||
53 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||
54 | EVP_CIPHER_CTX_init(&ctx->cipher); | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | ctx->buf_len = 0; | - | ||||||||||||||||||
57 | ctx->buf_off = 0; | - | ||||||||||||||||||
58 | ctx->cont = 1; | - | ||||||||||||||||||
59 | ctx->finished = 0; | - | ||||||||||||||||||
60 | ctx->ok = 1; | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | bi->init = 0; | - | ||||||||||||||||||
63 | bi->ptr = (char *)ctx; | - | ||||||||||||||||||
64 | bi->flags = 0; | - | ||||||||||||||||||
65 | return executed 198 times by 2 tests: (1);return (1); Executed by:
executed 198 times by 2 tests: return (1); Executed by:
| 198 | ||||||||||||||||||
66 | } | - | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | static int | - | ||||||||||||||||||
69 | enc_free(BIO *a) | - | ||||||||||||||||||
70 | { | - | ||||||||||||||||||
71 | BIO_ENC_CTX *b; | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | if (a ==
| 0-198 | ||||||||||||||||||
74 | ((void *)0)
| 0-198 | ||||||||||||||||||
75 | ) | - | ||||||||||||||||||
76 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||
77 | b = (BIO_ENC_CTX *)a->ptr; | - | ||||||||||||||||||
78 | EVP_CIPHER_CTX_cleanup(&(b->cipher)); | - | ||||||||||||||||||
79 | freezero(a->ptr, sizeof(BIO_ENC_CTX)); | - | ||||||||||||||||||
80 | a->ptr = | - | ||||||||||||||||||
81 | ((void *)0) | - | ||||||||||||||||||
82 | ; | - | ||||||||||||||||||
83 | a->init = 0; | - | ||||||||||||||||||
84 | a->flags = 0; | - | ||||||||||||||||||
85 | return executed 198 times by 2 tests: (1);return (1); Executed by:
executed 198 times by 2 tests: return (1); Executed by:
| 198 | ||||||||||||||||||
86 | } | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | static int | - | ||||||||||||||||||
89 | enc_read(BIO *b, char *out, int outl) | - | ||||||||||||||||||
90 | { | - | ||||||||||||||||||
91 | int ret = 0, i; | - | ||||||||||||||||||
92 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | if (out ==
| 0-2 | ||||||||||||||||||
95 | ((void *)0)
| 0-2 | ||||||||||||||||||
96 | ) | - | ||||||||||||||||||
97 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||
98 | ctx = (BIO_ENC_CTX *)b->ptr; | - | ||||||||||||||||||
99 | - | |||||||||||||||||||
100 | if ((
| 0-2 | ||||||||||||||||||
101 | ((void *)0)
| 0-2 | ||||||||||||||||||
102 | )
| 0-2 | ||||||||||||||||||
103 | ((void *)0)
| 0-2 | ||||||||||||||||||
104 | )
| 0-2 | ||||||||||||||||||
105 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | - | |||||||||||||||||||
108 | if (ctx->buf_len > 0
| 1 | ||||||||||||||||||
109 | i = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
110 | if (i > outl
| 0-1 | ||||||||||||||||||
111 | i = outl; never executed: i = outl; | 0 | ||||||||||||||||||
112 | memcpy(out, &(ctx->buf[ctx->buf_off]), i); | - | ||||||||||||||||||
113 | ret = i; | - | ||||||||||||||||||
114 | out += i; | - | ||||||||||||||||||
115 | outl -= i; | - | ||||||||||||||||||
116 | ctx->buf_off += i; | - | ||||||||||||||||||
117 | if (ctx->buf_len == ctx->buf_off
| 0-1 | ||||||||||||||||||
118 | ctx->buf_len = 0; | - | ||||||||||||||||||
119 | ctx->buf_off = 0; | - | ||||||||||||||||||
120 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
121 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
122 | - | |||||||||||||||||||
123 | - | |||||||||||||||||||
124 | - | |||||||||||||||||||
125 | - | |||||||||||||||||||
126 | while (outl > 0
| 0-4 | ||||||||||||||||||
127 | if (ctx->cont <= 0
| 2 | ||||||||||||||||||
128 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | - | |||||||||||||||||||
131 | - | |||||||||||||||||||
132 | i = BIO_read(b->next_bio, &(ctx->buf[(32*2)]), (1024*4)); | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | if (i <= 0
| 1 | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | if (!BIO_test_flags(b->next_bio, 0x08)
| 0-1 | ||||||||||||||||||
137 | ctx->cont = i; | - | ||||||||||||||||||
138 | i = EVP_CipherFinal_ex(&(ctx->cipher), | - | ||||||||||||||||||
139 | (unsigned char *)ctx->buf, | - | ||||||||||||||||||
140 | &(ctx->buf_len)); | - | ||||||||||||||||||
141 | ctx->ok = i; | - | ||||||||||||||||||
142 | ctx->buf_off = 0; | - | ||||||||||||||||||
143 | } executed 1 time by 1 test: else {end of block Executed by:
| 1 | ||||||||||||||||||
144 | ret = (
| 0 | ||||||||||||||||||
145 | break; never executed: break; | 0 | ||||||||||||||||||
146 | } | - | ||||||||||||||||||
147 | } else { | - | ||||||||||||||||||
148 | EVP_CipherUpdate(&(ctx->cipher), | - | ||||||||||||||||||
149 | (unsigned char *)ctx->buf, &ctx->buf_len, | - | ||||||||||||||||||
150 | (unsigned char *)&(ctx->buf[(32*2)]), i); | - | ||||||||||||||||||
151 | ctx->cont = 1; | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | - | |||||||||||||||||||
154 | - | |||||||||||||||||||
155 | - | |||||||||||||||||||
156 | - | |||||||||||||||||||
157 | - | |||||||||||||||||||
158 | if (ctx->buf_len == 0
| 0-1 | ||||||||||||||||||
159 | continue; never executed: continue; | 0 | ||||||||||||||||||
160 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | if (ctx->buf_len <= outl
| 0-2 | ||||||||||||||||||
163 | i = ctx->buf_len; executed 2 times by 1 test: i = ctx->buf_len; Executed by:
| 2 | ||||||||||||||||||
164 | else | - | ||||||||||||||||||
165 | i = outl; never executed: i = outl; | 0 | ||||||||||||||||||
166 | if (i <= 0
| 0-2 | ||||||||||||||||||
167 | break; never executed: break; | 0 | ||||||||||||||||||
168 | memcpy(out, ctx->buf, i); | - | ||||||||||||||||||
169 | ret += i; | - | ||||||||||||||||||
170 | ctx->buf_off = i; | - | ||||||||||||||||||
171 | outl -= i; | - | ||||||||||||||||||
172 | out += i; | - | ||||||||||||||||||
173 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
176 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
177 | return executed 2 times by 1 test: ((return ((ret == 0) ? ctx->cont : ret); Executed by:
executed 2 times by 1 test: return ((ret == 0) ? ctx->cont : ret); Executed by:
| 1-2 | ||||||||||||||||||
178 | } | - | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | static int | - | ||||||||||||||||||
181 | enc_write(BIO *b, const char *in, int inl) | - | ||||||||||||||||||
182 | { | - | ||||||||||||||||||
183 | int ret = 0, n, i; | - | ||||||||||||||||||
184 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
185 | - | |||||||||||||||||||
186 | ctx = (BIO_ENC_CTX *)b->ptr; | - | ||||||||||||||||||
187 | ret = inl; | - | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
190 | n = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
191 | while (n > 0
| 57-254 | ||||||||||||||||||
192 | i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); | - | ||||||||||||||||||
193 | if (i <= 0
| 0-57 | ||||||||||||||||||
194 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
195 | return never executed: (i);return (i); never executed: return (i); | 0 | ||||||||||||||||||
196 | } | - | ||||||||||||||||||
197 | ctx->buf_off += i; | - | ||||||||||||||||||
198 | n -= i; | - | ||||||||||||||||||
199 | } executed 57 times by 2 tests: end of block Executed by:
| 57 | ||||||||||||||||||
200 | - | |||||||||||||||||||
201 | - | |||||||||||||||||||
202 | if ((
| 57-197 | ||||||||||||||||||
203 | ((void *)0)
| 57-197 | ||||||||||||||||||
204 | )
| 0-197 | ||||||||||||||||||
205 | return executed 57 times by 2 tests: (0);return (0); Executed by:
executed 57 times by 2 tests: return (0); Executed by:
| 57 | ||||||||||||||||||
206 | - | |||||||||||||||||||
207 | ctx->buf_off = 0; | - | ||||||||||||||||||
208 | while (inl > 0
| 197 | ||||||||||||||||||
209 | n = (
| 0-197 | ||||||||||||||||||
210 | EVP_CipherUpdate(&(ctx->cipher), | - | ||||||||||||||||||
211 | (unsigned char *)ctx->buf, &ctx->buf_len, | - | ||||||||||||||||||
212 | (unsigned char *)in, n); | - | ||||||||||||||||||
213 | inl -= n; | - | ||||||||||||||||||
214 | in += n; | - | ||||||||||||||||||
215 | - | |||||||||||||||||||
216 | ctx->buf_off = 0; | - | ||||||||||||||||||
217 | n = ctx->buf_len; | - | ||||||||||||||||||
218 | while (n > 0
| 197 | ||||||||||||||||||
219 | i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); | - | ||||||||||||||||||
220 | if (i <= 0
| 0-197 | ||||||||||||||||||
221 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
222 | return never executed: (return (ret == inl) ? i : ret - inl;
never executed: return (ret == inl) ? i : ret - inl; | 0 | ||||||||||||||||||
223 | } | - | ||||||||||||||||||
224 | n -= i; | - | ||||||||||||||||||
225 | ctx->buf_off += i; | - | ||||||||||||||||||
226 | } executed 197 times by 2 tests: end of block Executed by:
| 197 | ||||||||||||||||||
227 | ctx->buf_len = 0; | - | ||||||||||||||||||
228 | ctx->buf_off = 0; | - | ||||||||||||||||||
229 | } executed 197 times by 2 tests: end of block Executed by:
| 197 | ||||||||||||||||||
230 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
231 | return executed 197 times by 2 tests: (ret);return (ret); Executed by:
executed 197 times by 2 tests: return (ret); Executed by:
| 197 | ||||||||||||||||||
232 | } | - | ||||||||||||||||||
233 | - | |||||||||||||||||||
234 | static long | - | ||||||||||||||||||
235 | enc_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||||||||
236 | { | - | ||||||||||||||||||
237 | BIO *dbio; | - | ||||||||||||||||||
238 | BIO_ENC_CTX *ctx, *dctx; | - | ||||||||||||||||||
239 | long ret = 1; | - | ||||||||||||||||||
240 | int i; | - | ||||||||||||||||||
241 | EVP_CIPHER_CTX **c_ctx; | - | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | ctx = (BIO_ENC_CTX *)b->ptr; | - | ||||||||||||||||||
244 | - | |||||||||||||||||||
245 | switch (cmd) { | - | ||||||||||||||||||
246 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||||||||
247 | ctx->ok = 1; | - | ||||||||||||||||||
248 | ctx->finished = 0; | - | ||||||||||||||||||
249 | EVP_CipherInit_ex(&(ctx->cipher), | - | ||||||||||||||||||
250 | ((void *)0) | - | ||||||||||||||||||
251 | , | - | ||||||||||||||||||
252 | ((void *)0) | - | ||||||||||||||||||
253 | , | - | ||||||||||||||||||
254 | ((void *)0) | - | ||||||||||||||||||
255 | , | - | ||||||||||||||||||
256 | ((void *)0) | - | ||||||||||||||||||
257 | , | - | ||||||||||||||||||
258 | ctx->cipher.encrypt); | - | ||||||||||||||||||
259 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||
260 | break; never executed: break; | 0 | ||||||||||||||||||
261 | case never executed: 2:case 2: never executed: case 2: | 0 | ||||||||||||||||||
262 | if (ctx->cont <= 0
| 0 | ||||||||||||||||||
263 | ret = 1; never executed: ret = 1; | 0 | ||||||||||||||||||
264 | else | - | ||||||||||||||||||
265 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | 0 | ||||||||||||||||||
266 | break; never executed: break; | 0 | ||||||||||||||||||
267 | case never executed: 13:case 13: never executed: case 13: | 0 | ||||||||||||||||||
268 | ret = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
269 | if (ret <= 0
| 0 | ||||||||||||||||||
270 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | 0 | ||||||||||||||||||
271 | break; never executed: break; | 0 | ||||||||||||||||||
272 | case never executed: 10:case 10: never executed: case 10: | 0 | ||||||||||||||||||
273 | ret = ctx->buf_len - ctx->buf_off; | - | ||||||||||||||||||
274 | if (ret <= 0
| 0 | ||||||||||||||||||
275 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | 0 | ||||||||||||||||||
276 | break; never executed: break; | 0 | ||||||||||||||||||
277 | case executed 198 times by 2 tests: 11:case 11: Executed by:
executed 198 times by 2 tests: case 11: Executed by:
| 198 | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | again: | - | ||||||||||||||||||
280 | while (ctx->buf_len != ctx->buf_off
| 57-395 | ||||||||||||||||||
281 | i = enc_write(b, | - | ||||||||||||||||||
282 | ((void *)0) | - | ||||||||||||||||||
283 | , 0); | - | ||||||||||||||||||
284 | if (i < 0
| 0-57 | ||||||||||||||||||
285 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||
286 | } executed 57 times by 2 tests: end of block Executed by:
| 57 | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | if (!ctx->finished
| 197-198 | ||||||||||||||||||
289 | ctx->finished = 1; | - | ||||||||||||||||||
290 | ctx->buf_off = 0; | - | ||||||||||||||||||
291 | ret = EVP_CipherFinal_ex(&(ctx->cipher), | - | ||||||||||||||||||
292 | (unsigned char *)ctx->buf, | - | ||||||||||||||||||
293 | &(ctx->buf_len)); | - | ||||||||||||||||||
294 | ctx->ok = (int)ret; | - | ||||||||||||||||||
295 | if (ret <= 0
| 0-197 | ||||||||||||||||||
296 | break; never executed: break; | 0 | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | - | |||||||||||||||||||
299 | goto executed 197 times by 2 tests: again;goto again; Executed by:
executed 197 times by 2 tests: goto again; Executed by:
| 197 | ||||||||||||||||||
300 | } | - | ||||||||||||||||||
301 | - | |||||||||||||||||||
302 | - | |||||||||||||||||||
303 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||
304 | break; executed 198 times by 2 tests: break; Executed by:
| 198 | ||||||||||||||||||
305 | case executed 1 time by 1 test: 113:case 113: Executed by:
executed 1 time by 1 test: case 113: Executed by:
| 1 | ||||||||||||||||||
306 | ret = (long)ctx->ok; | - | ||||||||||||||||||
307 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||
308 | case never executed: 101:case 101: never executed: case 101: | 0 | ||||||||||||||||||
309 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||
310 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||
311 | BIO_copy_next_retry(b); | - | ||||||||||||||||||
312 | break; never executed: break; | 0 | ||||||||||||||||||
313 | case executed 198 times by 2 tests: 129:case 129: Executed by:
executed 198 times by 2 tests: case 129: Executed by:
| 198 | ||||||||||||||||||
314 | c_ctx = (EVP_CIPHER_CTX **)ptr; | - | ||||||||||||||||||
315 | (*c_ctx) = &(ctx->cipher); | - | ||||||||||||||||||
316 | b->init = 1; | - | ||||||||||||||||||
317 | break; executed 198 times by 2 tests: break; Executed by:
| 198 | ||||||||||||||||||
318 | case never executed: 12:case 12: never executed: case 12: | 0 | ||||||||||||||||||
319 | dbio = (BIO *)ptr; | - | ||||||||||||||||||
320 | dctx = (BIO_ENC_CTX *)dbio->ptr; | - | ||||||||||||||||||
321 | EVP_CIPHER_CTX_init(&dctx->cipher); | - | ||||||||||||||||||
322 | ret = EVP_CIPHER_CTX_copy(&dctx->cipher, &ctx->cipher); | - | ||||||||||||||||||
323 | if (ret
| 0 | ||||||||||||||||||
324 | dbio->init = 1; never executed: dbio->init = 1; | 0 | ||||||||||||||||||
325 | break; never executed: break; | 0 | ||||||||||||||||||
326 | default executed 200 times by 2 tests: :default: Executed by:
executed 200 times by 2 tests: default: Executed by:
| 200 | ||||||||||||||||||
327 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||
328 | break; executed 200 times by 2 tests: break; Executed by:
| 200 | ||||||||||||||||||
329 | } | - | ||||||||||||||||||
330 | return executed 597 times by 2 tests: (ret);return (ret); Executed by:
executed 597 times by 2 tests: return (ret); Executed by:
| 597 | ||||||||||||||||||
331 | } | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | static long | - | ||||||||||||||||||
334 | enc_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | - | ||||||||||||||||||
335 | { | - | ||||||||||||||||||
336 | long ret = 1; | - | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | if (b->next_bio ==
| 0 | ||||||||||||||||||
339 | ((void *)0)
| 0 | ||||||||||||||||||
340 | ) | - | ||||||||||||||||||
341 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||
342 | switch (cmd) { | - | ||||||||||||||||||
343 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
344 | ret = BIO_callback_ctrl(b->next_bio, cmd, fp); | - | ||||||||||||||||||
345 | break; never executed: break; | 0 | ||||||||||||||||||
346 | } | - | ||||||||||||||||||
347 | return never executed: (ret);return (ret); never executed: return (ret); | 0 | ||||||||||||||||||
348 | } | - | ||||||||||||||||||
349 | int | - | ||||||||||||||||||
350 | BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, | - | ||||||||||||||||||
351 | const unsigned char *i, int e) | - | ||||||||||||||||||
352 | { | - | ||||||||||||||||||
353 | BIO_ENC_CTX *ctx; | - | ||||||||||||||||||
354 | long (*cb)(BIO *, int, const char *, int, long, long); | - | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | if (b ==
| 0 | ||||||||||||||||||
357 | ((void *)0)
| 0 | ||||||||||||||||||
358 | ) | - | ||||||||||||||||||
359 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | if ((
| 0 | ||||||||||||||||||
362 | ((void *)0)
| 0 | ||||||||||||||||||
363 | ) | - | ||||||||||||||||||
364 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | if ((
| 0 | ||||||||||||||||||
367 | ((void *)0)
| 0 | ||||||||||||||||||
368 | ) { | - | ||||||||||||||||||
369 | if (cb(b, 0x06, (const char *)c, 4, e, 0L)
| 0 | ||||||||||||||||||
370 | <= 0
| 0 | ||||||||||||||||||
371 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
372 | } never executed: end of block | 0 | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | BIO_set_init(b, 1); | - | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | if (!EVP_CipherInit_ex(&(ctx->cipher), c,
| 0 | ||||||||||||||||||
377 | ((void *)0)
| 0 | ||||||||||||||||||
378 | , k, i, e)
| 0 | ||||||||||||||||||
379 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
380 | - | |||||||||||||||||||
381 | if (cb !=
| 0 | ||||||||||||||||||
382 | ((void *)0)
| 0 | ||||||||||||||||||
383 | ) | - | ||||||||||||||||||
384 | return never executed: cb(b, 0x06, (const char *)c, 4, e, 1L);return cb(b, 0x06, (const char *)c, 4, e, 1L); never executed: return cb(b, 0x06, (const char *)c, 4, e, 1L); | 0 | ||||||||||||||||||
385 | - | |||||||||||||||||||
386 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
387 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |