Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/gcm128.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | static void gcm_init_4bit(u128 Htable[16], u64 H[2]) | - | ||||||||||||||||||
3 | { | - | ||||||||||||||||||
4 | u128 V; | - | ||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | Htable[0].hi = 0; | - | ||||||||||||||||||
10 | Htable[0].lo = 0; | - | ||||||||||||||||||
11 | V.hi = H[0]; | - | ||||||||||||||||||
12 | V.lo = H[1]; | - | ||||||||||||||||||
13 | Htable[8] = V; | - | ||||||||||||||||||
14 | do { if (sizeof(size_t)==8
executed 7990 times by 2 tests: else { u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); V.lo = (V.hi<<63)|(V.lo>>1); V.hi = (V.hi>>1 )^((u64)T<<32); }end of block Executed by:
never executed: } while(0);end of block | 0-7990 | ||||||||||||||||||
15 | Htable[4] = V; | - | ||||||||||||||||||
16 | do { if (sizeof(size_t)==8
executed 7990 times by 2 tests: else { u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); V.lo = (V.hi<<63)|(V.lo>>1); V.hi = (V.hi>>1 )^((u64)T<<32); }end of block Executed by:
never executed: } while(0);end of block | 0-7990 | ||||||||||||||||||
17 | Htable[2] = V; | - | ||||||||||||||||||
18 | do { if (sizeof(size_t)==8
executed 7990 times by 2 tests: else { u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); V.lo = (V.hi<<63)|(V.lo>>1); V.hi = (V.hi>>1 )^((u64)T<<32); }end of block Executed by:
never executed: } while(0);end of block | 0-7990 | ||||||||||||||||||
19 | Htable[1] = V; | - | ||||||||||||||||||
20 | Htable[3].hi = V.hi ^ Htable[2].hi, Htable[3].lo = V.lo ^ Htable[2].lo; | - | ||||||||||||||||||
21 | V = Htable[4]; | - | ||||||||||||||||||
22 | Htable[5].hi = V.hi ^ Htable[1].hi, Htable[5].lo = V.lo ^ Htable[1].lo; | - | ||||||||||||||||||
23 | Htable[6].hi = V.hi ^ Htable[2].hi, Htable[6].lo = V.lo ^ Htable[2].lo; | - | ||||||||||||||||||
24 | Htable[7].hi = V.hi ^ Htable[3].hi, Htable[7].lo = V.lo ^ Htable[3].lo; | - | ||||||||||||||||||
25 | V = Htable[8]; | - | ||||||||||||||||||
26 | Htable[9].hi = V.hi ^ Htable[1].hi, Htable[9].lo = V.lo ^ Htable[1].lo; | - | ||||||||||||||||||
27 | Htable[10].hi = V.hi ^ Htable[2].hi, Htable[10].lo = V.lo ^ Htable[2].lo; | - | ||||||||||||||||||
28 | Htable[11].hi = V.hi ^ Htable[3].hi, Htable[11].lo = V.lo ^ Htable[3].lo; | - | ||||||||||||||||||
29 | Htable[12].hi = V.hi ^ Htable[4].hi, Htable[12].lo = V.lo ^ Htable[4].lo; | - | ||||||||||||||||||
30 | Htable[13].hi = V.hi ^ Htable[5].hi, Htable[13].lo = V.lo ^ Htable[5].lo; | - | ||||||||||||||||||
31 | Htable[14].hi = V.hi ^ Htable[6].hi, Htable[14].lo = V.lo ^ Htable[6].lo; | - | ||||||||||||||||||
32 | Htable[15].hi = V.hi ^ Htable[7].hi, Htable[15].lo = V.lo ^ Htable[7].lo; | - | ||||||||||||||||||
33 | } executed 7990 times by 2 tests: end of block Executed by:
| 7990 | ||||||||||||||||||
34 | void gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]); | - | ||||||||||||||||||
35 | void gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp, | - | ||||||||||||||||||
36 | size_t len); | - | ||||||||||||||||||
37 | extern unsigned int OPENSSL_ia32cap_P[]; | - | ||||||||||||||||||
38 | - | |||||||||||||||||||
39 | void gcm_init_clmul(u128 Htable[16], const u64 Xi[2]); | - | ||||||||||||||||||
40 | void gcm_gmult_clmul(u64 Xi[2], const u128 Htable[16]); | - | ||||||||||||||||||
41 | void gcm_ghash_clmul(u64 Xi[2], const u128 Htable[16], const u8 *inp, | - | ||||||||||||||||||
42 | size_t len); | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | - | |||||||||||||||||||
45 | - | |||||||||||||||||||
46 | - | |||||||||||||||||||
47 | - | |||||||||||||||||||
48 | - | |||||||||||||||||||
49 | void gcm_init_avx(u128 Htable[16], const u64 Xi[2]); | - | ||||||||||||||||||
50 | void gcm_gmult_avx(u64 Xi[2], const u128 Htable[16]); | - | ||||||||||||||||||
51 | void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *inp, | - | ||||||||||||||||||
52 | size_t len); | - | ||||||||||||||||||
53 | void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block) | - | ||||||||||||||||||
54 | { | - | ||||||||||||||||||
55 | const union { | - | ||||||||||||||||||
56 | long one; | - | ||||||||||||||||||
57 | char little; | - | ||||||||||||||||||
58 | } is_endian = { 1 }; | - | ||||||||||||||||||
59 | - | |||||||||||||||||||
60 | memset(ctx, 0, sizeof(*ctx)); | - | ||||||||||||||||||
61 | ctx->block = block; | - | ||||||||||||||||||
62 | ctx->key = key; | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | (*block) (ctx->H.c, ctx->H.c, key); | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | if (is_endian.little
| 0-7990 | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | - | |||||||||||||||||||
69 | ctx->H.u[0] = ({ u64 ret_=(ctx->H.u[0]); asm ("bswapq %0" : "+r"(ret_)); ret_; }); | - | ||||||||||||||||||
70 | ctx->H.u[1] = ({ u64 ret_=(ctx->H.u[1]); asm ("bswapq %0" : "+r"(ret_)); ret_; }); | - | ||||||||||||||||||
71 | } executed 7990 times by 2 tests: end of block Executed by:
| 7990 | ||||||||||||||||||
72 | if (OPENSSL_ia32cap_P[1] & (1 << 1)
| 0-7990 | ||||||||||||||||||
73 | if (((
| 0 | ||||||||||||||||||
74 | gcm_init_avx(ctx->Htable, ctx->H.u); | - | ||||||||||||||||||
75 | ctx->gmult = gcm_gmult_avx; | - | ||||||||||||||||||
76 | (ctx->ghash = (gcm_ghash_avx)); | - | ||||||||||||||||||
77 | } never executed: else {end of block | 0 | ||||||||||||||||||
78 | gcm_init_clmul(ctx->Htable, ctx->H.u); | - | ||||||||||||||||||
79 | ctx->gmult = gcm_gmult_clmul; | - | ||||||||||||||||||
80 | (ctx->ghash = (gcm_ghash_clmul)); | - | ||||||||||||||||||
81 | } never executed: end of block | 0 | ||||||||||||||||||
82 | return; never executed: return; | 0 | ||||||||||||||||||
83 | } | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | gcm_init_4bit(ctx->Htable, ctx->H.u); | - | ||||||||||||||||||
86 | ctx->gmult = gcm_gmult_4bit; | - | ||||||||||||||||||
87 | (ctx->ghash = (gcm_ghash_4bit)); | - | ||||||||||||||||||
88 | } executed 7990 times by 2 tests: end of block Executed by:
| 7990 | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, | - | ||||||||||||||||||
91 | size_t len) | - | ||||||||||||||||||
92 | { | - | ||||||||||||||||||
93 | const union { | - | ||||||||||||||||||
94 | long one; | - | ||||||||||||||||||
95 | char little; | - | ||||||||||||||||||
96 | } is_endian = { 1 }; | - | ||||||||||||||||||
97 | unsigned int ctr; | - | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | - | |||||||||||||||||||
102 | ctx->len.u[0] = 0; | - | ||||||||||||||||||
103 | ctx->len.u[1] = 0; | - | ||||||||||||||||||
104 | ctx->ares = 0; | - | ||||||||||||||||||
105 | ctx->mres = 0; | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | if (len == 12
| 233-31380 | ||||||||||||||||||
108 | memcpy(ctx->Yi.c, iv, 12); | - | ||||||||||||||||||
109 | ctx->Yi.c[12] = 0; | - | ||||||||||||||||||
110 | ctx->Yi.c[13] = 0; | - | ||||||||||||||||||
111 | ctx->Yi.c[14] = 0; | - | ||||||||||||||||||
112 | ctx->Yi.c[15] = 1; | - | ||||||||||||||||||
113 | ctr = 1; | - | ||||||||||||||||||
114 | } executed 31380 times by 2 tests: else {end of block Executed by:
| 31380 | ||||||||||||||||||
115 | size_t i; | - | ||||||||||||||||||
116 | u64 len0 = len; | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | - | |||||||||||||||||||
119 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
120 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | while (len >= 16
| 233-539 | ||||||||||||||||||
123 | for (i = 0; i < 16
| 539-8624 | ||||||||||||||||||
124 | ctx->Xi.c[i] ^= iv[i]; executed 8624 times by 2 tests: ctx->Xi.c[i] ^= iv[i]; Executed by:
| 8624 | ||||||||||||||||||
125 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
126 | iv += 16; | - | ||||||||||||||||||
127 | len -= 16; | - | ||||||||||||||||||
128 | } executed 539 times by 2 tests: end of block Executed by:
| 539 | ||||||||||||||||||
129 | if (len
| 74-159 | ||||||||||||||||||
130 | for (i = 0; i < len
| 159-1596 | ||||||||||||||||||
131 | ctx->Xi.c[i] ^= iv[i]; executed 1596 times by 2 tests: ctx->Xi.c[i] ^= iv[i]; Executed by:
| 1596 | ||||||||||||||||||
132 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
133 | } executed 159 times by 2 tests: end of block Executed by:
| 159 | ||||||||||||||||||
134 | len0 <<= 3; | - | ||||||||||||||||||
135 | if (is_endian.little
| 0-233 | ||||||||||||||||||
136 | - | |||||||||||||||||||
137 | ctx->Xi.u[1] ^= ({ u64 ret_=(len0); asm ("bswapq %0" : "+r"(ret_)); ret_; }); | - | ||||||||||||||||||
138 | } executed 233 times by 2 tests: else {end of block Executed by:
| 233 | ||||||||||||||||||
139 | ctx->Xi.u[1] ^= len0; | - | ||||||||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | if (is_endian.little
| 0-233 | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | ctr = ({ u32 ret_=(ctx->Xi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 233 times by 2 tests: ctr = ({ u32 ret_=(ctx->Xi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 233 | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | - | |||||||||||||||||||
149 | - | |||||||||||||||||||
150 | else | - | ||||||||||||||||||
151 | ctr = ctx->Xi.d[3]; never executed: ctr = ctx->Xi.d[3]; | 0 | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | - | |||||||||||||||||||
154 | ctx->Yi.u[0] = ctx->Xi.u[0]; | - | ||||||||||||||||||
155 | ctx->Yi.u[1] = ctx->Xi.u[1]; | - | ||||||||||||||||||
156 | } executed 233 times by 2 tests: end of block Executed by:
| 233 | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
159 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
160 | - | |||||||||||||||||||
161 | (*ctx->block) (ctx->Yi.c, ctx->EK0.c, ctx->key); | - | ||||||||||||||||||
162 | ++ctr; | - | ||||||||||||||||||
163 | if (is_endian.little
| 0-31613 | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 31613 times by 2 tests: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 31613 | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | - | |||||||||||||||||||
168 | - | |||||||||||||||||||
169 | else | - | ||||||||||||||||||
170 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
171 | } | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, | - | ||||||||||||||||||
174 | size_t len) | - | ||||||||||||||||||
175 | { | - | ||||||||||||||||||
176 | size_t i; | - | ||||||||||||||||||
177 | unsigned int n; | - | ||||||||||||||||||
178 | u64 alen = ctx->len.u[0]; | - | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
181 | - | |||||||||||||||||||
182 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
183 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | - | |||||||||||||||||||
186 | - | |||||||||||||||||||
187 | if (ctx->len.u[1]
| 0-31713 | ||||||||||||||||||
188 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | alen += len; | - | ||||||||||||||||||
191 | if (alen > (1ULL << 61)
| 0-31713 | ||||||||||||||||||
192 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
193 | ctx->len.u[0] = alen; | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | n = ctx->ares; | - | ||||||||||||||||||
196 | if (n
| 312-31401 | ||||||||||||||||||
197 | while (n
| 156-2532 | ||||||||||||||||||
198 | ctx->Xi.c[n] ^= *(aad++); | - | ||||||||||||||||||
199 | --len; | - | ||||||||||||||||||
200 | n = (n + 1) % 16; | - | ||||||||||||||||||
201 | } executed 2376 times by 1 test: end of block Executed by:
| 2376 | ||||||||||||||||||
202 | if (n == 0
| 156 | ||||||||||||||||||
203 | (* executed 156 times by 1 test: gcm_gmult_p)(ctx->Xi.u,ctx->Htable);(*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); Executed by:
executed 156 times by 1 test: (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); Executed by:
| 156 | ||||||||||||||||||
204 | else { | - | ||||||||||||||||||
205 | ctx->ares = n; | - | ||||||||||||||||||
206 | return executed 156 times by 1 test: 0;return 0; Executed by:
executed 156 times by 1 test: return 0; Executed by:
| 156 | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | } | - | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | if ((
| 167-31390 | ||||||||||||||||||
211 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,aad,i); | - | ||||||||||||||||||
212 | aad += i; | - | ||||||||||||||||||
213 | len -= i; | - | ||||||||||||||||||
214 | } executed 167 times by 2 tests: end of block Executed by:
| 167 | ||||||||||||||||||
215 | if (len
| 242-31315 | ||||||||||||||||||
216 | n = (unsigned int)len; | - | ||||||||||||||||||
217 | for (i = 0; i < len
| 31315-201110 | ||||||||||||||||||
218 | ctx->Xi.c[i] ^= aad[i]; executed 201110 times by 2 tests: ctx->Xi.c[i] ^= aad[i]; Executed by:
| 201110 | ||||||||||||||||||
219 | } executed 31315 times by 2 tests: end of block Executed by:
| 31315 | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | ctx->ares = n; | - | ||||||||||||||||||
222 | return executed 31557 times by 2 tests: 0;return 0; Executed by:
executed 31557 times by 2 tests: return 0; Executed by:
| 31557 | ||||||||||||||||||
223 | } | - | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, | - | ||||||||||||||||||
226 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
227 | size_t len) | - | ||||||||||||||||||
228 | { | - | ||||||||||||||||||
229 | const union { | - | ||||||||||||||||||
230 | long one; | - | ||||||||||||||||||
231 | char little; | - | ||||||||||||||||||
232 | } is_endian = { 1 }; | - | ||||||||||||||||||
233 | unsigned int n, ctr, mres; | - | ||||||||||||||||||
234 | size_t i; | - | ||||||||||||||||||
235 | u64 mlen = ctx->len.u[1]; | - | ||||||||||||||||||
236 | block128_f block = ctx->block; | - | ||||||||||||||||||
237 | void *key = ctx->key; | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
242 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
243 | - | |||||||||||||||||||
244 | - | |||||||||||||||||||
245 | - | |||||||||||||||||||
246 | mlen += len; | - | ||||||||||||||||||
247 | if (mlen > ((1ULL << 36) - 32)
| 0-270 | ||||||||||||||||||
248 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
249 | ctx->len.u[1] = mlen; | - | ||||||||||||||||||
250 | - | |||||||||||||||||||
251 | mres = ctx->mres; | - | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | if (ctx->ares
| 31-239 | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | - | |||||||||||||||||||
256 | if (len == 0
| 0-239 | ||||||||||||||||||
257 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
258 | ctx->ares = 0; | - | ||||||||||||||||||
259 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
260 | } | - | ||||||||||||||||||
261 | memcpy(ctx->Xn, ctx->Xi.c, sizeof(ctx->Xi)); | - | ||||||||||||||||||
262 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
263 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
264 | mres = sizeof(ctx->Xi); | - | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | - | |||||||||||||||||||
267 | - | |||||||||||||||||||
268 | ctx->ares = 0; | - | ||||||||||||||||||
269 | } executed 239 times by 2 tests: end of block Executed by:
| 239 | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | if (is_endian.little
| 0-270 | ||||||||||||||||||
272 | - | |||||||||||||||||||
273 | ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 270 times by 2 tests: ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 270 | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | - | |||||||||||||||||||
276 | - | |||||||||||||||||||
277 | else | - | ||||||||||||||||||
278 | ctr = ctx->Yi.d[3]; never executed: ctr = ctx->Yi.d[3]; | 0 | ||||||||||||||||||
279 | - | |||||||||||||||||||
280 | n = mres % 16; | - | ||||||||||||||||||
281 | - | |||||||||||||||||||
282 | if (16 % sizeof(size_t) == 0
| 0-270 | ||||||||||||||||||
283 | do { | - | ||||||||||||||||||
284 | if (n
| 24-246 | ||||||||||||||||||
285 | - | |||||||||||||||||||
286 | while (n
| 0-192 | ||||||||||||||||||
287 | ctx->Xn[mres++] = *(out++) = *(in++) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
288 | --len; | - | ||||||||||||||||||
289 | n = (n + 1) % 16; | - | ||||||||||||||||||
290 | } executed 192 times by 1 test: end of block Executed by:
| 192 | ||||||||||||||||||
291 | if (n == 0
| 0-24 | ||||||||||||||||||
292 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
293 | mres = 0; | - | ||||||||||||||||||
294 | } executed 24 times by 1 test: else {end of block Executed by:
| 24 | ||||||||||||||||||
295 | ctx->mres = mres; | - | ||||||||||||||||||
296 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
297 | } | - | ||||||||||||||||||
298 | } | - | ||||||||||||||||||
299 | - | |||||||||||||||||||
300 | - | |||||||||||||||||||
301 | - | |||||||||||||||||||
302 | - | |||||||||||||||||||
303 | - | |||||||||||||||||||
304 | if (len >= 16
| 19-185 | ||||||||||||||||||
305 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
306 | mres = 0; | - | ||||||||||||||||||
307 | } executed 166 times by 2 tests: end of block Executed by:
| 166 | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | while (len >= (3*1024)
| 0-270 | ||||||||||||||||||
310 | size_t j = (3*1024); | - | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | while (j
| 0 | ||||||||||||||||||
313 | size_t *out_t = (size_t *)out; | - | ||||||||||||||||||
314 | const size_t *in_t = (const size_t *)in; | - | ||||||||||||||||||
315 | - | |||||||||||||||||||
316 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
317 | ++ctr; | - | ||||||||||||||||||
318 | if (is_endian.little
| 0 | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); never executed: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); | 0 | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | - | |||||||||||||||||||
323 | - | |||||||||||||||||||
324 | else | - | ||||||||||||||||||
325 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
326 | for (i = 0; i < 16 / sizeof(size_t)
| 0 | ||||||||||||||||||
327 | out_t[i] = in_t[i] ^ ctx->EKi.t[i]; never executed: out_t[i] = in_t[i] ^ ctx->EKi.t[i]; | 0 | ||||||||||||||||||
328 | out += 16; | - | ||||||||||||||||||
329 | in += 16; | - | ||||||||||||||||||
330 | j -= 16; | - | ||||||||||||||||||
331 | } never executed: end of block | 0 | ||||||||||||||||||
332 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,out - (3*1024),(3*1024)); | - | ||||||||||||||||||
333 | len -= (3*1024); | - | ||||||||||||||||||
334 | } never executed: end of block | 0 | ||||||||||||||||||
335 | - | |||||||||||||||||||
336 | if ((
| 85-185 | ||||||||||||||||||
337 | size_t j = i; | - | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | while (len >= 16
| 185-2425 | ||||||||||||||||||
340 | size_t *out_t = (size_t *)out; | - | ||||||||||||||||||
341 | const size_t *in_t = (const size_t *)in; | - | ||||||||||||||||||
342 | - | |||||||||||||||||||
343 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
344 | ++ctr; | - | ||||||||||||||||||
345 | if (is_endian.little
| 0-2425 | ||||||||||||||||||
346 | - | |||||||||||||||||||
347 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 2425 times by 2 tests: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 2425 | ||||||||||||||||||
348 | - | |||||||||||||||||||
349 | - | |||||||||||||||||||
350 | - | |||||||||||||||||||
351 | else | - | ||||||||||||||||||
352 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
353 | for (i = 0; i < 16 / sizeof(size_t)
| 2425-4850 | ||||||||||||||||||
354 | out_t[i] = in_t[i] ^ ctx->EKi.t[i]; executed 4850 times by 2 tests: out_t[i] = in_t[i] ^ ctx->EKi.t[i]; Executed by:
| 4850 | ||||||||||||||||||
355 | out += 16; | - | ||||||||||||||||||
356 | in += 16; | - | ||||||||||||||||||
357 | len -= 16; | - | ||||||||||||||||||
358 | } executed 2425 times by 2 tests: end of block Executed by:
| 2425 | ||||||||||||||||||
359 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,out - j,j); | - | ||||||||||||||||||
360 | } executed 185 times by 2 tests: end of block Executed by:
| 185 | ||||||||||||||||||
361 | if (len
| 116-154 | ||||||||||||||||||
362 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
363 | ++ctr; | - | ||||||||||||||||||
364 | if (is_endian.little
| 0-154 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 154 times by 2 tests: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 154 | ||||||||||||||||||
367 | - | |||||||||||||||||||
368 | - | |||||||||||||||||||
369 | - | |||||||||||||||||||
370 | else | - | ||||||||||||||||||
371 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
372 | - | |||||||||||||||||||
373 | while (len--
| 154-900 | ||||||||||||||||||
374 | ctx->Xn[mres++] = out[n] = in[n] ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
375 | ++n; | - | ||||||||||||||||||
376 | } executed 900 times by 2 tests: end of block Executed by:
| 900 | ||||||||||||||||||
377 | - | |||||||||||||||||||
378 | - | |||||||||||||||||||
379 | - | |||||||||||||||||||
380 | - | |||||||||||||||||||
381 | - | |||||||||||||||||||
382 | - | |||||||||||||||||||
383 | - | |||||||||||||||||||
384 | } executed 154 times by 2 tests: end of block Executed by:
| 154 | ||||||||||||||||||
385 | - | |||||||||||||||||||
386 | ctx->mres = mres; | - | ||||||||||||||||||
387 | return executed 270 times by 2 tests: 0;return 0; Executed by:
executed 270 times by 2 tests: return 0; Executed by:
| 270 | ||||||||||||||||||
388 | } while (0); | - | ||||||||||||||||||
389 | } never executed: end of block | 0 | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | for (i = 0; i < len
| 0 | ||||||||||||||||||
392 | if (n == 0
| 0 | ||||||||||||||||||
393 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
394 | ++ctr; | - | ||||||||||||||||||
395 | if (is_endian.little
| 0 | ||||||||||||||||||
396 | - | |||||||||||||||||||
397 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); never executed: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); | 0 | ||||||||||||||||||
398 | - | |||||||||||||||||||
399 | - | |||||||||||||||||||
400 | - | |||||||||||||||||||
401 | else | - | ||||||||||||||||||
402 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
403 | } | - | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | ctx->Xn[mres++] = out[i] = in[i] ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
406 | n = (n + 1) % 16; | - | ||||||||||||||||||
407 | if (mres == sizeof(ctx->Xn)
| 0 | ||||||||||||||||||
408 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,sizeof(ctx->Xn)); | - | ||||||||||||||||||
409 | mres = 0; | - | ||||||||||||||||||
410 | } never executed: end of block | 0 | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | - | |||||||||||||||||||
413 | - | |||||||||||||||||||
414 | - | |||||||||||||||||||
415 | - | |||||||||||||||||||
416 | - | |||||||||||||||||||
417 | } never executed: end of block | 0 | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | ctx->mres = mres; | - | ||||||||||||||||||
420 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
421 | } | - | ||||||||||||||||||
422 | - | |||||||||||||||||||
423 | int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, | - | ||||||||||||||||||
424 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
425 | size_t len) | - | ||||||||||||||||||
426 | { | - | ||||||||||||||||||
427 | const union { | - | ||||||||||||||||||
428 | long one; | - | ||||||||||||||||||
429 | char little; | - | ||||||||||||||||||
430 | } is_endian = { 1 }; | - | ||||||||||||||||||
431 | unsigned int n, ctr, mres; | - | ||||||||||||||||||
432 | size_t i; | - | ||||||||||||||||||
433 | u64 mlen = ctx->len.u[1]; | - | ||||||||||||||||||
434 | block128_f block = ctx->block; | - | ||||||||||||||||||
435 | void *key = ctx->key; | - | ||||||||||||||||||
436 | - | |||||||||||||||||||
437 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
438 | - | |||||||||||||||||||
439 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
440 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
441 | - | |||||||||||||||||||
442 | - | |||||||||||||||||||
443 | - | |||||||||||||||||||
444 | mlen += len; | - | ||||||||||||||||||
445 | if (mlen > ((1ULL << 36) - 32)
| 0-175 | ||||||||||||||||||
446 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
447 | ctx->len.u[1] = mlen; | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | mres = ctx->mres; | - | ||||||||||||||||||
450 | - | |||||||||||||||||||
451 | if (ctx->ares
| 31-144 | ||||||||||||||||||
452 | - | |||||||||||||||||||
453 | - | |||||||||||||||||||
454 | if (len == 0
| 3-141 | ||||||||||||||||||
455 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
456 | ctx->ares = 0; | - | ||||||||||||||||||
457 | return executed 3 times by 1 test: 0;return 0; Executed by:
executed 3 times by 1 test: return 0; Executed by:
| 3 | ||||||||||||||||||
458 | } | - | ||||||||||||||||||
459 | memcpy(ctx->Xn, ctx->Xi.c, sizeof(ctx->Xi)); | - | ||||||||||||||||||
460 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
461 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
462 | mres = sizeof(ctx->Xi); | - | ||||||||||||||||||
463 | - | |||||||||||||||||||
464 | - | |||||||||||||||||||
465 | - | |||||||||||||||||||
466 | ctx->ares = 0; | - | ||||||||||||||||||
467 | } executed 141 times by 2 tests: end of block Executed by:
| 141 | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | if (is_endian.little
| 0-172 | ||||||||||||||||||
470 | - | |||||||||||||||||||
471 | ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 172 times by 2 tests: ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 172 | ||||||||||||||||||
472 | - | |||||||||||||||||||
473 | - | |||||||||||||||||||
474 | - | |||||||||||||||||||
475 | else | - | ||||||||||||||||||
476 | ctr = ctx->Yi.d[3]; never executed: ctr = ctx->Yi.d[3]; | 0 | ||||||||||||||||||
477 | - | |||||||||||||||||||
478 | n = mres % 16; | - | ||||||||||||||||||
479 | - | |||||||||||||||||||
480 | if (16 % sizeof(size_t) == 0
| 0-172 | ||||||||||||||||||
481 | do { | - | ||||||||||||||||||
482 | if (n
| 24-148 | ||||||||||||||||||
483 | - | |||||||||||||||||||
484 | while (n
| 0-192 | ||||||||||||||||||
485 | *(out++) = (ctx->Xn[mres++] = *(in++)) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
486 | --len; | - | ||||||||||||||||||
487 | n = (n + 1) % 16; | - | ||||||||||||||||||
488 | } executed 192 times by 1 test: end of block Executed by:
| 192 | ||||||||||||||||||
489 | if (n == 0
| 0-24 | ||||||||||||||||||
490 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
491 | mres = 0; | - | ||||||||||||||||||
492 | } executed 24 times by 1 test: else {end of block Executed by:
| 24 | ||||||||||||||||||
493 | ctx->mres = mres; | - | ||||||||||||||||||
494 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
495 | } | - | ||||||||||||||||||
496 | } | - | ||||||||||||||||||
497 | - | |||||||||||||||||||
498 | - | |||||||||||||||||||
499 | - | |||||||||||||||||||
500 | - | |||||||||||||||||||
501 | - | |||||||||||||||||||
502 | if (len >= 16
| 19-140 | ||||||||||||||||||
503 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
504 | mres = 0; | - | ||||||||||||||||||
505 | } executed 121 times by 2 tests: end of block Executed by:
| 121 | ||||||||||||||||||
506 | - | |||||||||||||||||||
507 | while (len >= (3*1024)
| 60-172 | ||||||||||||||||||
508 | size_t j = (3*1024); | - | ||||||||||||||||||
509 | - | |||||||||||||||||||
510 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,(3*1024)); | - | ||||||||||||||||||
511 | while (j
| 60-11520 | ||||||||||||||||||
512 | size_t *out_t = (size_t *)out; | - | ||||||||||||||||||
513 | const size_t *in_t = (const size_t *)in; | - | ||||||||||||||||||
514 | - | |||||||||||||||||||
515 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
516 | ++ctr; | - | ||||||||||||||||||
517 | if (is_endian.little
| 0-11520 | ||||||||||||||||||
518 | - | |||||||||||||||||||
519 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 11520 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 11520 | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | - | |||||||||||||||||||
522 | - | |||||||||||||||||||
523 | else | - | ||||||||||||||||||
524 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
525 | for (i = 0; i < 16 / sizeof(size_t)
| 11520-23040 | ||||||||||||||||||
526 | out_t[i] = in_t[i] ^ ctx->EKi.t[i]; executed 23040 times by 1 test: out_t[i] = in_t[i] ^ ctx->EKi.t[i]; Executed by:
| 23040 | ||||||||||||||||||
527 | out += 16; | - | ||||||||||||||||||
528 | in += 16; | - | ||||||||||||||||||
529 | j -= 16; | - | ||||||||||||||||||
530 | } executed 11520 times by 1 test: end of block Executed by:
| 11520 | ||||||||||||||||||
531 | len -= (3*1024); | - | ||||||||||||||||||
532 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||
533 | - | |||||||||||||||||||
534 | if ((
| 34-138 | ||||||||||||||||||
535 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,i); | - | ||||||||||||||||||
536 | while (len >= 16
| 138-3149 | ||||||||||||||||||
537 | size_t *out_t = (size_t *)out; | - | ||||||||||||||||||
538 | const size_t *in_t = (const size_t *)in; | - | ||||||||||||||||||
539 | - | |||||||||||||||||||
540 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
541 | ++ctr; | - | ||||||||||||||||||
542 | if (is_endian.little
| 0-3149 | ||||||||||||||||||
543 | - | |||||||||||||||||||
544 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 3149 times by 2 tests: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 3149 | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | - | |||||||||||||||||||
547 | - | |||||||||||||||||||
548 | else | - | ||||||||||||||||||
549 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
550 | for (i = 0; i < 16 / sizeof(size_t)
| 3149-6298 | ||||||||||||||||||
551 | out_t[i] = in_t[i] ^ ctx->EKi.t[i]; executed 6298 times by 2 tests: out_t[i] = in_t[i] ^ ctx->EKi.t[i]; Executed by:
| 6298 | ||||||||||||||||||
552 | out += 16; | - | ||||||||||||||||||
553 | in += 16; | - | ||||||||||||||||||
554 | len -= 16; | - | ||||||||||||||||||
555 | } executed 3149 times by 2 tests: end of block Executed by:
| 3149 | ||||||||||||||||||
556 | } executed 138 times by 2 tests: end of block Executed by:
| 138 | ||||||||||||||||||
557 | if (len
| 80-92 | ||||||||||||||||||
558 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
559 | ++ctr; | - | ||||||||||||||||||
560 | if (is_endian.little
| 0-92 | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 92 times by 2 tests: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 92 | ||||||||||||||||||
563 | - | |||||||||||||||||||
564 | - | |||||||||||||||||||
565 | - | |||||||||||||||||||
566 | else | - | ||||||||||||||||||
567 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
568 | - | |||||||||||||||||||
569 | while (len--
| 92-773 | ||||||||||||||||||
570 | out[n] = (ctx->Xn[mres++] = in[n]) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
571 | ++n; | - | ||||||||||||||||||
572 | } executed 773 times by 2 tests: end of block Executed by:
| 773 | ||||||||||||||||||
573 | } executed 92 times by 2 tests: end of block Executed by:
| 92 | ||||||||||||||||||
574 | - | |||||||||||||||||||
575 | ctx->mres = mres; | - | ||||||||||||||||||
576 | return executed 172 times by 2 tests: 0;return 0; Executed by:
executed 172 times by 2 tests: return 0; Executed by:
| 172 | ||||||||||||||||||
577 | } while (0); | - | ||||||||||||||||||
578 | } never executed: end of block | 0 | ||||||||||||||||||
579 | - | |||||||||||||||||||
580 | for (i = 0; i < len
| 0 | ||||||||||||||||||
581 | u8 c; | - | ||||||||||||||||||
582 | if (n == 0
| 0 | ||||||||||||||||||
583 | (*block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
584 | ++ctr; | - | ||||||||||||||||||
585 | if (is_endian.little
| 0 | ||||||||||||||||||
586 | - | |||||||||||||||||||
587 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); never executed: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); | 0 | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | - | |||||||||||||||||||
590 | - | |||||||||||||||||||
591 | else | - | ||||||||||||||||||
592 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
593 | } | - | ||||||||||||||||||
594 | - | |||||||||||||||||||
595 | out[i] = (ctx->Xn[mres++] = c = in[i]) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
596 | n = (n + 1) % 16; | - | ||||||||||||||||||
597 | if (mres == sizeof(ctx->Xn)
| 0 | ||||||||||||||||||
598 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,sizeof(ctx->Xn)); | - | ||||||||||||||||||
599 | mres = 0; | - | ||||||||||||||||||
600 | } never executed: end of block | 0 | ||||||||||||||||||
601 | } never executed: end of block | 0 | ||||||||||||||||||
602 | - | |||||||||||||||||||
603 | ctx->mres = mres; | - | ||||||||||||||||||
604 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
605 | } | - | ||||||||||||||||||
606 | - | |||||||||||||||||||
607 | int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, | - | ||||||||||||||||||
608 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
609 | size_t len, ctr128_f stream) | - | ||||||||||||||||||
610 | { | - | ||||||||||||||||||
611 | - | |||||||||||||||||||
612 | - | |||||||||||||||||||
613 | - | |||||||||||||||||||
614 | const union { | - | ||||||||||||||||||
615 | long one; | - | ||||||||||||||||||
616 | char little; | - | ||||||||||||||||||
617 | } is_endian = { 1 }; | - | ||||||||||||||||||
618 | unsigned int n, ctr, mres; | - | ||||||||||||||||||
619 | size_t i; | - | ||||||||||||||||||
620 | u64 mlen = ctx->len.u[1]; | - | ||||||||||||||||||
621 | void *key = ctx->key; | - | ||||||||||||||||||
622 | - | |||||||||||||||||||
623 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
624 | - | |||||||||||||||||||
625 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
626 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | - | |||||||||||||||||||
629 | - | |||||||||||||||||||
630 | mlen += len; | - | ||||||||||||||||||
631 | if (mlen > ((1ULL << 36) - 32)
| 0-15231 | ||||||||||||||||||
632 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
633 | ctx->len.u[1] = mlen; | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | mres = ctx->mres; | - | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | if (ctx->ares
| 468-14763 | ||||||||||||||||||
638 | - | |||||||||||||||||||
639 | - | |||||||||||||||||||
640 | if (len == 0
| 0-14763 | ||||||||||||||||||
641 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
642 | ctx->ares = 0; | - | ||||||||||||||||||
643 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
644 | } | - | ||||||||||||||||||
645 | memcpy(ctx->Xn, ctx->Xi.c, sizeof(ctx->Xi)); | - | ||||||||||||||||||
646 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
647 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
648 | mres = sizeof(ctx->Xi); | - | ||||||||||||||||||
649 | - | |||||||||||||||||||
650 | - | |||||||||||||||||||
651 | - | |||||||||||||||||||
652 | ctx->ares = 0; | - | ||||||||||||||||||
653 | } executed 14763 times by 1 test: end of block Executed by:
| 14763 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | if (is_endian.little
| 0-15231 | ||||||||||||||||||
656 | - | |||||||||||||||||||
657 | ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 15231 times by 1 test: ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 15231 | ||||||||||||||||||
658 | - | |||||||||||||||||||
659 | - | |||||||||||||||||||
660 | - | |||||||||||||||||||
661 | else | - | ||||||||||||||||||
662 | ctr = ctx->Yi.d[3]; never executed: ctr = ctx->Yi.d[3]; | 0 | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | n = mres % 16; | - | ||||||||||||||||||
665 | if (n
| 276-14955 | ||||||||||||||||||
666 | - | |||||||||||||||||||
667 | while (n
| 78-2262 | ||||||||||||||||||
668 | ctx->Xn[mres++] = *(out++) = *(in++) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
669 | --len; | - | ||||||||||||||||||
670 | n = (n + 1) % 16; | - | ||||||||||||||||||
671 | } executed 2184 times by 1 test: end of block Executed by:
| 2184 | ||||||||||||||||||
672 | if (n == 0
| 78-198 | ||||||||||||||||||
673 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
674 | mres = 0; | - | ||||||||||||||||||
675 | } executed 198 times by 1 test: else {end of block Executed by:
| 198 | ||||||||||||||||||
676 | ctx->mres = mres; | - | ||||||||||||||||||
677 | return executed 78 times by 1 test: 0;return 0; Executed by:
executed 78 times by 1 test: return 0; Executed by:
| 78 | ||||||||||||||||||
678 | } | - | ||||||||||||||||||
679 | } | - | ||||||||||||||||||
680 | - | |||||||||||||||||||
681 | if (len >= 16
| 198-12286 | ||||||||||||||||||
682 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
683 | mres = 0; | - | ||||||||||||||||||
684 | } executed 12088 times by 1 test: end of block Executed by:
| 12088 | ||||||||||||||||||
685 | - | |||||||||||||||||||
686 | while (len >= (3*1024)
| 1116-15153 | ||||||||||||||||||
687 | (*stream) (in, out, (3*1024) / 16, key, ctx->Yi.c); | - | ||||||||||||||||||
688 | ctr += (3*1024) / 16; | - | ||||||||||||||||||
689 | if (is_endian.little
| 0-1116 | ||||||||||||||||||
690 | - | |||||||||||||||||||
691 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 1116 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 1116 | ||||||||||||||||||
692 | - | |||||||||||||||||||
693 | - | |||||||||||||||||||
694 | - | |||||||||||||||||||
695 | else | - | ||||||||||||||||||
696 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
697 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,out,(3*1024)); | - | ||||||||||||||||||
698 | out += (3*1024); | - | ||||||||||||||||||
699 | in += (3*1024); | - | ||||||||||||||||||
700 | len -= (3*1024); | - | ||||||||||||||||||
701 | } executed 1116 times by 1 test: end of block Executed by:
| 1116 | ||||||||||||||||||
702 | - | |||||||||||||||||||
703 | - | |||||||||||||||||||
704 | if ((
| 2867-12286 | ||||||||||||||||||
705 | size_t j = i / 16; | - | ||||||||||||||||||
706 | - | |||||||||||||||||||
707 | (*stream) (in, out, j, key, ctx->Yi.c); | - | ||||||||||||||||||
708 | ctr += (unsigned int)j; | - | ||||||||||||||||||
709 | if (is_endian.little
| 0-12286 | ||||||||||||||||||
710 | - | |||||||||||||||||||
711 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 12286 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 12286 | ||||||||||||||||||
712 | - | |||||||||||||||||||
713 | - | |||||||||||||||||||
714 | - | |||||||||||||||||||
715 | else | - | ||||||||||||||||||
716 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
717 | in += i; | - | ||||||||||||||||||
718 | len -= i; | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,out,i); | - | ||||||||||||||||||
721 | out += i; | - | ||||||||||||||||||
722 | } executed 12286 times by 1 test: end of block Executed by:
| 12286 | ||||||||||||||||||
723 | if (len
| 1751-13402 | ||||||||||||||||||
724 | (*ctx->block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
725 | ++ctr; | - | ||||||||||||||||||
726 | if (is_endian.little
| 0-13402 | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 13402 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 13402 | ||||||||||||||||||
729 | - | |||||||||||||||||||
730 | - | |||||||||||||||||||
731 | - | |||||||||||||||||||
732 | else | - | ||||||||||||||||||
733 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
734 | while (len--
| 13402-53338 | ||||||||||||||||||
735 | - | |||||||||||||||||||
736 | ctx->Xn[mres++] = out[n] = in[n] ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | - | |||||||||||||||||||
739 | - | |||||||||||||||||||
740 | ++n; | - | ||||||||||||||||||
741 | } executed 53338 times by 1 test: end of block Executed by:
| 53338 | ||||||||||||||||||
742 | } executed 13402 times by 1 test: end of block Executed by:
| 13402 | ||||||||||||||||||
743 | - | |||||||||||||||||||
744 | ctx->mres = mres; | - | ||||||||||||||||||
745 | return executed 15153 times by 1 test: 0;return 0; Executed by:
executed 15153 times by 1 test: return 0; Executed by:
| 15153 | ||||||||||||||||||
746 | - | |||||||||||||||||||
747 | } | - | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, | - | ||||||||||||||||||
750 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
751 | size_t len, ctr128_f stream) | - | ||||||||||||||||||
752 | { | - | ||||||||||||||||||
753 | - | |||||||||||||||||||
754 | - | |||||||||||||||||||
755 | - | |||||||||||||||||||
756 | const union { | - | ||||||||||||||||||
757 | long one; | - | ||||||||||||||||||
758 | char little; | - | ||||||||||||||||||
759 | } is_endian = { 1 }; | - | ||||||||||||||||||
760 | unsigned int n, ctr, mres; | - | ||||||||||||||||||
761 | size_t i; | - | ||||||||||||||||||
762 | u64 mlen = ctx->len.u[1]; | - | ||||||||||||||||||
763 | void *key = ctx->key; | - | ||||||||||||||||||
764 | - | |||||||||||||||||||
765 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
766 | - | |||||||||||||||||||
767 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
768 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
769 | - | |||||||||||||||||||
770 | - | |||||||||||||||||||
771 | - | |||||||||||||||||||
772 | mlen += len; | - | ||||||||||||||||||
773 | if (mlen > ((1ULL << 36) - 32)
| 0-16481 | ||||||||||||||||||
774 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
775 | ctx->len.u[1] = mlen; | - | ||||||||||||||||||
776 | - | |||||||||||||||||||
777 | mres = ctx->mres; | - | ||||||||||||||||||
778 | - | |||||||||||||||||||
779 | if (ctx->ares
| 468-16013 | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | - | |||||||||||||||||||
782 | if (len == 0
| 5-16008 | ||||||||||||||||||
783 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
784 | ctx->ares = 0; | - | ||||||||||||||||||
785 | return executed 5 times by 1 test: 0;return 0; Executed by:
executed 5 times by 1 test: return 0; Executed by:
| 5 | ||||||||||||||||||
786 | } | - | ||||||||||||||||||
787 | memcpy(ctx->Xn, ctx->Xi.c, sizeof(ctx->Xi)); | - | ||||||||||||||||||
788 | ctx->Xi.u[0] = 0; | - | ||||||||||||||||||
789 | ctx->Xi.u[1] = 0; | - | ||||||||||||||||||
790 | mres = sizeof(ctx->Xi); | - | ||||||||||||||||||
791 | - | |||||||||||||||||||
792 | - | |||||||||||||||||||
793 | - | |||||||||||||||||||
794 | ctx->ares = 0; | - | ||||||||||||||||||
795 | } executed 16008 times by 1 test: end of block Executed by:
| 16008 | ||||||||||||||||||
796 | - | |||||||||||||||||||
797 | if (is_endian.little
| 0-16476 | ||||||||||||||||||
798 | - | |||||||||||||||||||
799 | ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 16476 times by 1 test: ctr = ({ u32 ret_=(ctx->Yi.d[3]); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 16476 | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | - | |||||||||||||||||||
802 | - | |||||||||||||||||||
803 | else | - | ||||||||||||||||||
804 | ctr = ctx->Yi.d[3]; never executed: ctr = ctx->Yi.d[3]; | 0 | ||||||||||||||||||
805 | - | |||||||||||||||||||
806 | n = mres % 16; | - | ||||||||||||||||||
807 | if (n
| 276-16200 | ||||||||||||||||||
808 | - | |||||||||||||||||||
809 | while (n
| 78-2262 | ||||||||||||||||||
810 | *(out++) = (ctx->Xn[mres++] = *(in++)) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
811 | --len; | - | ||||||||||||||||||
812 | n = (n + 1) % 16; | - | ||||||||||||||||||
813 | } executed 2184 times by 1 test: end of block Executed by:
| 2184 | ||||||||||||||||||
814 | if (n == 0
| 78-198 | ||||||||||||||||||
815 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
816 | mres = 0; | - | ||||||||||||||||||
817 | } executed 198 times by 1 test: else {end of block Executed by:
| 198 | ||||||||||||||||||
818 | ctx->mres = mres; | - | ||||||||||||||||||
819 | return executed 78 times by 1 test: 0;return 0; Executed by:
executed 78 times by 1 test: return 0; Executed by:
| 78 | ||||||||||||||||||
820 | } | - | ||||||||||||||||||
821 | } | - | ||||||||||||||||||
822 | - | |||||||||||||||||||
823 | if (len >= 16
| 198-11605 | ||||||||||||||||||
824 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
825 | mres = 0; | - | ||||||||||||||||||
826 | } executed 11407 times by 1 test: end of block Executed by:
| 11407 | ||||||||||||||||||
827 | - | |||||||||||||||||||
828 | while (len >= (3*1024)
| 1156-16398 | ||||||||||||||||||
829 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,(3*1024)); | - | ||||||||||||||||||
830 | (*stream) (in, out, (3*1024) / 16, key, ctx->Yi.c); | - | ||||||||||||||||||
831 | ctr += (3*1024) / 16; | - | ||||||||||||||||||
832 | if (is_endian.little
| 0-1156 | ||||||||||||||||||
833 | - | |||||||||||||||||||
834 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 1156 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 1156 | ||||||||||||||||||
835 | - | |||||||||||||||||||
836 | - | |||||||||||||||||||
837 | - | |||||||||||||||||||
838 | else | - | ||||||||||||||||||
839 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
840 | out += (3*1024); | - | ||||||||||||||||||
841 | in += (3*1024); | - | ||||||||||||||||||
842 | len -= (3*1024); | - | ||||||||||||||||||
843 | } executed 1156 times by 1 test: end of block Executed by:
| 1156 | ||||||||||||||||||
844 | - | |||||||||||||||||||
845 | - | |||||||||||||||||||
846 | if ((
| 4795-11603 | ||||||||||||||||||
847 | size_t j = i / 16; | - | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | - | |||||||||||||||||||
850 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,i); | - | ||||||||||||||||||
851 | (*stream) (in, out, j, key, ctx->Yi.c); | - | ||||||||||||||||||
852 | ctr += (unsigned int)j; | - | ||||||||||||||||||
853 | if (is_endian.little
| 0-11603 | ||||||||||||||||||
854 | - | |||||||||||||||||||
855 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 11603 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 11603 | ||||||||||||||||||
856 | - | |||||||||||||||||||
857 | - | |||||||||||||||||||
858 | - | |||||||||||||||||||
859 | else | - | ||||||||||||||||||
860 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
861 | out += i; | - | ||||||||||||||||||
862 | in += i; | - | ||||||||||||||||||
863 | len -= i; | - | ||||||||||||||||||
864 | } executed 11603 times by 1 test: end of block Executed by:
| 11603 | ||||||||||||||||||
865 | if (len
| 1780-14618 | ||||||||||||||||||
866 | (*ctx->block) (ctx->Yi.c, ctx->EKi.c, key); | - | ||||||||||||||||||
867 | ++ctr; | - | ||||||||||||||||||
868 | if (is_endian.little
| 0-14618 | ||||||||||||||||||
869 | - | |||||||||||||||||||
870 | ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); executed 14618 times by 1 test: ctx->Yi.d[3] = ({ u32 ret_=(ctr); asm ("bswapl %0" : "+r"(ret_)); ret_; }); Executed by:
| 14618 | ||||||||||||||||||
871 | - | |||||||||||||||||||
872 | - | |||||||||||||||||||
873 | - | |||||||||||||||||||
874 | else | - | ||||||||||||||||||
875 | ctx->Yi.d[3] = ctr; never executed: ctx->Yi.d[3] = ctr; | 0 | ||||||||||||||||||
876 | while (len--
| 14618-83937 | ||||||||||||||||||
877 | - | |||||||||||||||||||
878 | out[n] = (ctx->Xn[mres++] = in[n]) ^ ctx->EKi.c[n]; | - | ||||||||||||||||||
879 | - | |||||||||||||||||||
880 | - | |||||||||||||||||||
881 | - | |||||||||||||||||||
882 | - | |||||||||||||||||||
883 | - | |||||||||||||||||||
884 | ++n; | - | ||||||||||||||||||
885 | } executed 83937 times by 1 test: end of block Executed by:
| 83937 | ||||||||||||||||||
886 | } executed 14618 times by 1 test: end of block Executed by:
| 14618 | ||||||||||||||||||
887 | - | |||||||||||||||||||
888 | ctx->mres = mres; | - | ||||||||||||||||||
889 | return executed 16398 times by 1 test: 0;return 0; Executed by:
executed 16398 times by 1 test: return 0; Executed by:
| 16398 | ||||||||||||||||||
890 | - | |||||||||||||||||||
891 | } | - | ||||||||||||||||||
892 | - | |||||||||||||||||||
893 | int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, | - | ||||||||||||||||||
894 | size_t len) | - | ||||||||||||||||||
895 | { | - | ||||||||||||||||||
896 | const union { | - | ||||||||||||||||||
897 | long one; | - | ||||||||||||||||||
898 | char little; | - | ||||||||||||||||||
899 | } is_endian = { 1 }; | - | ||||||||||||||||||
900 | u64 alen = ctx->len.u[0] << 3; | - | ||||||||||||||||||
901 | u64 clen = ctx->len.u[1] << 3; | - | ||||||||||||||||||
902 | - | |||||||||||||||||||
903 | void (*gcm_gmult_p) (u64 Xi[2], const u128 Htable[16]) = ctx->gmult; | - | ||||||||||||||||||
904 | - | |||||||||||||||||||
905 | void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], | - | ||||||||||||||||||
906 | const u8 *inp, size_t len) = ctx->ghash; | - | ||||||||||||||||||
907 | - | |||||||||||||||||||
908 | - | |||||||||||||||||||
909 | - | |||||||||||||||||||
910 | - | |||||||||||||||||||
911 | u128 bitlen; | - | ||||||||||||||||||
912 | unsigned int mres = ctx->mres; | - | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | if (mres
| 3791-27822 | ||||||||||||||||||
915 | unsigned blocks = (mres + 15) & -16; | - | ||||||||||||||||||
916 | - | |||||||||||||||||||
917 | memset(ctx->Xn + mres, 0, blocks - mres); | - | ||||||||||||||||||
918 | mres = blocks; | - | ||||||||||||||||||
919 | if (mres == sizeof(ctx->Xn)
| 0-27822 | ||||||||||||||||||
920 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
921 | mres = 0; | - | ||||||||||||||||||
922 | } never executed: end of block | 0 | ||||||||||||||||||
923 | } executed 27822 times by 2 tests: else if (ctx->aresend of block Executed by:
| 0-27822 | ||||||||||||||||||
924 | (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable); | - | ||||||||||||||||||
925 | } never executed: end of block | 0 | ||||||||||||||||||
926 | - | |||||||||||||||||||
927 | - | |||||||||||||||||||
928 | - | |||||||||||||||||||
929 | - | |||||||||||||||||||
930 | - | |||||||||||||||||||
931 | if (is_endian.little
| 0-31613 | ||||||||||||||||||
932 | - | |||||||||||||||||||
933 | alen = ({ u64 ret_=(alen); asm ("bswapq %0" : "+r"(ret_)); ret_; }); | - | ||||||||||||||||||
934 | clen = ({ u64 ret_=(clen); asm ("bswapq %0" : "+r"(ret_)); ret_; }); | - | ||||||||||||||||||
935 | } executed 31613 times by 2 tests: end of block Executed by:
| 31613 | ||||||||||||||||||
936 | - | |||||||||||||||||||
937 | - | |||||||||||||||||||
938 | bitlen.hi = alen; | - | ||||||||||||||||||
939 | bitlen.lo = clen; | - | ||||||||||||||||||
940 | memcpy(ctx->Xn + mres, &bitlen, sizeof(bitlen)); | - | ||||||||||||||||||
941 | mres += sizeof(bitlen); | - | ||||||||||||||||||
942 | (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,ctx->Xn,mres); | - | ||||||||||||||||||
943 | - | |||||||||||||||||||
944 | - | |||||||||||||||||||
945 | - | |||||||||||||||||||
946 | - | |||||||||||||||||||
947 | - | |||||||||||||||||||
948 | - | |||||||||||||||||||
949 | ctx->Xi.u[0] ^= ctx->EK0.u[0]; | - | ||||||||||||||||||
950 | ctx->Xi.u[1] ^= ctx->EK0.u[1]; | - | ||||||||||||||||||
951 | - | |||||||||||||||||||
952 | if (tag
| 0-17897 | ||||||||||||||||||
953 | return executed 13716 times by 2 tests: CRYPTO_memcmp(ctx->Xi.c, tag, len);return CRYPTO_memcmp(ctx->Xi.c, tag, len); Executed by:
executed 13716 times by 2 tests: return CRYPTO_memcmp(ctx->Xi.c, tag, len); Executed by:
| 13716 | ||||||||||||||||||
954 | else | - | ||||||||||||||||||
955 | return executed 17897 times by 1 test: -1;return -1; Executed by:
executed 17897 times by 1 test: return -1; Executed by:
| 17897 | ||||||||||||||||||
956 | } | - | ||||||||||||||||||
957 | - | |||||||||||||||||||
958 | void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len) | - | ||||||||||||||||||
959 | { | - | ||||||||||||||||||
960 | CRYPTO_gcm128_finish(ctx, | - | ||||||||||||||||||
961 | ((void *)0) | - | ||||||||||||||||||
962 | , 0); | - | ||||||||||||||||||
963 | memcpy(tag, ctx->Xi.c, | - | ||||||||||||||||||
964 | len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c)); | - | ||||||||||||||||||
965 | } executed 17897 times by 1 test: end of block Executed by:
| 17897 | ||||||||||||||||||
966 | - | |||||||||||||||||||
967 | GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block) | - | ||||||||||||||||||
968 | { | - | ||||||||||||||||||
969 | GCM128_CONTEXT *ret; | - | ||||||||||||||||||
970 | - | |||||||||||||||||||
971 | if ((
| 0 | ||||||||||||||||||
972 | ((void *)0)
| 0 | ||||||||||||||||||
973 | ) | - | ||||||||||||||||||
974 | CRYPTO_gcm128_init(ret, key, block); never executed: CRYPTO_gcm128_init(ret, key, block); | 0 | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
977 | } | - | ||||||||||||||||||
978 | - | |||||||||||||||||||
979 | void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx) | - | ||||||||||||||||||
980 | { | - | ||||||||||||||||||
981 | CRYPTO_clear_free(ctx, sizeof(*ctx), __FILE__, 1887); | - | ||||||||||||||||||
982 | } never executed: end of block | 0 | ||||||||||||||||||
Switch to Source code | Preprocessed file |