Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/cts128.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, | - | ||||||||||||
3 | unsigned char *out, size_t len, | - | ||||||||||||
4 | const void *key, unsigned char ivec[16], | - | ||||||||||||
5 | block128_f block) | - | ||||||||||||
6 | { | - | ||||||||||||
7 | size_t residue, n; | - | ||||||||||||
8 | - | |||||||||||||
9 | if (len <= 16
| 0-6 | ||||||||||||
10 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
11 | - | |||||||||||||
12 | if ((
| 3 | ||||||||||||
13 | residue = 16; executed 3 times by 1 test: residue = 16; Executed by:
| 3 | ||||||||||||
14 | - | |||||||||||||
15 | len -= residue; | - | ||||||||||||
16 | - | |||||||||||||
17 | CRYPTO_cbc128_encrypt(in, out, len, key, ivec, block); | - | ||||||||||||
18 | - | |||||||||||||
19 | in += len; | - | ||||||||||||
20 | out += len; | - | ||||||||||||
21 | - | |||||||||||||
22 | for (n = 0; n < residue
| 6-79 | ||||||||||||
23 | ivec[n] ^= in[n]; executed 79 times by 1 test: ivec[n] ^= in[n]; Executed by:
| 79 | ||||||||||||
24 | (*block) (ivec, ivec, key); | - | ||||||||||||
25 | memcpy(out, out - 16, residue); | - | ||||||||||||
26 | memcpy(out - 16, ivec, 16); | - | ||||||||||||
27 | - | |||||||||||||
28 | return executed 6 times by 1 test: len + residue;return len + residue; Executed by:
executed 6 times by 1 test: return len + residue; Executed by:
| 6 | ||||||||||||
29 | } | - | ||||||||||||
30 | - | |||||||||||||
31 | size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, | - | ||||||||||||
32 | unsigned char *out, size_t len, | - | ||||||||||||
33 | const void *key, | - | ||||||||||||
34 | unsigned char ivec[16], | - | ||||||||||||
35 | block128_f block) | - | ||||||||||||
36 | { | - | ||||||||||||
37 | size_t residue, n; | - | ||||||||||||
38 | - | |||||||||||||
39 | if (len < 16
| 0-6 | ||||||||||||
40 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
41 | - | |||||||||||||
42 | residue = len % 16; | - | ||||||||||||
43 | - | |||||||||||||
44 | len -= residue; | - | ||||||||||||
45 | - | |||||||||||||
46 | CRYPTO_cbc128_encrypt(in, out, len, key, ivec, block); | - | ||||||||||||
47 | - | |||||||||||||
48 | if (residue == 0
| 3 | ||||||||||||
49 | return executed 3 times by 1 test: len;return len; Executed by:
executed 3 times by 1 test: return len; Executed by:
| 3 | ||||||||||||
50 | - | |||||||||||||
51 | in += len; | - | ||||||||||||
52 | out += len; | - | ||||||||||||
53 | - | |||||||||||||
54 | for (n = 0; n < residue
| 3-31 | ||||||||||||
55 | ivec[n] ^= in[n]; executed 31 times by 1 test: ivec[n] ^= in[n]; Executed by:
| 31 | ||||||||||||
56 | (*block) (ivec, ivec, key); | - | ||||||||||||
57 | memcpy(out - 16 + residue, ivec, 16); | - | ||||||||||||
58 | - | |||||||||||||
59 | return executed 3 times by 1 test: len + residue;return len + residue; Executed by:
executed 3 times by 1 test: return len + residue; Executed by:
| 3 | ||||||||||||
60 | } | - | ||||||||||||
61 | - | |||||||||||||
62 | size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
63 | size_t len, const void *key, | - | ||||||||||||
64 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
65 | { | - | ||||||||||||
66 | size_t residue; | - | ||||||||||||
67 | union { | - | ||||||||||||
68 | size_t align; | - | ||||||||||||
69 | unsigned char c[16]; | - | ||||||||||||
70 | } tmp; | - | ||||||||||||
71 | - | |||||||||||||
72 | if (len <= 16
| 0-6 | ||||||||||||
73 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
74 | - | |||||||||||||
75 | if ((
| 3 | ||||||||||||
76 | residue = 16; executed 3 times by 1 test: residue = 16; Executed by:
| 3 | ||||||||||||
77 | - | |||||||||||||
78 | len -= residue; | - | ||||||||||||
79 | - | |||||||||||||
80 | (*cbc) (in, out, len, key, ivec, 1); | - | ||||||||||||
81 | - | |||||||||||||
82 | in += len; | - | ||||||||||||
83 | out += len; | - | ||||||||||||
84 | - | |||||||||||||
85 | - | |||||||||||||
86 | - | |||||||||||||
87 | - | |||||||||||||
88 | - | |||||||||||||
89 | - | |||||||||||||
90 | memset(tmp.c, 0, sizeof(tmp)); | - | ||||||||||||
91 | memcpy(tmp.c, in, residue); | - | ||||||||||||
92 | memcpy(out, out - 16, residue); | - | ||||||||||||
93 | (*cbc) (tmp.c, out - 16, 16, key, ivec, 1); | - | ||||||||||||
94 | - | |||||||||||||
95 | return executed 6 times by 1 test: len + residue;return len + residue; Executed by:
executed 6 times by 1 test: return len + residue; Executed by:
| 6 | ||||||||||||
96 | } | - | ||||||||||||
97 | - | |||||||||||||
98 | size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
99 | size_t len, const void *key, | - | ||||||||||||
100 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
101 | { | - | ||||||||||||
102 | size_t residue; | - | ||||||||||||
103 | union { | - | ||||||||||||
104 | size_t align; | - | ||||||||||||
105 | unsigned char c[16]; | - | ||||||||||||
106 | } tmp; | - | ||||||||||||
107 | - | |||||||||||||
108 | if (len < 16
| 0-6 | ||||||||||||
109 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
110 | - | |||||||||||||
111 | residue = len % 16; | - | ||||||||||||
112 | - | |||||||||||||
113 | len -= residue; | - | ||||||||||||
114 | - | |||||||||||||
115 | (*cbc) (in, out, len, key, ivec, 1); | - | ||||||||||||
116 | - | |||||||||||||
117 | if (residue == 0
| 3 | ||||||||||||
118 | return executed 3 times by 1 test: len;return len; Executed by:
executed 3 times by 1 test: return len; Executed by:
| 3 | ||||||||||||
119 | - | |||||||||||||
120 | in += len; | - | ||||||||||||
121 | out += len; | - | ||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | memset(tmp.c, 0, sizeof(tmp)); | - | ||||||||||||
127 | memcpy(tmp.c, in, residue); | - | ||||||||||||
128 | (*cbc) (tmp.c, out - 16 + residue, 16, key, ivec, 1); | - | ||||||||||||
129 | - | |||||||||||||
130 | return executed 3 times by 1 test: len + residue;return len + residue; Executed by:
executed 3 times by 1 test: return len + residue; Executed by:
| 3 | ||||||||||||
131 | } | - | ||||||||||||
132 | - | |||||||||||||
133 | size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, | - | ||||||||||||
134 | unsigned char *out, size_t len, | - | ||||||||||||
135 | const void *key, unsigned char ivec[16], | - | ||||||||||||
136 | block128_f block) | - | ||||||||||||
137 | { | - | ||||||||||||
138 | size_t residue, n; | - | ||||||||||||
139 | union { | - | ||||||||||||
140 | size_t align; | - | ||||||||||||
141 | unsigned char c[32]; | - | ||||||||||||
142 | } tmp; | - | ||||||||||||
143 | - | |||||||||||||
144 | if (len <= 16
| 0-6 | ||||||||||||
145 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
146 | - | |||||||||||||
147 | if ((
| 3 | ||||||||||||
148 | residue = 16; executed 3 times by 1 test: residue = 16; Executed by:
| 3 | ||||||||||||
149 | - | |||||||||||||
150 | len -= 16 + residue; | - | ||||||||||||
151 | - | |||||||||||||
152 | if (len
| 3 | ||||||||||||
153 | CRYPTO_cbc128_decrypt(in, out, len, key, ivec, block); | - | ||||||||||||
154 | in += len; | - | ||||||||||||
155 | out += len; | - | ||||||||||||
156 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
157 | - | |||||||||||||
158 | (*block) (in, tmp.c + 16, key); | - | ||||||||||||
159 | - | |||||||||||||
160 | memcpy(tmp.c, tmp.c + 16, 16); | - | ||||||||||||
161 | memcpy(tmp.c, in + 16, residue); | - | ||||||||||||
162 | (*block) (tmp.c, tmp.c, key); | - | ||||||||||||
163 | - | |||||||||||||
164 | for (n = 0; n < 16
| 6-96 | ||||||||||||
165 | unsigned char c = in[n]; | - | ||||||||||||
166 | out[n] = tmp.c[n] ^ ivec[n]; | - | ||||||||||||
167 | ivec[n] = c; | - | ||||||||||||
168 | } executed 96 times by 1 test: end of block Executed by:
| 96 | ||||||||||||
169 | for (residue += 16; n < residue
| 6-79 | ||||||||||||
170 | out[n] = tmp.c[n] ^ in[n]; executed 79 times by 1 test: out[n] = tmp.c[n] ^ in[n]; Executed by:
| 79 | ||||||||||||
171 | - | |||||||||||||
172 | return executed 6 times by 1 test: 16 + len + residue;return 16 + len + residue; Executed by:
executed 6 times by 1 test: return 16 + len + residue; Executed by:
| 6 | ||||||||||||
173 | } | - | ||||||||||||
174 | - | |||||||||||||
175 | size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, | - | ||||||||||||
176 | unsigned char *out, size_t len, | - | ||||||||||||
177 | const void *key, | - | ||||||||||||
178 | unsigned char ivec[16], | - | ||||||||||||
179 | block128_f block) | - | ||||||||||||
180 | { | - | ||||||||||||
181 | size_t residue, n; | - | ||||||||||||
182 | union { | - | ||||||||||||
183 | size_t align; | - | ||||||||||||
184 | unsigned char c[32]; | - | ||||||||||||
185 | } tmp; | - | ||||||||||||
186 | - | |||||||||||||
187 | if (len < 16
| 0-6 | ||||||||||||
188 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
189 | - | |||||||||||||
190 | residue = len % 16; | - | ||||||||||||
191 | - | |||||||||||||
192 | if (residue == 0
| 3 | ||||||||||||
193 | CRYPTO_cbc128_decrypt(in, out, len, key, ivec, block); | - | ||||||||||||
194 | return executed 3 times by 1 test: len;return len; Executed by:
executed 3 times by 1 test: return len; Executed by:
| 3 | ||||||||||||
195 | } | - | ||||||||||||
196 | - | |||||||||||||
197 | len -= 16 + residue; | - | ||||||||||||
198 | - | |||||||||||||
199 | if (len
| 1-2 | ||||||||||||
200 | CRYPTO_cbc128_decrypt(in, out, len, key, ivec, block); | - | ||||||||||||
201 | in += len; | - | ||||||||||||
202 | out += len; | - | ||||||||||||
203 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
204 | - | |||||||||||||
205 | (*block) (in + residue, tmp.c + 16, key); | - | ||||||||||||
206 | - | |||||||||||||
207 | memcpy(tmp.c, tmp.c + 16, 16); | - | ||||||||||||
208 | memcpy(tmp.c, in, residue); | - | ||||||||||||
209 | (*block) (tmp.c, tmp.c, key); | - | ||||||||||||
210 | - | |||||||||||||
211 | for (n = 0; n < 16
| 3-48 | ||||||||||||
212 | unsigned char c = in[n]; | - | ||||||||||||
213 | out[n] = tmp.c[n] ^ ivec[n]; | - | ||||||||||||
214 | ivec[n] = in[n + residue]; | - | ||||||||||||
215 | tmp.c[n] = c; | - | ||||||||||||
216 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||
217 | for (residue += 16; n < residue
| 3-31 | ||||||||||||
218 | out[n] = tmp.c[n] ^ tmp.c[n - 16]; executed 31 times by 1 test: out[n] = tmp.c[n] ^ tmp.c[n - 16]; Executed by:
| 31 | ||||||||||||
219 | - | |||||||||||||
220 | return executed 3 times by 1 test: 16 + len + residue;return 16 + len + residue; Executed by:
executed 3 times by 1 test: return 16 + len + residue; Executed by:
| 3 | ||||||||||||
221 | } | - | ||||||||||||
222 | - | |||||||||||||
223 | size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
224 | size_t len, const void *key, | - | ||||||||||||
225 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
226 | { | - | ||||||||||||
227 | size_t residue; | - | ||||||||||||
228 | union { | - | ||||||||||||
229 | size_t align; | - | ||||||||||||
230 | unsigned char c[32]; | - | ||||||||||||
231 | } tmp; | - | ||||||||||||
232 | - | |||||||||||||
233 | if (len <= 16
| 0-6 | ||||||||||||
234 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
235 | - | |||||||||||||
236 | if ((
| 3 | ||||||||||||
237 | residue = 16; executed 3 times by 1 test: residue = 16; Executed by:
| 3 | ||||||||||||
238 | - | |||||||||||||
239 | len -= 16 + residue; | - | ||||||||||||
240 | - | |||||||||||||
241 | if (len
| 3 | ||||||||||||
242 | (*cbc) (in, out, len, key, ivec, 0); | - | ||||||||||||
243 | in += len; | - | ||||||||||||
244 | out += len; | - | ||||||||||||
245 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
246 | - | |||||||||||||
247 | memset(tmp.c, 0, sizeof(tmp)); | - | ||||||||||||
248 | - | |||||||||||||
249 | - | |||||||||||||
250 | - | |||||||||||||
251 | (*cbc) (in, tmp.c, 16, key, tmp.c + 16, 0); | - | ||||||||||||
252 | - | |||||||||||||
253 | memcpy(tmp.c, in + 16, residue); | - | ||||||||||||
254 | - | |||||||||||||
255 | - | |||||||||||||
256 | - | |||||||||||||
257 | (*cbc) (tmp.c, tmp.c, 32, key, ivec, 0); | - | ||||||||||||
258 | memcpy(out, tmp.c, 16 + residue); | - | ||||||||||||
259 | - | |||||||||||||
260 | return executed 6 times by 1 test: 16 + len + residue;return 16 + len + residue; Executed by:
executed 6 times by 1 test: return 16 + len + residue; Executed by:
| 6 | ||||||||||||
261 | } | - | ||||||||||||
262 | - | |||||||||||||
263 | size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
264 | size_t len, const void *key, | - | ||||||||||||
265 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
266 | { | - | ||||||||||||
267 | size_t residue; | - | ||||||||||||
268 | union { | - | ||||||||||||
269 | size_t align; | - | ||||||||||||
270 | unsigned char c[32]; | - | ||||||||||||
271 | } tmp; | - | ||||||||||||
272 | - | |||||||||||||
273 | if (len < 16
| 0-6 | ||||||||||||
274 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
275 | - | |||||||||||||
276 | residue = len % 16; | - | ||||||||||||
277 | - | |||||||||||||
278 | if (residue == 0
| 3 | ||||||||||||
279 | (*cbc) (in, out, len, key, ivec, 0); | - | ||||||||||||
280 | return executed 3 times by 1 test: len;return len; Executed by:
executed 3 times by 1 test: return len; Executed by:
| 3 | ||||||||||||
281 | } | - | ||||||||||||
282 | - | |||||||||||||
283 | len -= 16 + residue; | - | ||||||||||||
284 | - | |||||||||||||
285 | if (len
| 1-2 | ||||||||||||
286 | (*cbc) (in, out, len, key, ivec, 0); | - | ||||||||||||
287 | in += len; | - | ||||||||||||
288 | out += len; | - | ||||||||||||
289 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
290 | - | |||||||||||||
291 | memset(tmp.c, 0, sizeof(tmp)); | - | ||||||||||||
292 | - | |||||||||||||
293 | - | |||||||||||||
294 | - | |||||||||||||
295 | (*cbc) (in + residue, tmp.c, 16, key, tmp.c + 16, 0); | - | ||||||||||||
296 | - | |||||||||||||
297 | memcpy(tmp.c, in, residue); | - | ||||||||||||
298 | - | |||||||||||||
299 | - | |||||||||||||
300 | - | |||||||||||||
301 | (*cbc) (tmp.c, tmp.c, 32, key, ivec, 0); | - | ||||||||||||
302 | memcpy(out, tmp.c, 16 + residue); | - | ||||||||||||
303 | - | |||||||||||||
304 | return executed 3 times by 1 test: 16 + len + residue;return 16 + len + residue; Executed by:
executed 3 times by 1 test: return 16 + len + residue; Executed by:
| 3 | ||||||||||||
305 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |