Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/e_aes_cbc_hmac_sha1.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | typedef struct { | - | ||||||||||||
10 | AES_KEY ks; | - | ||||||||||||
11 | SHA_CTX head, tail, md; | - | ||||||||||||
12 | size_t payload_length; | - | ||||||||||||
13 | union { | - | ||||||||||||
14 | unsigned int tls_ver; | - | ||||||||||||
15 | unsigned char tls_aad[16]; | - | ||||||||||||
16 | } aux; | - | ||||||||||||
17 | } EVP_AES_HMAC_SHA1; | - | ||||||||||||
18 | - | |||||||||||||
19 | - | |||||||||||||
20 | - | |||||||||||||
21 | - | |||||||||||||
22 | - | |||||||||||||
23 | int aesni_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); | - | ||||||||||||
24 | int aesni_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); | - | ||||||||||||
25 | - | |||||||||||||
26 | void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
27 | size_t length, const AES_KEY *key, unsigned char *ivec, int enc); | - | ||||||||||||
28 | - | |||||||||||||
29 | void aesni_cbc_sha1_enc (const void *inp, void *out, size_t blocks, | - | ||||||||||||
30 | const AES_KEY *key, unsigned char iv[16], SHA_CTX *ctx, const void *in0); | - | ||||||||||||
31 | - | |||||||||||||
32 | - | |||||||||||||
33 | - | |||||||||||||
34 | static int | - | ||||||||||||
35 | aesni_cbc_hmac_sha1_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *inkey, | - | ||||||||||||
36 | const unsigned char *iv, int enc) | - | ||||||||||||
37 | { | - | ||||||||||||
38 | EVP_AES_HMAC_SHA1 *key = ((EVP_AES_HMAC_SHA1 *)(ctx)->cipher_data); | - | ||||||||||||
39 | int ret; | - | ||||||||||||
40 | - | |||||||||||||
41 | if (enc
| 0 | ||||||||||||
42 | ret = aesni_set_encrypt_key(inkey, ctx->key_len * 8, &key->ks); never executed: ret = aesni_set_encrypt_key(inkey, ctx->key_len * 8, &key->ks); | 0 | ||||||||||||
43 | else | - | ||||||||||||
44 | ret = aesni_set_decrypt_key(inkey, ctx->key_len * 8, &key->ks); never executed: ret = aesni_set_decrypt_key(inkey, ctx->key_len * 8, &key->ks); | 0 | ||||||||||||
45 | - | |||||||||||||
46 | SHA1_Init(&key->head); | - | ||||||||||||
47 | key->tail = key->head; | - | ||||||||||||
48 | key->md = key->head; | - | ||||||||||||
49 | - | |||||||||||||
50 | key->payload_length = ((size_t)-1); | - | ||||||||||||
51 | - | |||||||||||||
52 | return never executed: ret < 0return ret < 0 ? 0 : 1;
never executed: return ret < 0 ? 0 : 1; | 0 | ||||||||||||
53 | } | - | ||||||||||||
54 | - | |||||||||||||
55 | - | |||||||||||||
56 | - | |||||||||||||
57 | - | |||||||||||||
58 | - | |||||||||||||
59 | - | |||||||||||||
60 | - | |||||||||||||
61 | void sha1_block_data_order (void *c, const void *p, size_t len); | - | ||||||||||||
62 | - | |||||||||||||
63 | static void | - | ||||||||||||
64 | sha1_update(SHA_CTX *c, const void *data, size_t len) | - | ||||||||||||
65 | { | - | ||||||||||||
66 | const unsigned char *ptr = data; | - | ||||||||||||
67 | size_t res; | - | ||||||||||||
68 | - | |||||||||||||
69 | if ((
| 0 | ||||||||||||
70 | res = (16*4) - res; | - | ||||||||||||
71 | if (len < res
| 0 | ||||||||||||
72 | res = len; never executed: res = len; | 0 | ||||||||||||
73 | SHA1_Update(c, ptr, res); | - | ||||||||||||
74 | ptr += res; | - | ||||||||||||
75 | len -= res; | - | ||||||||||||
76 | } never executed: end of block | 0 | ||||||||||||
77 | - | |||||||||||||
78 | res = len % (16*4); | - | ||||||||||||
79 | len -= res; | - | ||||||||||||
80 | - | |||||||||||||
81 | if (len
| 0 | ||||||||||||
82 | sha1_block_data_order(c, ptr, len / (16*4)); | - | ||||||||||||
83 | - | |||||||||||||
84 | ptr += len; | - | ||||||||||||
85 | c->Nh += len >> 29; | - | ||||||||||||
86 | c->Nl += len <<= 3; | - | ||||||||||||
87 | if (c->Nl < (unsigned int)len
| 0 | ||||||||||||
88 | c->Nh++; never executed: c->Nh++; | 0 | ||||||||||||
89 | } never executed: end of block | 0 | ||||||||||||
90 | - | |||||||||||||
91 | if (res
| 0 | ||||||||||||
92 | SHA1_Update(c, ptr, res); never executed: SHA1_Update(c, ptr, res); | 0 | ||||||||||||
93 | } never executed: end of block | 0 | ||||||||||||
94 | - | |||||||||||||
95 | - | |||||||||||||
96 | - | |||||||||||||
97 | - | |||||||||||||
98 | - | |||||||||||||
99 | - | |||||||||||||
100 | static int | - | ||||||||||||
101 | aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||||||||
102 | const unsigned char *in, size_t len) | - | ||||||||||||
103 | { | - | ||||||||||||
104 | EVP_AES_HMAC_SHA1 *key = ((EVP_AES_HMAC_SHA1 *)(ctx)->cipher_data); | - | ||||||||||||
105 | unsigned int l; | - | ||||||||||||
106 | size_t plen = key->payload_length, | - | ||||||||||||
107 | iv = 0, | - | ||||||||||||
108 | sha_off = 0; | - | ||||||||||||
109 | - | |||||||||||||
110 | size_t aes_off = 0, blocks; | - | ||||||||||||
111 | - | |||||||||||||
112 | sha_off = (16*4) - key->md.num; | - | ||||||||||||
113 | - | |||||||||||||
114 | - | |||||||||||||
115 | key->payload_length = ((size_t)-1); | - | ||||||||||||
116 | - | |||||||||||||
117 | if (len % 16
| 0 | ||||||||||||
118 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
119 | - | |||||||||||||
120 | if (ctx->encrypt
| 0 | ||||||||||||
121 | if (plen == ((size_t)-1)
| 0 | ||||||||||||
122 | plen = len; never executed: plen = len; | 0 | ||||||||||||
123 | else if (len != ((plen + 20 + 16) &
| 0 | ||||||||||||
124 | -16)
| 0 | ||||||||||||
125 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
126 | else if (key->aux.tls_ver >= 0x0302
| 0 | ||||||||||||
127 | iv = 16; never executed: iv = 16; | 0 | ||||||||||||
128 | - | |||||||||||||
129 | - | |||||||||||||
130 | if (plen > (sha_off + iv)
| 0 | ||||||||||||
131 | (
| 0 | ||||||||||||
132 | sha1_update(&key->md, in + iv, sha_off); | - | ||||||||||||
133 | - | |||||||||||||
134 | aesni_cbc_sha1_enc(in, out, blocks, &key->ks, | - | ||||||||||||
135 | ctx->iv, &key->md, in + iv + sha_off); | - | ||||||||||||
136 | blocks *= (16*4); | - | ||||||||||||
137 | aes_off += blocks; | - | ||||||||||||
138 | sha_off += blocks; | - | ||||||||||||
139 | key->md.Nh += blocks >> 29; | - | ||||||||||||
140 | key->md.Nl += blocks <<= 3; | - | ||||||||||||
141 | if (key->md.Nl < (unsigned int)blocks
| 0 | ||||||||||||
142 | key->md.Nh++; never executed: key->md.Nh++; | 0 | ||||||||||||
143 | } never executed: else {end of block | 0 | ||||||||||||
144 | sha_off = 0; | - | ||||||||||||
145 | } never executed: end of block | 0 | ||||||||||||
146 | - | |||||||||||||
147 | sha_off += iv; | - | ||||||||||||
148 | sha1_update(&key->md, in + sha_off, plen - sha_off); | - | ||||||||||||
149 | - | |||||||||||||
150 | if (plen != len
| 0 | ||||||||||||
151 | if (in != out
| 0 | ||||||||||||
152 | memcpy(out + aes_off, in + aes_off, never executed: memcpy(out + aes_off, in + aes_off, plen - aes_off); | 0 | ||||||||||||
153 | plen - aes_off); never executed: memcpy(out + aes_off, in + aes_off, plen - aes_off); | 0 | ||||||||||||
154 | - | |||||||||||||
155 | - | |||||||||||||
156 | SHA1_Final(out + plen, &key->md); | - | ||||||||||||
157 | key->md = key->tail; | - | ||||||||||||
158 | sha1_update(&key->md, out + plen, 20); | - | ||||||||||||
159 | SHA1_Final(out + plen, &key->md); | - | ||||||||||||
160 | - | |||||||||||||
161 | - | |||||||||||||
162 | plen += 20; | - | ||||||||||||
163 | for (l = len - plen - 1; plen < len
| 0 | ||||||||||||
164 | out[plen] = l; never executed: out[plen] = l; | 0 | ||||||||||||
165 | - | |||||||||||||
166 | - | |||||||||||||
167 | aesni_cbc_encrypt(out + aes_off, out + aes_off, | - | ||||||||||||
168 | len - aes_off, &key->ks, ctx->iv, 1); | - | ||||||||||||
169 | } never executed: else {end of block | 0 | ||||||||||||
170 | aesni_cbc_encrypt(in + aes_off, out + aes_off, | - | ||||||||||||
171 | len - aes_off, &key->ks, ctx->iv, 1); | - | ||||||||||||
172 | } never executed: end of block | 0 | ||||||||||||
173 | } else { | - | ||||||||||||
174 | union { | - | ||||||||||||
175 | unsigned int u[20/sizeof(unsigned int)]; | - | ||||||||||||
176 | unsigned char c[32 + 20]; | - | ||||||||||||
177 | } mac, *pmac; | - | ||||||||||||
178 | - | |||||||||||||
179 | - | |||||||||||||
180 | pmac = (void *)(((size_t)mac.c + 31) & ((size_t)0 - 32)); | - | ||||||||||||
181 | - | |||||||||||||
182 | - | |||||||||||||
183 | aesni_cbc_encrypt(in, out, len, &key->ks, ctx->iv, 0); | - | ||||||||||||
184 | - | |||||||||||||
185 | if (plen
| 0 | ||||||||||||
186 | size_t inp_len, mask, j, i; | - | ||||||||||||
187 | unsigned int res, maxpad, pad, bitlen; | - | ||||||||||||
188 | int ret = 1; | - | ||||||||||||
189 | union { | - | ||||||||||||
190 | unsigned int u[16]; | - | ||||||||||||
191 | unsigned char c[(16*4)]; | - | ||||||||||||
192 | } | - | ||||||||||||
193 | *data = (void *)key->md.data; | - | ||||||||||||
194 | - | |||||||||||||
195 | if ((
| 0 | ||||||||||||
196 | key->aux.tls_aad[plen - 3]) >= 0x0302
| 0 | ||||||||||||
197 | iv = 16; never executed: iv = 16; | 0 | ||||||||||||
198 | - | |||||||||||||
199 | if (len < (iv + 20 + 1)
| 0 | ||||||||||||
200 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | out += iv; | - | ||||||||||||
204 | len -= iv; | - | ||||||||||||
205 | - | |||||||||||||
206 | - | |||||||||||||
207 | pad = out[len - 1]; | - | ||||||||||||
208 | maxpad = len - (20 + 1); | - | ||||||||||||
209 | maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); | - | ||||||||||||
210 | maxpad &= 255; | - | ||||||||||||
211 | - | |||||||||||||
212 | ret &= constant_time_ge(maxpad, pad); | - | ||||||||||||
213 | - | |||||||||||||
214 | inp_len = len - (20 + pad + 1); | - | ||||||||||||
215 | mask = (0 - ((inp_len - len) >> | - | ||||||||||||
216 | (sizeof(inp_len) * 8 - 1))); | - | ||||||||||||
217 | inp_len &= mask; | - | ||||||||||||
218 | ret &= (int)mask; | - | ||||||||||||
219 | - | |||||||||||||
220 | key->aux.tls_aad[plen - 2] = inp_len >> 8; | - | ||||||||||||
221 | key->aux.tls_aad[plen - 1] = inp_len; | - | ||||||||||||
222 | - | |||||||||||||
223 | - | |||||||||||||
224 | key->md = key->head; | - | ||||||||||||
225 | sha1_update(&key->md, key->aux.tls_aad, plen); | - | ||||||||||||
226 | - | |||||||||||||
227 | - | |||||||||||||
228 | len -= 20; | - | ||||||||||||
229 | if (len >= (256 + (16*4))
| 0 | ||||||||||||
230 | j = (len - (256 + (16*4))) & | - | ||||||||||||
231 | (0 - (16*4)); | - | ||||||||||||
232 | j += (16*4) - key->md.num; | - | ||||||||||||
233 | sha1_update(&key->md, out, j); | - | ||||||||||||
234 | out += j; | - | ||||||||||||
235 | len -= j; | - | ||||||||||||
236 | inp_len -= j; | - | ||||||||||||
237 | } never executed: end of block | 0 | ||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | bitlen = key->md.Nl + (inp_len << 3); | - | ||||||||||||
241 | - | |||||||||||||
242 | bitlen = ({ unsigned int r=(bitlen); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
243 | pmac->u[0] = 0; | - | ||||||||||||
244 | pmac->u[1] = 0; | - | ||||||||||||
245 | pmac->u[2] = 0; | - | ||||||||||||
246 | pmac->u[3] = 0; | - | ||||||||||||
247 | pmac->u[4] = 0; | - | ||||||||||||
248 | - | |||||||||||||
249 | for (res = key->md.num, j = 0; j < len
| 0 | ||||||||||||
250 | size_t c = out[j]; | - | ||||||||||||
251 | mask = (j - inp_len) >> (sizeof(j) * 8 - 8); | - | ||||||||||||
252 | c &= mask; | - | ||||||||||||
253 | c |= 0x80 & ~mask & | - | ||||||||||||
254 | ~((inp_len - j) >> (sizeof(j) * 8 - 8)); | - | ||||||||||||
255 | data->c[res++] = (unsigned char)c; | - | ||||||||||||
256 | - | |||||||||||||
257 | if (res != (16*4)
| 0 | ||||||||||||
258 | continue; never executed: continue; | 0 | ||||||||||||
259 | - | |||||||||||||
260 | - | |||||||||||||
261 | mask = 0 - ((inp_len + 7 - j) >> | - | ||||||||||||
262 | (sizeof(j) * 8 - 1)); | - | ||||||||||||
263 | data->u[16 - 1] |= bitlen&mask; | - | ||||||||||||
264 | sha1_block_data_order(&key->md, data, 1); | - | ||||||||||||
265 | mask &= 0 - ((j - inp_len - 72) >> | - | ||||||||||||
266 | (sizeof(j) * 8 - 1)); | - | ||||||||||||
267 | pmac->u[0] |= key->md.h0 & mask; | - | ||||||||||||
268 | pmac->u[1] |= key->md.h1 & mask; | - | ||||||||||||
269 | pmac->u[2] |= key->md.h2 & mask; | - | ||||||||||||
270 | pmac->u[3] |= key->md.h3 & mask; | - | ||||||||||||
271 | pmac->u[4] |= key->md.h4 & mask; | - | ||||||||||||
272 | res = 0; | - | ||||||||||||
273 | } never executed: end of block | 0 | ||||||||||||
274 | - | |||||||||||||
275 | for (i = res; i < (16*4)
| 0 | ||||||||||||
276 | data->c[i] = 0; never executed: data->c[i] = 0; | 0 | ||||||||||||
277 | - | |||||||||||||
278 | if (res > (16*4) - 8
| 0 | ||||||||||||
279 | mask = 0 - ((inp_len + 8 - j) >> | - | ||||||||||||
280 | (sizeof(j) * 8 - 1)); | - | ||||||||||||
281 | data->u[16 - 1] |= bitlen & mask; | - | ||||||||||||
282 | sha1_block_data_order(&key->md, data, 1); | - | ||||||||||||
283 | mask &= 0 - ((j - inp_len - 73) >> | - | ||||||||||||
284 | (sizeof(j) * 8 - 1)); | - | ||||||||||||
285 | pmac->u[0] |= key->md.h0 & mask; | - | ||||||||||||
286 | pmac->u[1] |= key->md.h1 & mask; | - | ||||||||||||
287 | pmac->u[2] |= key->md.h2 & mask; | - | ||||||||||||
288 | pmac->u[3] |= key->md.h3 & mask; | - | ||||||||||||
289 | pmac->u[4] |= key->md.h4 & mask; | - | ||||||||||||
290 | - | |||||||||||||
291 | memset(data, 0, (16*4)); | - | ||||||||||||
292 | j += 64; | - | ||||||||||||
293 | } never executed: end of block | 0 | ||||||||||||
294 | data->u[16 - 1] = bitlen; | - | ||||||||||||
295 | sha1_block_data_order(&key->md, data, 1); | - | ||||||||||||
296 | mask = 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1)); | - | ||||||||||||
297 | pmac->u[0] |= key->md.h0 & mask; | - | ||||||||||||
298 | pmac->u[1] |= key->md.h1 & mask; | - | ||||||||||||
299 | pmac->u[2] |= key->md.h2 & mask; | - | ||||||||||||
300 | pmac->u[3] |= key->md.h3 & mask; | - | ||||||||||||
301 | pmac->u[4] |= key->md.h4 & mask; | - | ||||||||||||
302 | - | |||||||||||||
303 | - | |||||||||||||
304 | pmac->u[0] = ({ unsigned int r=(pmac->u[0]); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
305 | pmac->u[1] = ({ unsigned int r=(pmac->u[1]); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
306 | pmac->u[2] = ({ unsigned int r=(pmac->u[2]); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
307 | pmac->u[3] = ({ unsigned int r=(pmac->u[3]); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
308 | pmac->u[4] = ({ unsigned int r=(pmac->u[4]); asm ("bswapl %0":"=r"(r):"0"(r)); r; }); | - | ||||||||||||
309 | len += 20; | - | ||||||||||||
310 | key->md = key->tail; | - | ||||||||||||
311 | sha1_update(&key->md, pmac->c, 20); | - | ||||||||||||
312 | SHA1_Final(pmac->c, &key->md); | - | ||||||||||||
313 | - | |||||||||||||
314 | - | |||||||||||||
315 | out += inp_len; | - | ||||||||||||
316 | len -= inp_len; | - | ||||||||||||
317 | - | |||||||||||||
318 | { | - | ||||||||||||
319 | unsigned char *p = | - | ||||||||||||
320 | out + len - 1 - maxpad - 20; | - | ||||||||||||
321 | size_t off = out - p; | - | ||||||||||||
322 | unsigned int c, cmask; | - | ||||||||||||
323 | - | |||||||||||||
324 | maxpad += 20; | - | ||||||||||||
325 | for (res = 0, i = 0, j = 0; j < maxpad
| 0 | ||||||||||||
326 | c = p[j]; | - | ||||||||||||
327 | cmask = ((int)(j - off - | - | ||||||||||||
328 | 20)) >> | - | ||||||||||||
329 | (sizeof(int) * 8 - 1); | - | ||||||||||||
330 | res |= (c ^ pad) & ~cmask; | - | ||||||||||||
331 | cmask &= ((int)(off - 1 - j)) >> | - | ||||||||||||
332 | (sizeof(int) * 8 - 1); | - | ||||||||||||
333 | res |= (c ^ pmac->c[i]) & cmask; | - | ||||||||||||
334 | i += 1 & cmask; | - | ||||||||||||
335 | } never executed: end of block | 0 | ||||||||||||
336 | maxpad -= 20; | - | ||||||||||||
337 | - | |||||||||||||
338 | res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1)); | - | ||||||||||||
339 | ret &= (int)~res; | - | ||||||||||||
340 | } | - | ||||||||||||
341 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
342 | } else { | - | ||||||||||||
343 | sha1_update(&key->md, out, len); | - | ||||||||||||
344 | } never executed: end of block | 0 | ||||||||||||
345 | } | - | ||||||||||||
346 | - | |||||||||||||
347 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | static int | - | ||||||||||||
351 | aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) | - | ||||||||||||
352 | { | - | ||||||||||||
353 | EVP_AES_HMAC_SHA1 *key = ((EVP_AES_HMAC_SHA1 *)(ctx)->cipher_data); | - | ||||||||||||
354 | - | |||||||||||||
355 | switch (type) { | - | ||||||||||||
356 | case never executed: 0x17:case 0x17: never executed: case 0x17: | 0 | ||||||||||||
357 | { | - | ||||||||||||
358 | unsigned int i; | - | ||||||||||||
359 | unsigned char hmac_key[64]; | - | ||||||||||||
360 | - | |||||||||||||
361 | memset(hmac_key, 0, sizeof(hmac_key)); | - | ||||||||||||
362 | - | |||||||||||||
363 | if (arg > (int)sizeof(hmac_key)
| 0 | ||||||||||||
364 | SHA1_Init(&key->head); | - | ||||||||||||
365 | sha1_update(&key->head, ptr, arg); | - | ||||||||||||
366 | SHA1_Final(hmac_key, &key->head); | - | ||||||||||||
367 | } never executed: else {end of block | 0 | ||||||||||||
368 | memcpy(hmac_key, ptr, arg); | - | ||||||||||||
369 | } never executed: end of block | 0 | ||||||||||||
370 | - | |||||||||||||
371 | for (i = 0; i < sizeof(hmac_key)
| 0 | ||||||||||||
372 | hmac_key[i] ^= 0x36; never executed: hmac_key[i] ^= 0x36; | 0 | ||||||||||||
373 | SHA1_Init(&key->head); | - | ||||||||||||
374 | sha1_update(&key->head, hmac_key, sizeof(hmac_key)); | - | ||||||||||||
375 | - | |||||||||||||
376 | for (i = 0; i < sizeof(hmac_key)
| 0 | ||||||||||||
377 | hmac_key[i] ^= 0x36 ^ 0x5c; never executed: hmac_key[i] ^= 0x36 ^ 0x5c; | 0 | ||||||||||||
378 | SHA1_Init(&key->tail); | - | ||||||||||||
379 | sha1_update(&key->tail, hmac_key, sizeof(hmac_key)); | - | ||||||||||||
380 | - | |||||||||||||
381 | explicit_bzero(hmac_key, sizeof(hmac_key)); | - | ||||||||||||
382 | - | |||||||||||||
383 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
384 | } | - | ||||||||||||
385 | case never executed: 0x16:case 0x16: never executed: case 0x16: | 0 | ||||||||||||
386 | { | - | ||||||||||||
387 | unsigned char *p = ptr; | - | ||||||||||||
388 | unsigned int len = p[arg - 2] << 8 | p[arg - 1]; | - | ||||||||||||
389 | - | |||||||||||||
390 | if (ctx->encrypt
| 0 | ||||||||||||
391 | key->payload_length = len; | - | ||||||||||||
392 | if ((
| 0 | ||||||||||||
393 | p[arg - 3]) >= 0x0302
| 0 | ||||||||||||
394 | len -= 16; | - | ||||||||||||
395 | p[arg - 2] = len >> 8; | - | ||||||||||||
396 | p[arg - 1] = len; | - | ||||||||||||
397 | } never executed: end of block | 0 | ||||||||||||
398 | key->md = key->head; | - | ||||||||||||
399 | sha1_update(&key->md, p, arg); | - | ||||||||||||
400 | - | |||||||||||||
401 | return never executed: (int)(((len + 20 +return (int)(((len + 20 + 16) & -16) - len); never executed: return (int)(((len + 20 + 16) & -16) - len); | 0 | ||||||||||||
402 | 16) & -16) - len); never executed: return (int)(((len + 20 + 16) & -16) - len); | 0 | ||||||||||||
403 | } else { | - | ||||||||||||
404 | if (arg > 13
| 0 | ||||||||||||
405 | arg = 13; never executed: arg = 13; | 0 | ||||||||||||
406 | memcpy(key->aux.tls_aad, ptr, arg); | - | ||||||||||||
407 | key->payload_length = arg; | - | ||||||||||||
408 | - | |||||||||||||
409 | return never executed: 20;return 20; never executed: return 20; | 0 | ||||||||||||
410 | } | - | ||||||||||||
411 | } | - | ||||||||||||
412 | default never executed: :default: never executed: default: | 0 | ||||||||||||
413 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
414 | } | - | ||||||||||||
415 | } | - | ||||||||||||
416 | - | |||||||||||||
417 | static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = { | - | ||||||||||||
418 | - | |||||||||||||
419 | .nid = 916, | - | ||||||||||||
420 | - | |||||||||||||
421 | - | |||||||||||||
422 | - | |||||||||||||
423 | .block_size = 16, | - | ||||||||||||
424 | .key_len = 16, | - | ||||||||||||
425 | .iv_len = 16, | - | ||||||||||||
426 | .flags = 0x2 | 0x1000 | | - | ||||||||||||
427 | 0x200000, | - | ||||||||||||
428 | .init = aesni_cbc_hmac_sha1_init_key, | - | ||||||||||||
429 | .do_cipher = aesni_cbc_hmac_sha1_cipher, | - | ||||||||||||
430 | .ctx_size = sizeof(EVP_AES_HMAC_SHA1), | - | ||||||||||||
431 | .ctrl = aesni_cbc_hmac_sha1_ctrl | - | ||||||||||||
432 | }; | - | ||||||||||||
433 | - | |||||||||||||
434 | static EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = { | - | ||||||||||||
435 | - | |||||||||||||
436 | .nid = 918, | - | ||||||||||||
437 | - | |||||||||||||
438 | - | |||||||||||||
439 | - | |||||||||||||
440 | .block_size = 16, | - | ||||||||||||
441 | .key_len = 32, | - | ||||||||||||
442 | .iv_len = 16, | - | ||||||||||||
443 | .flags = 0x2 | 0x1000 | | - | ||||||||||||
444 | 0x200000, | - | ||||||||||||
445 | .init = aesni_cbc_hmac_sha1_init_key, | - | ||||||||||||
446 | .do_cipher = aesni_cbc_hmac_sha1_cipher, | - | ||||||||||||
447 | .ctx_size = sizeof(EVP_AES_HMAC_SHA1), | - | ||||||||||||
448 | .ctrl = aesni_cbc_hmac_sha1_ctrl | - | ||||||||||||
449 | }; | - | ||||||||||||
450 | - | |||||||||||||
451 | const EVP_CIPHER * | - | ||||||||||||
452 | EVP_aes_128_cbc_hmac_sha1(void) | - | ||||||||||||
453 | { | - | ||||||||||||
454 | return executed 625 times by 33 tests: (return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_128_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_128_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 0-625 | ||||||||||||
455 | &aesni_128_cbc_hmac_sha1_cipher : executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_128_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
456 | ((void *)0) executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_128_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
457 | ; executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_128_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
458 | } | - | ||||||||||||
459 | - | |||||||||||||
460 | const EVP_CIPHER * | - | ||||||||||||
461 | EVP_aes_256_cbc_hmac_sha1(void) | - | ||||||||||||
462 | { | - | ||||||||||||
463 | return executed 625 times by 33 tests: (return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_256_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_256_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 0-625 | ||||||||||||
464 | &aesni_256_cbc_hmac_sha1_cipher : executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_256_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
465 | ((void *)0) executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_256_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
466 | ; executed 625 times by 33 tests: return (OPENSSL_cpu_caps() & (1ULL << (32 + 25))) ? &aesni_256_cbc_hmac_sha1_cipher : ((void *)0) ; Executed by:
| 625 | ||||||||||||
467 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |