Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/whrlpool/wp_dgst.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | int WHIRLPOOL_Init(WHIRLPOOL_CTX *c) | - | ||||||||||||||||||
4 | { | - | ||||||||||||||||||
5 | memset(c, 0, sizeof(*c)); | - | ||||||||||||||||||
6 | return executed 9 times by 1 test: 1;return 1; Executed by:
executed 9 times by 1 test: return 1; Executed by:
| 9 | ||||||||||||||||||
7 | } | - | ||||||||||||||||||
8 | - | |||||||||||||||||||
9 | int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *_inp, size_t bytes) | - | ||||||||||||||||||
10 | { | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | - | |||||||||||||||||||
16 | size_t chunk = ((size_t)1) << (sizeof(size_t) * 8 - 4); | - | ||||||||||||||||||
17 | const unsigned char *inp = _inp; | - | ||||||||||||||||||
18 | - | |||||||||||||||||||
19 | while (bytes >= chunk
| 0-100008 | ||||||||||||||||||
20 | WHIRLPOOL_BitUpdate(c, inp, chunk * 8); | - | ||||||||||||||||||
21 | bytes -= chunk; | - | ||||||||||||||||||
22 | inp += chunk; | - | ||||||||||||||||||
23 | } never executed: end of block | 0 | ||||||||||||||||||
24 | if (bytes
| 1-100007 | ||||||||||||||||||
25 | WHIRLPOOL_BitUpdate(c, inp, bytes * 8); executed 100007 times by 1 test: WHIRLPOOL_BitUpdate(c, inp, bytes * 8); Executed by:
| 100007 | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | return executed 100008 times by 1 test: 1;return 1; Executed by:
executed 100008 times by 1 test: return 1; Executed by:
| 100008 | ||||||||||||||||||
28 | } | - | ||||||||||||||||||
29 | - | |||||||||||||||||||
30 | void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *_inp, size_t bits) | - | ||||||||||||||||||
31 | { | - | ||||||||||||||||||
32 | size_t n; | - | ||||||||||||||||||
33 | unsigned int bitoff = c->bitoff, | - | ||||||||||||||||||
34 | bitrem = bitoff % 8, inpgap = (8 - (unsigned int)bits % 8) & 7; | - | ||||||||||||||||||
35 | const unsigned char *inp = _inp; | - | ||||||||||||||||||
36 | - | |||||||||||||||||||
37 | - | |||||||||||||||||||
38 | - | |||||||||||||||||||
39 | - | |||||||||||||||||||
40 | - | |||||||||||||||||||
41 | - | |||||||||||||||||||
42 | c->bitlen[0] += bits; | - | ||||||||||||||||||
43 | if (c->bitlen[0] < bits
| 0-100007 | ||||||||||||||||||
44 | n = 1; | - | ||||||||||||||||||
45 | do { | - | ||||||||||||||||||
46 | c->bitlen[n]++; | - | ||||||||||||||||||
47 | } never executed: while (c->bitlen[n] == 0end of block
| 0 | ||||||||||||||||||
48 | && ++
| 0 | ||||||||||||||||||
49 | } never executed: end of block | 0 | ||||||||||||||||||
50 | - | |||||||||||||||||||
51 | reconsider: code before this statement executed 100007 times by 1 test: reconsider: Executed by:
| 100007 | ||||||||||||||||||
52 | if (inpgap == 0
| 0-100007 | ||||||||||||||||||
53 | while (bits
| 100007-112508 | ||||||||||||||||||
54 | if (bitoff == 0
| 1-96875 | ||||||||||||||||||
55 | whirlpool_block(c, inp, n); | - | ||||||||||||||||||
56 | inp += n * 512 / 8; | - | ||||||||||||||||||
57 | bits %= 512; | - | ||||||||||||||||||
58 | } executed 1 time by 1 test: else {end of block Executed by:
| 1 | ||||||||||||||||||
59 | unsigned int byteoff = bitoff / 8; | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | bitrem = 512 - bitoff; | - | ||||||||||||||||||
62 | if (bits >= bitrem
| 15625-96882 | ||||||||||||||||||
63 | bits -= bitrem; | - | ||||||||||||||||||
64 | bitrem /= 8; | - | ||||||||||||||||||
65 | memcpy(c->data + byteoff, inp, bitrem); | - | ||||||||||||||||||
66 | inp += bitrem; | - | ||||||||||||||||||
67 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
68 | bitoff = 0; | - | ||||||||||||||||||
69 | } executed 15625 times by 1 test: else {end of block Executed by:
| 15625 | ||||||||||||||||||
70 | memcpy(c->data + byteoff, inp, bits / 8); | - | ||||||||||||||||||
71 | bitoff += (unsigned int)bits; | - | ||||||||||||||||||
72 | bits = 0; | - | ||||||||||||||||||
73 | } executed 96882 times by 1 test: end of block Executed by:
| 96882 | ||||||||||||||||||
74 | c->bitoff = bitoff; | - | ||||||||||||||||||
75 | } executed 112507 times by 1 test: end of block Executed by:
| 112507 | ||||||||||||||||||
76 | } | - | ||||||||||||||||||
77 | } executed 100007 times by 1 test: elseend of block Executed by:
| 100007 | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | { | - | ||||||||||||||||||
80 | while (bits
| 0 | ||||||||||||||||||
81 | unsigned int byteoff = bitoff / 8; | - | ||||||||||||||||||
82 | unsigned char b; | - | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | - | |||||||||||||||||||
85 | if (bitrem == inpgap
| 0 | ||||||||||||||||||
86 | c->data[byteoff++] |= inp[0] & (0xff >> inpgap); | - | ||||||||||||||||||
87 | inpgap = 8 - inpgap; | - | ||||||||||||||||||
88 | bitoff += inpgap; | - | ||||||||||||||||||
89 | bitrem = 0; | - | ||||||||||||||||||
90 | bits -= inpgap; | - | ||||||||||||||||||
91 | inpgap = 0; | - | ||||||||||||||||||
92 | inp++; | - | ||||||||||||||||||
93 | if (bitoff == 512
| 0 | ||||||||||||||||||
94 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
95 | bitoff = 0; | - | ||||||||||||||||||
96 | } never executed: end of block | 0 | ||||||||||||||||||
97 | c->bitoff = bitoff; | - | ||||||||||||||||||
98 | goto never executed: reconsider;goto reconsider; never executed: goto reconsider; | 0 | ||||||||||||||||||
99 | } else | - | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | if (bits > 8
| 0 | ||||||||||||||||||
102 | b = ((inp[0] << inpgap) | (inp[1] >> (8 - inpgap))); | - | ||||||||||||||||||
103 | b &= 0xff; | - | ||||||||||||||||||
104 | if (bitrem
| 0 | ||||||||||||||||||
105 | c->data[byteoff++] |= b >> bitrem; never executed: c->data[byteoff++] |= b >> bitrem; | 0 | ||||||||||||||||||
106 | else | - | ||||||||||||||||||
107 | c->data[byteoff++] = b; never executed: c->data[byteoff++] = b; | 0 | ||||||||||||||||||
108 | bitoff += 8; | - | ||||||||||||||||||
109 | bits -= 8; | - | ||||||||||||||||||
110 | inp++; | - | ||||||||||||||||||
111 | if (bitoff >= 512
| 0 | ||||||||||||||||||
112 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
113 | byteoff = 0; | - | ||||||||||||||||||
114 | bitoff %= 512; | - | ||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||
116 | if (bitrem
| 0 | ||||||||||||||||||
117 | c->data[byteoff] = b << (8 - bitrem); never executed: c->data[byteoff] = b << (8 - bitrem); | 0 | ||||||||||||||||||
118 | } never executed: else {end of block | 0 | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | b = (inp[0] << inpgap) & 0xff; | - | ||||||||||||||||||
121 | if (bitrem
| 0 | ||||||||||||||||||
122 | c->data[byteoff++] |= b >> bitrem; never executed: c->data[byteoff++] |= b >> bitrem; | 0 | ||||||||||||||||||
123 | else | - | ||||||||||||||||||
124 | c->data[byteoff++] = b; never executed: c->data[byteoff++] = b; | 0 | ||||||||||||||||||
125 | bitoff += (unsigned int)bits; | - | ||||||||||||||||||
126 | if (bitoff == 512
| 0 | ||||||||||||||||||
127 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
128 | byteoff = 0; | - | ||||||||||||||||||
129 | bitoff %= 512; | - | ||||||||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||||||||
131 | if (bitrem
| 0 | ||||||||||||||||||
132 | c->data[byteoff] = b << (8 - bitrem); never executed: c->data[byteoff] = b << (8 - bitrem); | 0 | ||||||||||||||||||
133 | bits = 0; | - | ||||||||||||||||||
134 | } never executed: end of block | 0 | ||||||||||||||||||
135 | c->bitoff = bitoff; | - | ||||||||||||||||||
136 | } never executed: end of block | 0 | ||||||||||||||||||
137 | } never executed: end of block | 0 | ||||||||||||||||||
138 | } | - | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c) | - | ||||||||||||||||||
141 | { | - | ||||||||||||||||||
142 | unsigned int bitoff = c->bitoff, byteoff = bitoff / 8; | - | ||||||||||||||||||
143 | size_t i, j, v; | - | ||||||||||||||||||
144 | unsigned char *p; | - | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | bitoff %= 8; | - | ||||||||||||||||||
147 | if (bitoff
| 0-9 | ||||||||||||||||||
148 | c->data[byteoff] |= 0x80 >> bitoff; never executed: c->data[byteoff] |= 0x80 >> bitoff; | 0 | ||||||||||||||||||
149 | else | - | ||||||||||||||||||
150 | c->data[byteoff] = 0x80; executed 9 times by 1 test: c->data[byteoff] = 0x80; Executed by:
| 9 | ||||||||||||||||||
151 | byteoff++; | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | - | |||||||||||||||||||
154 | if (byteoff > (512 / 8 - (256/8))
| 2-7 | ||||||||||||||||||
155 | if (byteoff < 512 / 8
| 0-2 | ||||||||||||||||||
156 | memset(&c->data[byteoff], 0, 512 / 8 - byteoff); executed 2 times by 1 test: memset(&c->data[byteoff], 0, 512 / 8 - byteoff); Executed by:
| 2 | ||||||||||||||||||
157 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
158 | byteoff = 0; | - | ||||||||||||||||||
159 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
160 | if (byteoff < (512 / 8 - (256/8))
| 0-9 | ||||||||||||||||||
161 | memset(&c->data[byteoff], 0, executed 9 times by 1 test: memset(&c->data[byteoff], 0, (512 / 8 - (256/8)) - byteoff); Executed by:
| 9 | ||||||||||||||||||
162 | (512 / 8 - (256/8)) - byteoff); executed 9 times by 1 test: memset(&c->data[byteoff], 0, (512 / 8 - (256/8)) - byteoff); Executed by:
| 9 | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | p = &c->data[512 / 8 - 1]; | - | ||||||||||||||||||
165 | for (i = 0; i < (256/8) / sizeof(size_t)
| 9-36 | ||||||||||||||||||
166 | for (v = c->bitlen[i], j = 0; j < sizeof(size_t)
| 36-288 | ||||||||||||||||||
167 | * executed 288 times by 1 test: p-- = (unsigned char)(v & 0xff);*p-- = (unsigned char)(v & 0xff); Executed by:
executed 288 times by 1 test: *p-- = (unsigned char)(v & 0xff); Executed by:
| 288 | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | whirlpool_block(c, c->data, 1); | - | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | if (md
| 0-9 | ||||||||||||||||||
172 | memcpy(md, c->H.c, (512/8)); | - | ||||||||||||||||||
173 | OPENSSL_cleanse(c, sizeof(*c)); | - | ||||||||||||||||||
174 | return executed 9 times by 1 test: 1;return 1; Executed by:
executed 9 times by 1 test: return 1; Executed by:
| 9 | ||||||||||||||||||
175 | } | - | ||||||||||||||||||
176 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
177 | } | - | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md) | - | ||||||||||||||||||
180 | { | - | ||||||||||||||||||
181 | WHIRLPOOL_CTX ctx; | - | ||||||||||||||||||
182 | static unsigned char m[(512/8)]; | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | if (md ==
| 0 | ||||||||||||||||||
185 | ((void *)0)
| 0 | ||||||||||||||||||
186 | ) | - | ||||||||||||||||||
187 | md = m; never executed: md = m; | 0 | ||||||||||||||||||
188 | WHIRLPOOL_Init(&ctx); | - | ||||||||||||||||||
189 | WHIRLPOOL_Update(&ctx, inp, bytes); | - | ||||||||||||||||||
190 | WHIRLPOOL_Final(md, &ctx); | - | ||||||||||||||||||
191 | return never executed: md;return md; never executed: return md; | 0 | ||||||||||||||||||
192 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |