Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/evp_enc.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | int | - | ||||||||||||||||||||||||
12 | EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | - | ||||||||||||||||||||||||
13 | const unsigned char *key, const unsigned char *iv, int enc) | - | ||||||||||||||||||||||||
14 | { | - | ||||||||||||||||||||||||
15 | if (cipher
| 0 | ||||||||||||||||||||||||
16 | EVP_CIPHER_CTX_init(ctx); never executed: EVP_CIPHER_CTX_init(ctx); | 0 | ||||||||||||||||||||||||
17 | return never executed: EVP_CipherInit_ex(ctx, cipher, return EVP_CipherInit_ex(ctx, cipher, ((void *)0) , key, iv, enc); never executed: return EVP_CipherInit_ex(ctx, cipher, ((void *)0) , key, iv, enc); | 0 | ||||||||||||||||||||||||
18 | ((void *)0) never executed: return EVP_CipherInit_ex(ctx, cipher, ((void *)0) , key, iv, enc); | 0 | ||||||||||||||||||||||||
19 | , key, iv, enc); never executed: return EVP_CipherInit_ex(ctx, cipher, ((void *)0) , key, iv, enc); | 0 | ||||||||||||||||||||||||
20 | } | - | ||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | int | - | ||||||||||||||||||||||||
23 | EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | - | ||||||||||||||||||||||||
24 | const unsigned char *key, const unsigned char *iv, int enc) | - | ||||||||||||||||||||||||
25 | { | - | ||||||||||||||||||||||||
26 | if (enc == -1
| 0-878 | ||||||||||||||||||||||||
27 | enc = ctx->encrypt; never executed: enc = ctx->encrypt; | 0 | ||||||||||||||||||||||||
28 | else { | - | ||||||||||||||||||||||||
29 | if (enc
| 392-486 | ||||||||||||||||||||||||
30 | enc = 1; executed 486 times by 5 tests: enc = 1; Executed by:
| 486 | ||||||||||||||||||||||||
31 | ctx->encrypt = enc; | - | ||||||||||||||||||||||||
32 | } executed 878 times by 5 tests: end of block Executed by:
| 878 | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | if (ctx->engine
| 0-878 | ||||||||||||||||||||||||
39 | (!cipher
| 0 | ||||||||||||||||||||||||
40 | goto never executed: skip_to_init;goto skip_to_init; never executed: goto skip_to_init; | 0 | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | if (cipher
| 198-680 | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | if (ctx->cipher
| 66-614 | ||||||||||||||||||||||||
47 | unsigned long flags = ctx->flags; | - | ||||||||||||||||||||||||
48 | EVP_CIPHER_CTX_cleanup(ctx); | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | ctx->encrypt = enc; | - | ||||||||||||||||||||||||
51 | ctx->flags = flags; | - | ||||||||||||||||||||||||
52 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | if (impl
| 0-680 | ||||||||||||||||||||||||
55 | if (!ENGINE_init(impl)
| 0 | ||||||||||||||||||||||||
56 | ERR_put_error(6,(0xfff),(134),__FILE__,121); | - | ||||||||||||||||||||||||
57 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
58 | } | - | ||||||||||||||||||||||||
59 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | impl = ENGINE_get_cipher_engine(cipher->nid); executed 680 times by 5 tests: impl = ENGINE_get_cipher_engine(cipher->nid); Executed by:
| 680 | ||||||||||||||||||||||||
62 | if (impl
| 0-680 | ||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | const EVP_CIPHER *c = | - | ||||||||||||||||||||||||
65 | ENGINE_get_cipher(impl, cipher->nid); | - | ||||||||||||||||||||||||
66 | if (!c
| 0 | ||||||||||||||||||||||||
67 | ERR_put_error(6,(0xfff),(134),__FILE__,132); | - | ||||||||||||||||||||||||
68 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
69 | } | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | cipher = c; | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | ctx->engine = impl; | - | ||||||||||||||||||||||||
76 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
77 | ctx->engine = executed 680 times by 5 tests: ctx->engine = ((void *)0) ; Executed by:
| 680 | ||||||||||||||||||||||||
78 | ((void *)0) executed 680 times by 5 tests: ctx->engine = ((void *)0) ; Executed by:
| 680 | ||||||||||||||||||||||||
79 | ; executed 680 times by 5 tests: ctx->engine = ((void *)0) ; Executed by:
| 680 | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | ctx->cipher = cipher; | - | ||||||||||||||||||||||||
83 | if (ctx->cipher->ctx_size
| 12-668 | ||||||||||||||||||||||||
84 | ctx->cipher_data = malloc(ctx->cipher->ctx_size); | - | ||||||||||||||||||||||||
85 | if (!ctx->cipher_data
| 0-668 | ||||||||||||||||||||||||
86 | ERR_put_error(6,(0xfff),((1|64)),__FILE__,149); | - | ||||||||||||||||||||||||
87 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | } executed 668 times by 5 tests: else {end of block Executed by:
| 668 | ||||||||||||||||||||||||
90 | ctx->cipher_data = | - | ||||||||||||||||||||||||
91 | ((void *)0) | - | ||||||||||||||||||||||||
92 | ; | - | ||||||||||||||||||||||||
93 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
94 | ctx->key_len = cipher->key_len; | - | ||||||||||||||||||||||||
95 | ctx->flags = 0; | - | ||||||||||||||||||||||||
96 | if (ctx->cipher->flags & 0x40
| 36-644 | ||||||||||||||||||||||||
97 | if (!EVP_CIPHER_CTX_ctrl(ctx, 0x0, 0,
| 0-36 | ||||||||||||||||||||||||
98 | ((void *)0)
| 0-36 | ||||||||||||||||||||||||
99 | )
| 0-36 | ||||||||||||||||||||||||
100 | ERR_put_error(6,(0xfff),(134),__FILE__,159); | - | ||||||||||||||||||||||||
101 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
104 | } executed 680 times by 5 tests: else if (!ctx->cipherend of block Executed by:
| 0-680 | ||||||||||||||||||||||||
105 | ERR_put_error(6,(0xfff),(131),__FILE__,164); | - | ||||||||||||||||||||||||
106 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
107 | } | - | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | skip_to_init: code before this statement executed 878 times by 5 tests: skip_to_init: Executed by:
| 878 | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | if (ctx->cipher->block_size != 1
| 361-517 | ||||||||||||||||||||||||
113 | ctx->cipher->block_size != 8
| 154-363 | ||||||||||||||||||||||||
114 | ctx->cipher->block_size != 16
| 0-363 | ||||||||||||||||||||||||
115 | ERR_put_error(6,(0xfff),(136),__FILE__,174); | - | ||||||||||||||||||||||||
116 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | if (!(EVP_CIPHER_CTX_flags(ctx) & 0x10)
| 0-878 | ||||||||||||||||||||||||
120 | switch ((EVP_CIPHER_CTX_flags(ctx) & 0xF0007)) { | - | ||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||
122 | case executed 48 times by 3 tests: 0x0:case 0x0: Executed by:
executed 48 times by 3 tests: case 0x0: Executed by:
| 48 | ||||||||||||||||||||||||
123 | case executed 150 times by 3 tests: 0x1:case 0x1: Executed by:
executed 150 times by 3 tests: case 0x1: Executed by:
| 150 | ||||||||||||||||||||||||
124 | break; executed 198 times by 4 tests: break; Executed by:
| 198 | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | case executed 181 times by 3 tests: 0x3:case 0x3: Executed by:
executed 181 times by 3 tests: case 0x3: Executed by:
| 181 | ||||||||||||||||||||||||
127 | case executed 123 times by 3 tests: 0x4:case 0x4: Executed by:
executed 123 times by 3 tests: case 0x4: Executed by:
| 123 | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | ctx->num = 0; | - | ||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | case executed 367 times by 4 tests: 0x2:case 0x2: Executed by:
executed 367 times by 4 tests: case 0x2: Executed by:
code before this statement executed 304 times by 3 tests: case 0x2: Executed by:
| 304-367 | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | if ((
| 0-671 | ||||||||||||||||||||||||
135 | sizeof(ctx->iv)
| 0-671 | ||||||||||||||||||||||||
136 | ERR_put_error(6,(0xfff),(102),__FILE__,195); | - | ||||||||||||||||||||||||
137 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
138 | } | - | ||||||||||||||||||||||||
139 | if (iv
| 155-516 | ||||||||||||||||||||||||
140 | memcpy(ctx->oiv, iv, executed 516 times by 5 tests: memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); Executed by:
| 516 | ||||||||||||||||||||||||
141 | EVP_CIPHER_CTX_iv_length(ctx)); executed 516 times by 5 tests: memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); Executed by:
| 516 | ||||||||||||||||||||||||
142 | memcpy(ctx->iv, ctx->oiv, | - | ||||||||||||||||||||||||
143 | EVP_CIPHER_CTX_iv_length(ctx)); | - | ||||||||||||||||||||||||
144 | break; executed 671 times by 5 tests: break; Executed by:
| 671 | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | case executed 9 times by 1 test: 0x5:case 0x5: Executed by:
executed 9 times by 1 test: case 0x5: Executed by:
| 9 | ||||||||||||||||||||||||
147 | ctx->num = 0; | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | if (iv
| 0-9 | ||||||||||||||||||||||||
150 | memcpy(ctx->iv, iv, executed 9 times by 1 test: memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); Executed by:
| 9 | ||||||||||||||||||||||||
151 | EVP_CIPHER_CTX_iv_length(ctx)); executed 9 times by 1 test: memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); Executed by:
| 9 | ||||||||||||||||||||||||
152 | break; executed 9 times by 1 test: break; Executed by:
| 9 | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
155 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
156 | break; dead code: break; | - | ||||||||||||||||||||||||
157 | } | - | ||||||||||||||||||||||||
158 | } | - | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | if (key
| 0-680 | ||||||||||||||||||||||||
161 | if (!ctx->cipher->init(ctx, key, iv, enc)
| 0-680 | ||||||||||||||||||||||||
162 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
163 | } executed 680 times by 5 tests: end of block Executed by:
| 680 | ||||||||||||||||||||||||
164 | ctx->buf_len = 0; | - | ||||||||||||||||||||||||
165 | ctx->final_used = 0; | - | ||||||||||||||||||||||||
166 | ctx->block_mask = ctx->cipher->block_size - 1; | - | ||||||||||||||||||||||||
167 | return executed 878 times by 5 tests: 1;return 1; Executed by:
executed 878 times by 5 tests: return 1; Executed by:
| 878 | ||||||||||||||||||||||||
168 | } | - | ||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | int | - | ||||||||||||||||||||||||
171 | EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | - | ||||||||||||||||||||||||
172 | const unsigned char *in, int inl) | - | ||||||||||||||||||||||||
173 | { | - | ||||||||||||||||||||||||
174 | if (ctx->encrypt
| 99 | ||||||||||||||||||||||||
175 | return executed 99 times by 2 tests: EVP_EncryptUpdate(ctx, out, outl, in, inl);return EVP_EncryptUpdate(ctx, out, outl, in, inl); Executed by:
executed 99 times by 2 tests: return EVP_EncryptUpdate(ctx, out, outl, in, inl); Executed by:
| 99 | ||||||||||||||||||||||||
176 | else | - | ||||||||||||||||||||||||
177 | return executed 99 times by 2 tests: EVP_DecryptUpdate(ctx, out, outl, in, inl);return EVP_DecryptUpdate(ctx, out, outl, in, inl); Executed by:
executed 99 times by 2 tests: return EVP_DecryptUpdate(ctx, out, outl, in, inl); Executed by:
| 99 | ||||||||||||||||||||||||
178 | } | - | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | int | - | ||||||||||||||||||||||||
181 | EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
182 | { | - | ||||||||||||||||||||||||
183 | if (ctx->encrypt
| 99 | ||||||||||||||||||||||||
184 | return executed 99 times by 2 tests: EVP_EncryptFinal_ex(ctx, out, outl);return EVP_EncryptFinal_ex(ctx, out, outl); Executed by:
executed 99 times by 2 tests: return EVP_EncryptFinal_ex(ctx, out, outl); Executed by:
| 99 | ||||||||||||||||||||||||
185 | else | - | ||||||||||||||||||||||||
186 | return executed 99 times by 2 tests: EVP_DecryptFinal_ex(ctx, out, outl);return EVP_DecryptFinal_ex(ctx, out, outl); Executed by:
executed 99 times by 2 tests: return EVP_DecryptFinal_ex(ctx, out, outl); Executed by:
| 99 | ||||||||||||||||||||||||
187 | } | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | __asm__(".section .gnu.warning." | - | ||||||||||||||||||||||||
191 | "EVP_CipherFinal" | - | ||||||||||||||||||||||||
192 | "\n\t.ascii \"" | - | ||||||||||||||||||||||||
193 | "EVP_CipherFinal is often misused, please use EVP_CipherFinal_ex and EVP_CIPHER_CTX_cleanup" | - | ||||||||||||||||||||||||
194 | "\"\n\t.text"); | - | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | ; | - | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | int | - | ||||||||||||||||||||||||
199 | EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
200 | { | - | ||||||||||||||||||||||||
201 | int ret; | - | ||||||||||||||||||||||||
202 | if (ctx->encrypt
| 0 | ||||||||||||||||||||||||
203 | ret = EVP_EncryptFinal_ex(ctx, out, outl); never executed: ret = EVP_EncryptFinal_ex(ctx, out, outl); | 0 | ||||||||||||||||||||||||
204 | else | - | ||||||||||||||||||||||||
205 | ret = EVP_DecryptFinal_ex(ctx, out, outl); never executed: ret = EVP_DecryptFinal_ex(ctx, out, outl); | 0 | ||||||||||||||||||||||||
206 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
207 | } | - | ||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | int | - | ||||||||||||||||||||||||
210 | EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | - | ||||||||||||||||||||||||
211 | const unsigned char *key, const unsigned char *iv) | - | ||||||||||||||||||||||||
212 | { | - | ||||||||||||||||||||||||
213 | return never executed: EVP_CipherInit(ctx, cipher, key, iv, 1);return EVP_CipherInit(ctx, cipher, key, iv, 1); never executed: return EVP_CipherInit(ctx, cipher, key, iv, 1); | 0 | ||||||||||||||||||||||||
214 | } | - | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | int | - | ||||||||||||||||||||||||
217 | EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | - | ||||||||||||||||||||||||
218 | const unsigned char *key, const unsigned char *iv) | - | ||||||||||||||||||||||||
219 | { | - | ||||||||||||||||||||||||
220 | return executed 208 times by 3 tests: EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1);return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1); Executed by:
executed 208 times by 3 tests: return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1); Executed by:
| 208 | ||||||||||||||||||||||||
221 | } | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | int | - | ||||||||||||||||||||||||
224 | EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | - | ||||||||||||||||||||||||
225 | const unsigned char *key, const unsigned char *iv) | - | ||||||||||||||||||||||||
226 | { | - | ||||||||||||||||||||||||
227 | return never executed: EVP_CipherInit(ctx, cipher, key, iv, 0);return EVP_CipherInit(ctx, cipher, key, iv, 0); never executed: return EVP_CipherInit(ctx, cipher, key, iv, 0); | 0 | ||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | int | - | ||||||||||||||||||||||||
231 | EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | - | ||||||||||||||||||||||||
232 | const unsigned char *key, const unsigned char *iv) | - | ||||||||||||||||||||||||
233 | { | - | ||||||||||||||||||||||||
234 | return executed 114 times by 1 test: EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0); Executed by:
executed 114 times by 1 test: return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0); Executed by:
| 114 | ||||||||||||||||||||||||
235 | } | - | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | int | - | ||||||||||||||||||||||||
238 | EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | - | ||||||||||||||||||||||||
239 | const unsigned char *in, int inl) | - | ||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||
241 | int i, j, bl; | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | if (ctx->cipher->flags & 0x100000
| 0-520 | ||||||||||||||||||||||||
244 | i = ctx->cipher->do_cipher(ctx, out, in, inl); | - | ||||||||||||||||||||||||
245 | if (i < 0
| 0 | ||||||||||||||||||||||||
246 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
247 | else | - | ||||||||||||||||||||||||
248 | * never executed: outl = i;*outl = i; never executed: *outl = i; | 0 | ||||||||||||||||||||||||
249 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
250 | } | - | ||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | if (inl <= 0
| 0-520 | ||||||||||||||||||||||||
253 | *outl = 0; | - | ||||||||||||||||||||||||
254 | return never executed: inl == 0;return inl == 0; never executed: return inl == 0; | 0 | ||||||||||||||||||||||||
255 | } | - | ||||||||||||||||||||||||
256 | - | |||||||||||||||||||||||||
257 | if (ctx->buf_len == 0
| 0-520 | ||||||||||||||||||||||||
258 | if (ctx->cipher->do_cipher(ctx, out, in, inl)
| 0-448 | ||||||||||||||||||||||||
259 | *outl = inl; | - | ||||||||||||||||||||||||
260 | return executed 448 times by 4 tests: 1;return 1; Executed by:
executed 448 times by 4 tests: return 1; Executed by:
| 448 | ||||||||||||||||||||||||
261 | } else { | - | ||||||||||||||||||||||||
262 | *outl = 0; | - | ||||||||||||||||||||||||
263 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
264 | } | - | ||||||||||||||||||||||||
265 | } | - | ||||||||||||||||||||||||
266 | i = ctx->buf_len; | - | ||||||||||||||||||||||||
267 | bl = ctx->cipher->block_size; | - | ||||||||||||||||||||||||
268 | if ((
| 0-72 | ||||||||||||||||||||||||
269 | ERR_put_error(6,(0xfff),(136),__FILE__,322); | - | ||||||||||||||||||||||||
270 | *outl = 0; | - | ||||||||||||||||||||||||
271 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
272 | } | - | ||||||||||||||||||||||||
273 | if (i != 0
| 0-72 | ||||||||||||||||||||||||
274 | if (bl - i > inl
| 0 | ||||||||||||||||||||||||
275 | memcpy(&(ctx->buf[i]), in, inl); | - | ||||||||||||||||||||||||
276 | ctx->buf_len += inl; | - | ||||||||||||||||||||||||
277 | *outl = 0; | - | ||||||||||||||||||||||||
278 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
279 | } else { | - | ||||||||||||||||||||||||
280 | j = bl - i; | - | ||||||||||||||||||||||||
281 | memcpy(&(ctx->buf[i]), in, j); | - | ||||||||||||||||||||||||
282 | if (!ctx->cipher->do_cipher(ctx, out, ctx->buf, bl)
| 0 | ||||||||||||||||||||||||
283 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
284 | inl -= j; | - | ||||||||||||||||||||||||
285 | in += j; | - | ||||||||||||||||||||||||
286 | out += bl; | - | ||||||||||||||||||||||||
287 | *outl = bl; | - | ||||||||||||||||||||||||
288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
289 | } else | - | ||||||||||||||||||||||||
290 | * executed 72 times by 3 tests: outl = 0;*outl = 0; Executed by:
executed 72 times by 3 tests: *outl = 0; Executed by:
| 72 | ||||||||||||||||||||||||
291 | i = inl&(bl - 1); | - | ||||||||||||||||||||||||
292 | inl -= i; | - | ||||||||||||||||||||||||
293 | if (inl > 0
| 0-72 | ||||||||||||||||||||||||
294 | if (!ctx->cipher->do_cipher(ctx, out, in, inl)
| 0-72 | ||||||||||||||||||||||||
295 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
296 | *outl += inl; | - | ||||||||||||||||||||||||
297 | } executed 72 times by 3 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | if (i != 0
| 0-72 | ||||||||||||||||||||||||
300 | memcpy(ctx->buf, &(in[inl]), i); executed 72 times by 3 tests: memcpy(ctx->buf, &(in[inl]), i); Executed by:
| 72 | ||||||||||||||||||||||||
301 | ctx->buf_len = i; | - | ||||||||||||||||||||||||
302 | return executed 72 times by 3 tests: 1;return 1; Executed by:
executed 72 times by 3 tests: return 1; Executed by:
| 72 | ||||||||||||||||||||||||
303 | } | - | ||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | __asm__(".section .gnu.warning." | - | ||||||||||||||||||||||||
307 | "EVP_EncryptFinal" | - | ||||||||||||||||||||||||
308 | "\n\t.ascii \"" | - | ||||||||||||||||||||||||
309 | "EVP_EncryptFinal is often misused, please use EVP_EncryptFinal_ex and EVP_CIPHER_CTX_cleanup" | - | ||||||||||||||||||||||||
310 | "\"\n\t.text"); | - | ||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||
312 | ; | - | ||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||
314 | int | - | ||||||||||||||||||||||||
315 | EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
316 | { | - | ||||||||||||||||||||||||
317 | int ret; | - | ||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||
319 | ret = EVP_EncryptFinal_ex(ctx, out, outl); | - | ||||||||||||||||||||||||
320 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
321 | } | - | ||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | int | - | ||||||||||||||||||||||||
324 | EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
325 | { | - | ||||||||||||||||||||||||
326 | int n, ret; | - | ||||||||||||||||||||||||
327 | unsigned int i, b, bl; | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | if (ctx->cipher->flags & 0x100000
| 0-303 | ||||||||||||||||||||||||
330 | ret = ctx->cipher->do_cipher(ctx, out, | - | ||||||||||||||||||||||||
331 | ((void *)0) | - | ||||||||||||||||||||||||
332 | , 0); | - | ||||||||||||||||||||||||
333 | if (ret < 0
| 0 | ||||||||||||||||||||||||
334 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
335 | else | - | ||||||||||||||||||||||||
336 | * never executed: outl = ret;*outl = ret; never executed: *outl = ret; | 0 | ||||||||||||||||||||||||
337 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
338 | } | - | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | b = ctx->cipher->block_size; | - | ||||||||||||||||||||||||
341 | if (b > sizeof ctx->buf
| 0-303 | ||||||||||||||||||||||||
342 | ERR_put_error(6,(0xfff),(136),__FILE__,387); | - | ||||||||||||||||||||||||
343 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
344 | } | - | ||||||||||||||||||||||||
345 | if (b == 1
| 133-170 | ||||||||||||||||||||||||
346 | *outl = 0; | - | ||||||||||||||||||||||||
347 | return executed 133 times by 3 tests: 1;return 1; Executed by:
executed 133 times by 3 tests: return 1; Executed by:
| 133 | ||||||||||||||||||||||||
348 | } | - | ||||||||||||||||||||||||
349 | bl = ctx->buf_len; | - | ||||||||||||||||||||||||
350 | if (ctx->flags & 0x100
| 66-104 | ||||||||||||||||||||||||
351 | if (bl
| 0-66 | ||||||||||||||||||||||||
352 | ERR_put_error(6,(0xfff),(138),__FILE__,397); | - | ||||||||||||||||||||||||
353 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
354 | } | - | ||||||||||||||||||||||||
355 | *outl = 0; | - | ||||||||||||||||||||||||
356 | return executed 66 times by 1 test: 1;return 1; Executed by:
executed 66 times by 1 test: return 1; Executed by:
| 66 | ||||||||||||||||||||||||
357 | } | - | ||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||
359 | n = b - bl; | - | ||||||||||||||||||||||||
360 | for (i = bl; i < b
| 104-884 | ||||||||||||||||||||||||
361 | ctx->buf[i] = n; executed 884 times by 3 tests: ctx->buf[i] = n; Executed by:
| 884 | ||||||||||||||||||||||||
362 | ret = ctx->cipher->do_cipher(ctx, out, ctx->buf, b); | - | ||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | if (ret
| 0-104 | ||||||||||||||||||||||||
366 | * executed 104 times by 3 tests: outl = b;*outl = b; Executed by:
executed 104 times by 3 tests: *outl = b; Executed by:
| 104 | ||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||
368 | return executed 104 times by 3 tests: ret;return ret; Executed by:
executed 104 times by 3 tests: return ret; Executed by:
| 104 | ||||||||||||||||||||||||
369 | } | - | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | int | - | ||||||||||||||||||||||||
372 | EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | - | ||||||||||||||||||||||||
373 | const unsigned char *in, int inl) | - | ||||||||||||||||||||||||
374 | { | - | ||||||||||||||||||||||||
375 | int fix_len; | - | ||||||||||||||||||||||||
376 | unsigned int b; | - | ||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | if (ctx->cipher->flags & 0x100000
| 0-213 | ||||||||||||||||||||||||
379 | fix_len = ctx->cipher->do_cipher(ctx, out, in, inl); | - | ||||||||||||||||||||||||
380 | if (fix_len < 0
| 0 | ||||||||||||||||||||||||
381 | *outl = 0; | - | ||||||||||||||||||||||||
382 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
383 | } else | - | ||||||||||||||||||||||||
384 | * never executed: outl = fix_len;*outl = fix_len; never executed: *outl = fix_len; | 0 | ||||||||||||||||||||||||
385 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
386 | } | - | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | if (inl <= 0
| 0-213 | ||||||||||||||||||||||||
389 | *outl = 0; | - | ||||||||||||||||||||||||
390 | return never executed: inl == 0;return inl == 0; never executed: return inl == 0; | 0 | ||||||||||||||||||||||||
391 | } | - | ||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | if (ctx->flags & 0x100
| 99-114 | ||||||||||||||||||||||||
394 | return executed 114 times by 1 test: EVP_EncryptUpdate(ctx, out, outl, in, inl);return EVP_EncryptUpdate(ctx, out, outl, in, inl); Executed by:
executed 114 times by 1 test: return EVP_EncryptUpdate(ctx, out, outl, in, inl); Executed by:
| 114 | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | b = ctx->cipher->block_size; | - | ||||||||||||||||||||||||
397 | if (b > sizeof ctx->final
| 0-99 | ||||||||||||||||||||||||
398 | ERR_put_error(6,(0xfff),(136),__FILE__,443); | - | ||||||||||||||||||||||||
399 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
400 | } | - | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | if (ctx->final_used
| 0-99 | ||||||||||||||||||||||||
403 | memcpy(out, ctx->final, b); | - | ||||||||||||||||||||||||
404 | out += b; | - | ||||||||||||||||||||||||
405 | fix_len = 1; | - | ||||||||||||||||||||||||
406 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
407 | fix_len = 0; executed 99 times by 2 tests: fix_len = 0; Executed by:
| 99 | ||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | if (!EVP_EncryptUpdate(ctx, out, outl, in, inl)
| 0-99 | ||||||||||||||||||||||||
411 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||
413 | - | |||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||
415 | if (b > 1
| 0-54 | ||||||||||||||||||||||||
416 | *outl -= b; | - | ||||||||||||||||||||||||
417 | ctx->final_used = 1; | - | ||||||||||||||||||||||||
418 | memcpy(ctx->final, &out[*outl], b); | - | ||||||||||||||||||||||||
419 | } executed 45 times by 2 tests: elseend of block Executed by:
| 45 | ||||||||||||||||||||||||
420 | ctx->final_used = 0; executed 54 times by 1 test: ctx->final_used = 0; Executed by:
| 54 | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | if (fix_len
| 0-99 | ||||||||||||||||||||||||
423 | * never executed: outl += b;*outl += b; never executed: *outl += b; | 0 | ||||||||||||||||||||||||
424 | - | |||||||||||||||||||||||||
425 | return executed 99 times by 2 tests: 1;return 1; Executed by:
executed 99 times by 2 tests: return 1; Executed by:
| 99 | ||||||||||||||||||||||||
426 | } | - | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||
429 | __asm__(".section .gnu.warning." | - | ||||||||||||||||||||||||
430 | "EVP_DecryptFinal" | - | ||||||||||||||||||||||||
431 | "\n\t.ascii \"" | - | ||||||||||||||||||||||||
432 | "EVP_DecryptFinal is often misused, please use EVP_DecryptFinal_ex and EVP_CIPHER_CTX_cleanup" | - | ||||||||||||||||||||||||
433 | "\"\n\t.text"); | - | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | ; | - | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | int | - | ||||||||||||||||||||||||
438 | EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
439 | { | - | ||||||||||||||||||||||||
440 | int ret; | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | ret = EVP_DecryptFinal_ex(ctx, out, outl); | - | ||||||||||||||||||||||||
443 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
444 | } | - | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | int | - | ||||||||||||||||||||||||
447 | EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | - | ||||||||||||||||||||||||
448 | { | - | ||||||||||||||||||||||||
449 | int i, n; | - | ||||||||||||||||||||||||
450 | unsigned int b; | - | ||||||||||||||||||||||||
451 | *outl = 0; | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | if (ctx->cipher->flags & 0x100000
| 0-213 | ||||||||||||||||||||||||
454 | i = ctx->cipher->do_cipher(ctx, out, | - | ||||||||||||||||||||||||
455 | ((void *)0) | - | ||||||||||||||||||||||||
456 | , 0); | - | ||||||||||||||||||||||||
457 | if (i < 0
| 0 | ||||||||||||||||||||||||
458 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
459 | else | - | ||||||||||||||||||||||||
460 | * never executed: outl = i;*outl = i; never executed: *outl = i; | 0 | ||||||||||||||||||||||||
461 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
462 | } | - | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | b = ctx->cipher->block_size; | - | ||||||||||||||||||||||||
465 | if (ctx->flags & 0x100
| 99-114 | ||||||||||||||||||||||||
466 | if (ctx->buf_len
| 0-114 | ||||||||||||||||||||||||
467 | ERR_put_error(6,(0xfff),(138),__FILE__,504); | - | ||||||||||||||||||||||||
468 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
469 | } | - | ||||||||||||||||||||||||
470 | *outl = 0; | - | ||||||||||||||||||||||||
471 | return executed 114 times by 1 test: 1;return 1; Executed by:
executed 114 times by 1 test: return 1; Executed by:
| 114 | ||||||||||||||||||||||||
472 | } | - | ||||||||||||||||||||||||
473 | if (b > 1
| 45-54 | ||||||||||||||||||||||||
474 | if (ctx->buf_len
| 0-45 | ||||||||||||||||||||||||
475 | ERR_put_error(6,(0xfff),(109),__FILE__,512); | - | ||||||||||||||||||||||||
476 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||
477 | } | - | ||||||||||||||||||||||||
478 | if (b > sizeof ctx->final
| 0-45 | ||||||||||||||||||||||||
479 | ERR_put_error(6,(0xfff),(136),__FILE__,516); | - | ||||||||||||||||||||||||
480 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
481 | } | - | ||||||||||||||||||||||||
482 | n = ctx->final[b - 1]; | - | ||||||||||||||||||||||||
483 | if (n == 0
| 0-45 | ||||||||||||||||||||||||
484 | ERR_put_error(6,(0xfff),(100),__FILE__,521); | - | ||||||||||||||||||||||||
485 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||
486 | } | - | ||||||||||||||||||||||||
487 | for (i = 0; i < n
| 45-362 | ||||||||||||||||||||||||
488 | if (ctx->final[--b] != n
| 0-362 | ||||||||||||||||||||||||
489 | ERR_put_error(6,(0xfff),(100),__FILE__,526); | - | ||||||||||||||||||||||||
490 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||
491 | } | - | ||||||||||||||||||||||||
492 | } executed 362 times by 2 tests: end of block Executed by:
| 362 | ||||||||||||||||||||||||
493 | n = ctx->cipher->block_size - n; | - | ||||||||||||||||||||||||
494 | for (i = 0; i < n
| 45-102 | ||||||||||||||||||||||||
495 | out[i] = ctx->final[i]; executed 102 times by 2 tests: out[i] = ctx->final[i]; Executed by:
| 102 | ||||||||||||||||||||||||
496 | *outl = n; | - | ||||||||||||||||||||||||
497 | } executed 45 times by 2 tests: elseend of block Executed by:
| 45 | ||||||||||||||||||||||||
498 | * executed 54 times by 1 test: outl = 0;*outl = 0; Executed by:
executed 54 times by 1 test: *outl = 0; Executed by:
| 54 | ||||||||||||||||||||||||
499 | return executed 99 times by 2 tests: (1);return (1); Executed by:
executed 99 times by 2 tests: return (1); Executed by:
| 99 | ||||||||||||||||||||||||
500 | } | - | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | EVP_CIPHER_CTX * | - | ||||||||||||||||||||||||
503 | EVP_CIPHER_CTX_new(void) | - | ||||||||||||||||||||||||
504 | { | - | ||||||||||||||||||||||||
505 | return executed 160 times by 1 test: calloc(1, sizeof(EVP_CIPHER_CTX));return calloc(1, sizeof(EVP_CIPHER_CTX)); Executed by:
executed 160 times by 1 test: return calloc(1, sizeof(EVP_CIPHER_CTX)); Executed by:
| 160 | ||||||||||||||||||||||||
506 | } | - | ||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | void | - | ||||||||||||||||||||||||
509 | EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) | - | ||||||||||||||||||||||||
510 | { | - | ||||||||||||||||||||||||
511 | if (ctx ==
| 160-1432 | ||||||||||||||||||||||||
512 | ((void *)0)
| 160-1432 | ||||||||||||||||||||||||
513 | ) | - | ||||||||||||||||||||||||
514 | return; executed 1432 times by 12 tests: return; Executed by:
| 1432 | ||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | EVP_CIPHER_CTX_cleanup(ctx); | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | free(ctx); | - | ||||||||||||||||||||||||
519 | } executed 160 times by 1 test: end of block Executed by:
| 160 | ||||||||||||||||||||||||
520 | - | |||||||||||||||||||||||||
521 | void | - | ||||||||||||||||||||||||
522 | EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) | - | ||||||||||||||||||||||||
523 | { | - | ||||||||||||||||||||||||
524 | memset(ctx, 0, sizeof(EVP_CIPHER_CTX)); | - | ||||||||||||||||||||||||
525 | } executed 454 times by 5 tests: end of block Executed by:
| 454 | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | int | - | ||||||||||||||||||||||||
528 | EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *a) | - | ||||||||||||||||||||||||
529 | { | - | ||||||||||||||||||||||||
530 | return never executed: EVP_CIPHER_CTX_cleanup(a);return EVP_CIPHER_CTX_cleanup(a); never executed: return EVP_CIPHER_CTX_cleanup(a); | 0 | ||||||||||||||||||||||||
531 | } | - | ||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | int | - | ||||||||||||||||||||||||
534 | EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) | - | ||||||||||||||||||||||||
535 | { | - | ||||||||||||||||||||||||
536 | if (c->cipher !=
| 0-680 | ||||||||||||||||||||||||
537 | ((void *)0)
| 0-680 | ||||||||||||||||||||||||
538 | ) { | - | ||||||||||||||||||||||||
539 | if (c->cipher->cleanup
| 0-680 | ||||||||||||||||||||||||
540 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | if (c->cipher_data
| 12-668 | ||||||||||||||||||||||||
543 | explicit_bzero(c->cipher_data, c->cipher->ctx_size); executed 668 times by 5 tests: explicit_bzero(c->cipher_data, c->cipher->ctx_size); Executed by:
| 668 | ||||||||||||||||||||||||
544 | } executed 680 times by 5 tests: end of block Executed by:
| 680 | ||||||||||||||||||||||||
545 | free(c->cipher_data); | - | ||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||
547 | ENGINE_finish(c->engine); | - | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | explicit_bzero(c, sizeof(EVP_CIPHER_CTX)); | - | ||||||||||||||||||||||||
550 | return executed 680 times by 5 tests: 1;return 1; Executed by:
executed 680 times by 5 tests: return 1; Executed by:
| 680 | ||||||||||||||||||||||||
551 | } | - | ||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||
553 | int | - | ||||||||||||||||||||||||
554 | EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) | - | ||||||||||||||||||||||||
555 | { | - | ||||||||||||||||||||||||
556 | if (c->cipher->flags & 0x80
| 0 | ||||||||||||||||||||||||
557 | return never executed: EVP_CIPHER_CTX_ctrl(c, 0x1,return EVP_CIPHER_CTX_ctrl(c, 0x1, keylen, ((void *)0) ); never executed: return EVP_CIPHER_CTX_ctrl(c, 0x1, keylen, ((void *)0) ); | 0 | ||||||||||||||||||||||||
558 | keylen, never executed: return EVP_CIPHER_CTX_ctrl(c, 0x1, keylen, ((void *)0) ); | 0 | ||||||||||||||||||||||||
559 | ((void *)0) never executed: return EVP_CIPHER_CTX_ctrl(c, 0x1, keylen, ((void *)0) ); | 0 | ||||||||||||||||||||||||
560 | ); never executed: return EVP_CIPHER_CTX_ctrl(c, 0x1, keylen, ((void *)0) ); | 0 | ||||||||||||||||||||||||
561 | if (c->key_len == keylen
| 0 | ||||||||||||||||||||||||
562 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
563 | if ((
| 0 | ||||||||||||||||||||||||
564 | c->key_len = keylen; | - | ||||||||||||||||||||||||
565 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
566 | } | - | ||||||||||||||||||||||||
567 | ERR_put_error(6,(0xfff),(130),__FILE__,598); | - | ||||||||||||||||||||||||
568 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
569 | } | - | ||||||||||||||||||||||||
570 | - | |||||||||||||||||||||||||
571 | int | - | ||||||||||||||||||||||||
572 | EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad) | - | ||||||||||||||||||||||||
573 | { | - | ||||||||||||||||||||||||
574 | if (pad
| 0-251 | ||||||||||||||||||||||||
575 | ctx->flags &= ~0x100; never executed: ctx->flags &= ~0x100; | 0 | ||||||||||||||||||||||||
576 | else | - | ||||||||||||||||||||||||
577 | ctx->flags |= 0x100; executed 251 times by 1 test: ctx->flags |= 0x100; Executed by:
| 251 | ||||||||||||||||||||||||
578 | return executed 251 times by 1 test: 1;return 1; Executed by:
executed 251 times by 1 test: return 1; Executed by:
| 251 | ||||||||||||||||||||||||
579 | } | - | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | int | - | ||||||||||||||||||||||||
582 | EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) | - | ||||||||||||||||||||||||
583 | { | - | ||||||||||||||||||||||||
584 | int ret; | - | ||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | if (!ctx->cipher
| 0-48 | ||||||||||||||||||||||||
587 | ERR_put_error(6,(0xfff),(131),__FILE__,618); | - | ||||||||||||||||||||||||
588 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
589 | } | - | ||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | if (!ctx->cipher->ctrl
| 0-48 | ||||||||||||||||||||||||
592 | ERR_put_error(6,(0xfff),(132),__FILE__,623); | - | ||||||||||||||||||||||||
593 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
594 | } | - | ||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | ret = ctx->cipher->ctrl(ctx, type, arg, ptr); | - | ||||||||||||||||||||||||
597 | if (ret == -1
| 0-48 | ||||||||||||||||||||||||
598 | ERR_put_error(6,(0xfff),(133),__FILE__,629); | - | ||||||||||||||||||||||||
599 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
600 | } | - | ||||||||||||||||||||||||
601 | return executed 48 times by 2 tests: ret;return ret; Executed by:
executed 48 times by 2 tests: return ret; Executed by:
| 48 | ||||||||||||||||||||||||
602 | } | - | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | int | - | ||||||||||||||||||||||||
605 | EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) | - | ||||||||||||||||||||||||
606 | { | - | ||||||||||||||||||||||||
607 | if (ctx->cipher->flags & 0x200
| 0-2 | ||||||||||||||||||||||||
608 | return never executed: EVP_CIPHER_CTX_ctrl(ctx, 0x6, 0, key);return EVP_CIPHER_CTX_ctrl(ctx, 0x6, 0, key); never executed: return EVP_CIPHER_CTX_ctrl(ctx, 0x6, 0, key); | 0 | ||||||||||||||||||||||||
609 | arc4random_buf(key, ctx->key_len); | - | ||||||||||||||||||||||||
610 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||||||||||||||
611 | } | - | ||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||
613 | int | - | ||||||||||||||||||||||||
614 | EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) | - | ||||||||||||||||||||||||
615 | { | - | ||||||||||||||||||||||||
616 | if ((
| 0 | ||||||||||||||||||||||||
617 | ((void *)0)
| 0 | ||||||||||||||||||||||||
618 | )
| 0 | ||||||||||||||||||||||||
619 | ((void *)0)
| 0 | ||||||||||||||||||||||||
620 | )
| 0 | ||||||||||||||||||||||||
621 | ERR_put_error(6,(0xfff),(111),__FILE__,648); | - | ||||||||||||||||||||||||
622 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
623 | } | - | ||||||||||||||||||||||||
624 | - | |||||||||||||||||||||||||
625 | - | |||||||||||||||||||||||||
626 | if (in->engine
| 0 | ||||||||||||||||||||||||
627 | ERR_put_error(6,(0xfff),(38),__FILE__,654); | - | ||||||||||||||||||||||||
628 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
629 | } | - | ||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | EVP_CIPHER_CTX_cleanup(out); | - | ||||||||||||||||||||||||
633 | memcpy(out, in, sizeof *out); | - | ||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | if (in->cipher_data
| 0 | ||||||||||||||||||||||||
636 | out->cipher_data = malloc(in->cipher->ctx_size); | - | ||||||||||||||||||||||||
637 | if (!out->cipher_data
| 0 | ||||||||||||||||||||||||
638 | ERR_put_error(6,(0xfff),((1|64)),__FILE__,665); | - | ||||||||||||||||||||||||
639 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
640 | } | - | ||||||||||||||||||||||||
641 | memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size); | - | ||||||||||||||||||||||||
642 | } never executed: end of block | 0 | ||||||||||||||||||||||||
643 | - | |||||||||||||||||||||||||
644 | if (in->cipher->flags & 0x400
| 0 | ||||||||||||||||||||||||
645 | return never executed: in->cipher->ctrl((EVP_CIPHER_CTX *)in,return in->cipher->ctrl((EVP_CIPHER_CTX *)in, 0x8, 0, out); never executed: return in->cipher->ctrl((EVP_CIPHER_CTX *)in, 0x8, 0, out); | 0 | ||||||||||||||||||||||||
646 | 0x8, 0, out); never executed: return in->cipher->ctrl((EVP_CIPHER_CTX *)in, 0x8, 0, out); | 0 | ||||||||||||||||||||||||
647 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
648 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |