Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/sha/sha512.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | int sha512_224_init(SHA512_CTX *c) | - | ||||||
5 | { | - | ||||||
6 | c->h[0] = 0x8c3d37c819544da2ULL; | - | ||||||
7 | c->h[1] = 0x73e1996689dcd4d6ULL; | - | ||||||
8 | c->h[2] = 0x1dfab7ae32ff9c82ULL; | - | ||||||
9 | c->h[3] = 0x679dd514582f9fcfULL; | - | ||||||
10 | c->h[4] = 0x0f6d2b697bd44da8ULL; | - | ||||||
11 | c->h[5] = 0x77e36f7304c48942ULL; | - | ||||||
12 | c->h[6] = 0x3f9d85a86a1d36c8ULL; | - | ||||||
13 | c->h[7] = 0x1112e6ad91d692a1ULL; | - | ||||||
14 | - | |||||||
15 | c->Nl = 0; | - | ||||||
16 | c->Nh = 0; | - | ||||||
17 | c->num = 0; | - | ||||||
18 | c->md_len = 28; | - | ||||||
19 | return executed 7 times by 1 test: 1;return 1; Executed by:
executed 7 times by 1 test: return 1; Executed by:
| 7 | ||||||
20 | } | - | ||||||
21 | - | |||||||
22 | int sha512_256_init(SHA512_CTX *c) | - | ||||||
23 | { | - | ||||||
24 | c->h[0] = 0x22312194fc2bf72cULL; | - | ||||||
25 | c->h[1] = 0x9f555fa3c84c64c2ULL; | - | ||||||
26 | c->h[2] = 0x2393b86b6f53b151ULL; | - | ||||||
27 | c->h[3] = 0x963877195940eabdULL; | - | ||||||
28 | c->h[4] = 0x96283ee2a88effe3ULL; | - | ||||||
29 | c->h[5] = 0xbe5e1e2553863992ULL; | - | ||||||
30 | c->h[6] = 0x2b0199fc2c85b8aaULL; | - | ||||||
31 | c->h[7] = 0x0eb72ddc81c52ca2ULL; | - | ||||||
32 | - | |||||||
33 | c->Nl = 0; | - | ||||||
34 | c->Nh = 0; | - | ||||||
35 | c->num = 0; | - | ||||||
36 | c->md_len = 32; | - | ||||||
37 | return executed 7 times by 1 test: 1;return 1; Executed by:
executed 7 times by 1 test: return 1; Executed by:
| 7 | ||||||
38 | } | - | ||||||
39 | - | |||||||
40 | int SHA384_Init(SHA512_CTX *c) | - | ||||||
41 | { | - | ||||||
42 | c->h[0] = 0xcbbb9d5dc1059ed8ULL; | - | ||||||
43 | c->h[1] = 0x629a292a367cd507ULL; | - | ||||||
44 | c->h[2] = 0x9159015a3070dd17ULL; | - | ||||||
45 | c->h[3] = 0x152fecd8f70e5939ULL; | - | ||||||
46 | c->h[4] = 0x67332667ffc00b31ULL; | - | ||||||
47 | c->h[5] = 0x8eb44a8768581511ULL; | - | ||||||
48 | c->h[6] = 0xdb0c2e0d64f98fa7ULL; | - | ||||||
49 | c->h[7] = 0x47b5481dbefa4fa4ULL; | - | ||||||
50 | - | |||||||
51 | c->Nl = 0; | - | ||||||
52 | c->Nh = 0; | - | ||||||
53 | c->num = 0; | - | ||||||
54 | c->md_len = 48; | - | ||||||
55 | return executed 66347 times by 1 test: 1;return 1; Executed by:
executed 66347 times by 1 test: return 1; Executed by:
| 66347 | ||||||
56 | } | - | ||||||
57 | - | |||||||
58 | int SHA512_Init(SHA512_CTX *c) | - | ||||||
59 | { | - | ||||||
60 | c->h[0] = 0x6a09e667f3bcc908ULL; | - | ||||||
61 | c->h[1] = 0xbb67ae8584caa73bULL; | - | ||||||
62 | c->h[2] = 0x3c6ef372fe94f82bULL; | - | ||||||
63 | c->h[3] = 0xa54ff53a5f1d36f1ULL; | - | ||||||
64 | c->h[4] = 0x510e527fade682d1ULL; | - | ||||||
65 | c->h[5] = 0x9b05688c2b3e6c1fULL; | - | ||||||
66 | c->h[6] = 0x1f83d9abfb41bd6bULL; | - | ||||||
67 | c->h[7] = 0x5be0cd19137e2179ULL; | - | ||||||
68 | - | |||||||
69 | c->Nl = 0; | - | ||||||
70 | c->Nh = 0; | - | ||||||
71 | c->num = 0; | - | ||||||
72 | c->md_len = 64; | - | ||||||
73 | return executed 234323 times by 1 test: 1;return 1; Executed by:
executed 234323 times by 1 test: return 1; Executed by:
| 234323 | ||||||
74 | } | - | ||||||
75 | - | |||||||
76 | - | |||||||
77 | - | |||||||
78 | - | |||||||
79 | void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); | - | ||||||
80 | - | |||||||
81 | int SHA512_Final(unsigned char *md, SHA512_CTX *c) | - | ||||||
82 | { | - | ||||||
83 | unsigned char *p = (unsigned char *)c->u.p; | - | ||||||
84 | size_t n = c->num; | - | ||||||
85 | - | |||||||
86 | p[n] = 0x80; | - | ||||||
87 | n++; | - | ||||||
88 | if (n > (sizeof(c->u) - 16)
| 18677-327039 | ||||||
89 | memset(p + n, 0, sizeof(c->u) - n); | - | ||||||
90 | n = 0; | - | ||||||
91 | sha512_block_data_order(c, p, 1); | - | ||||||
92 | } executed 18677 times by 1 test: end of block Executed by:
| 18677 | ||||||
93 | - | |||||||
94 | memset(p + n, 0, sizeof(c->u) - 16 - n); | - | ||||||
95 | - | |||||||
96 | - | |||||||
97 | - | |||||||
98 | - | |||||||
99 | p[sizeof(c->u) - 1] = (unsigned char)(c->Nl); | - | ||||||
100 | p[sizeof(c->u) - 2] = (unsigned char)(c->Nl >> 8); | - | ||||||
101 | p[sizeof(c->u) - 3] = (unsigned char)(c->Nl >> 16); | - | ||||||
102 | p[sizeof(c->u) - 4] = (unsigned char)(c->Nl >> 24); | - | ||||||
103 | p[sizeof(c->u) - 5] = (unsigned char)(c->Nl >> 32); | - | ||||||
104 | p[sizeof(c->u) - 6] = (unsigned char)(c->Nl >> 40); | - | ||||||
105 | p[sizeof(c->u) - 7] = (unsigned char)(c->Nl >> 48); | - | ||||||
106 | p[sizeof(c->u) - 8] = (unsigned char)(c->Nl >> 56); | - | ||||||
107 | p[sizeof(c->u) - 9] = (unsigned char)(c->Nh); | - | ||||||
108 | p[sizeof(c->u) - 10] = (unsigned char)(c->Nh >> 8); | - | ||||||
109 | p[sizeof(c->u) - 11] = (unsigned char)(c->Nh >> 16); | - | ||||||
110 | p[sizeof(c->u) - 12] = (unsigned char)(c->Nh >> 24); | - | ||||||
111 | p[sizeof(c->u) - 13] = (unsigned char)(c->Nh >> 32); | - | ||||||
112 | p[sizeof(c->u) - 14] = (unsigned char)(c->Nh >> 40); | - | ||||||
113 | p[sizeof(c->u) - 15] = (unsigned char)(c->Nh >> 48); | - | ||||||
114 | p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56); | - | ||||||
115 | - | |||||||
116 | - | |||||||
117 | sha512_block_data_order(c, p, 1); | - | ||||||
118 | - | |||||||
119 | if (md == 0
| 0-345716 | ||||||
120 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
121 | - | |||||||
122 | switch (c->md_len) { | - | ||||||
123 | - | |||||||
124 | case executed 7 times by 1 test: 28:case 28: Executed by:
executed 7 times by 1 test: case 28: Executed by:
| 7 | ||||||
125 | for (n = 0; n < 28 / 8
| 7-21 | ||||||
126 | unsigned long long t = c->h[n]; | - | ||||||
127 | - | |||||||
128 | *(md++) = (unsigned char)(t >> 56); | - | ||||||
129 | *(md++) = (unsigned char)(t >> 48); | - | ||||||
130 | *(md++) = (unsigned char)(t >> 40); | - | ||||||
131 | *(md++) = (unsigned char)(t >> 32); | - | ||||||
132 | *(md++) = (unsigned char)(t >> 24); | - | ||||||
133 | *(md++) = (unsigned char)(t >> 16); | - | ||||||
134 | *(md++) = (unsigned char)(t >> 8); | - | ||||||
135 | *(md++) = (unsigned char)(t); | - | ||||||
136 | } executed 21 times by 1 test: end of block Executed by:
| 21 | ||||||
137 | - | |||||||
138 | - | |||||||
139 | - | |||||||
140 | - | |||||||
141 | { | - | ||||||
142 | unsigned long long t = c->h[28 / 8]; | - | ||||||
143 | - | |||||||
144 | *(md++) = (unsigned char)(t >> 56); | - | ||||||
145 | *(md++) = (unsigned char)(t >> 48); | - | ||||||
146 | *(md++) = (unsigned char)(t >> 40); | - | ||||||
147 | *(md++) = (unsigned char)(t >> 32); | - | ||||||
148 | } | - | ||||||
149 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||
150 | case executed 7 times by 1 test: 32:case 32: Executed by:
executed 7 times by 1 test: case 32: Executed by:
| 7 | ||||||
151 | for (n = 0; n < 32 / 8
| 7-28 | ||||||
152 | unsigned long long t = c->h[n]; | - | ||||||
153 | - | |||||||
154 | *(md++) = (unsigned char)(t >> 56); | - | ||||||
155 | *(md++) = (unsigned char)(t >> 48); | - | ||||||
156 | *(md++) = (unsigned char)(t >> 40); | - | ||||||
157 | *(md++) = (unsigned char)(t >> 32); | - | ||||||
158 | *(md++) = (unsigned char)(t >> 24); | - | ||||||
159 | *(md++) = (unsigned char)(t >> 16); | - | ||||||
160 | *(md++) = (unsigned char)(t >> 8); | - | ||||||
161 | *(md++) = (unsigned char)(t); | - | ||||||
162 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||
163 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||
164 | case executed 86810 times by 1 test: 48:case 48: Executed by:
executed 86810 times by 1 test: case 48: Executed by:
| 86810 | ||||||
165 | for (n = 0; n < 48 / 8
| 86810-520860 | ||||||
166 | unsigned long long t = c->h[n]; | - | ||||||
167 | - | |||||||
168 | *(md++) = (unsigned char)(t >> 56); | - | ||||||
169 | *(md++) = (unsigned char)(t >> 48); | - | ||||||
170 | *(md++) = (unsigned char)(t >> 40); | - | ||||||
171 | *(md++) = (unsigned char)(t >> 32); | - | ||||||
172 | *(md++) = (unsigned char)(t >> 24); | - | ||||||
173 | *(md++) = (unsigned char)(t >> 16); | - | ||||||
174 | *(md++) = (unsigned char)(t >> 8); | - | ||||||
175 | *(md++) = (unsigned char)(t); | - | ||||||
176 | } executed 520860 times by 1 test: end of block Executed by:
| 520860 | ||||||
177 | break; executed 86810 times by 1 test: break; Executed by:
| 86810 | ||||||
178 | case executed 258892 times by 1 test: 64:case 64: Executed by:
executed 258892 times by 1 test: case 64: Executed by:
| 258892 | ||||||
179 | for (n = 0; n < 64 / 8
| 258892-2071136 | ||||||
180 | unsigned long long t = c->h[n]; | - | ||||||
181 | - | |||||||
182 | *(md++) = (unsigned char)(t >> 56); | - | ||||||
183 | *(md++) = (unsigned char)(t >> 48); | - | ||||||
184 | *(md++) = (unsigned char)(t >> 40); | - | ||||||
185 | *(md++) = (unsigned char)(t >> 32); | - | ||||||
186 | *(md++) = (unsigned char)(t >> 24); | - | ||||||
187 | *(md++) = (unsigned char)(t >> 16); | - | ||||||
188 | *(md++) = (unsigned char)(t >> 8); | - | ||||||
189 | *(md++) = (unsigned char)(t); | - | ||||||
190 | } executed 2071136 times by 1 test: end of block Executed by:
| 2071136 | ||||||
191 | break; executed 258892 times by 1 test: break; Executed by:
| 258892 | ||||||
192 | - | |||||||
193 | default never executed: :default: never executed: default: | 0 | ||||||
194 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
195 | } | - | ||||||
196 | - | |||||||
197 | return executed 345716 times by 1 test: 1;return 1; Executed by:
executed 345716 times by 1 test: return 1; Executed by:
| 345716 | ||||||
198 | } | - | ||||||
199 | - | |||||||
200 | int SHA384_Final(unsigned char *md, SHA512_CTX *c) | - | ||||||
201 | { | - | ||||||
202 | return executed 86807 times by 1 test: SHA512_Final(md, c);return SHA512_Final(md, c); Executed by:
executed 86807 times by 1 test: return SHA512_Final(md, c); Executed by:
| 86807 | ||||||
203 | } | - | ||||||
204 | - | |||||||
205 | int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len) | - | ||||||
206 | { | - | ||||||
207 | unsigned long long l; | - | ||||||
208 | unsigned char *p = c->u.p; | - | ||||||
209 | const unsigned char *data = (const unsigned char *)_data; | - | ||||||
210 | - | |||||||
211 | if (len == 0
| 21-1045529 | ||||||
212 | return executed 21 times by 1 test: 1;return 1; Executed by:
executed 21 times by 1 test: return 1; Executed by:
| 21 | ||||||
213 | - | |||||||
214 | l = (c->Nl + (((unsigned long long) len) << 3)) & 0xffffffffffffffffULL; | - | ||||||
215 | if (l < c->Nl
| 0-1045529 | ||||||
216 | c->Nh++; never executed: c->Nh++; | 0 | ||||||
217 | if (sizeof(len) >= 8
| 0-1045529 | ||||||
218 | c->Nh += (((unsigned long long) len) >> 61); executed 1045529 times by 1 test: c->Nh += (((unsigned long long) len) >> 61); Executed by:
| 1045529 | ||||||
219 | c->Nl = l; | - | ||||||
220 | - | |||||||
221 | if (c->num != 0
| 404534-640995 | ||||||
222 | size_t n = sizeof(c->u) - c->num; | - | ||||||
223 | - | |||||||
224 | if (len < n
| 86468-554527 | ||||||
225 | memcpy(p + c->num, data, len), c->num += (unsigned int)len; | - | ||||||
226 | return executed 554527 times by 1 test: 1;return 1; Executed by:
executed 554527 times by 1 test: return 1; Executed by:
| 554527 | ||||||
227 | } else { | - | ||||||
228 | memcpy(p + c->num, data, n), c->num = 0; | - | ||||||
229 | len -= n, data += n; | - | ||||||
230 | sha512_block_data_order(c, p, 1); | - | ||||||
231 | } executed 86468 times by 1 test: end of block Executed by:
| 86468 | ||||||
232 | } | - | ||||||
233 | - | |||||||
234 | if (len >= sizeof(c->u)
| 70853-420149 | ||||||
235 | sha512_block_data_order(c, data, len / sizeof(c->u)), | - | ||||||
236 | data += len, len %= sizeof(c->u), data -= len; | - | ||||||
237 | } executed 70853 times by 1 test: end of block Executed by:
| 70853 | ||||||
238 | - | |||||||
239 | if (len != 0
| 70102-420900 | ||||||
240 | memcpy(p, data, len), c->num = (int)len; executed 420900 times by 1 test: memcpy(p, data, len), c->num = (int)len; Executed by:
| 420900 | ||||||
241 | - | |||||||
242 | return executed 491002 times by 1 test: 1;return 1; Executed by:
executed 491002 times by 1 test: return 1; Executed by:
| 491002 | ||||||
243 | } | - | ||||||
244 | - | |||||||
245 | int SHA384_Update(SHA512_CTX *c, const void *data, size_t len) | - | ||||||
246 | { | - | ||||||
247 | return executed 190411 times by 1 test: SHA512_Update(c, data, len);return SHA512_Update(c, data, len); Executed by:
executed 190411 times by 1 test: return SHA512_Update(c, data, len); Executed by:
| 190411 | ||||||
248 | } | - | ||||||
249 | - | |||||||
250 | void SHA512_Transform(SHA512_CTX *c, const unsigned char *data) | - | ||||||
251 | { | - | ||||||
252 | - | |||||||
253 | - | |||||||
254 | - | |||||||
255 | - | |||||||
256 | sha512_block_data_order(c, data, 1); | - | ||||||
257 | } executed 394 times by 1 test: end of block Executed by:
| 394 | ||||||
258 | - | |||||||
259 | unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md) | - | ||||||
260 | { | - | ||||||
261 | SHA512_CTX c; | - | ||||||
262 | static unsigned char m[48]; | - | ||||||
263 | - | |||||||
264 | if (md ==
| 0 | ||||||
265 | ((void *)0)
| 0 | ||||||
266 | ) | - | ||||||
267 | md = m; never executed: md = m; | 0 | ||||||
268 | SHA384_Init(&c); | - | ||||||
269 | SHA512_Update(&c, d, n); | - | ||||||
270 | SHA512_Final(md, &c); | - | ||||||
271 | OPENSSL_cleanse(&c, sizeof(c)); | - | ||||||
272 | return never executed: md;return md; never executed: return md; | 0 | ||||||
273 | } | - | ||||||
274 | - | |||||||
275 | unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md) | - | ||||||
276 | { | - | ||||||
277 | SHA512_CTX c; | - | ||||||
278 | static unsigned char m[64]; | - | ||||||
279 | - | |||||||
280 | if (md ==
| 0-35 | ||||||
281 | ((void *)0)
| 0-35 | ||||||
282 | ) | - | ||||||
283 | md = m; never executed: md = m; | 0 | ||||||
284 | SHA512_Init(&c); | - | ||||||
285 | SHA512_Update(&c, d, n); | - | ||||||
286 | SHA512_Final(md, &c); | - | ||||||
287 | OPENSSL_cleanse(&c, sizeof(c)); | - | ||||||
288 | return executed 35 times by 1 test: md;return md; Executed by:
executed 35 times by 1 test: return md; Executed by:
| 35 | ||||||
289 | } | - | ||||||
Switch to Source code | Preprocessed file |