OpenCoverage

wp_dgst.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/whrlpool/wp_dgst.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3int WHIRLPOOL_Init(WHIRLPOOL_CTX *c)-
4{-
5 memset(c, 0, sizeof(*c));-
6 return
executed 9 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 9 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
9
7}-
8-
9int 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
bytes >= chunkDescription
TRUEnever evaluated
FALSEevaluated 100008 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
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
bytesDescription
TRUEevaluated 100007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-100007
25 WHIRLPOOL_BitUpdate(c, inp, bytes * 8);
executed 100007 times by 1 test: WHIRLPOOL_BitUpdate(c, inp, bytes * 8);
Executed by:
  • libcrypto.so.1.1
100007
26-
27 return
executed 100008 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 100008 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
100008
28}-
29-
30void 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
c->bitlen[0] < bitsDescription
TRUEnever evaluated
FALSEevaluated 100007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-100007
44 n = 1;-
45 do {-
46 c->bitlen[n]++;-
47 }
never executed: end of block
while (c->bitlen[n] == 0
c->bitlen[n] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
48 && ++
++n < ((256/8)...izeof(size_t))Description
TRUEnever evaluated
FALSEnever evaluated
n < ((256/8) / sizeof(size_t))
++n < ((256/8)...izeof(size_t))Description
TRUEnever evaluated
FALSEnever evaluated
);
0
49 }
never executed: end of block
0
50-
51 reconsider:
code before this statement executed 100007 times by 1 test: reconsider:
Executed by:
  • libcrypto.so.1.1
100007
52 if (inpgap == 0
inpgap == 0Description
TRUEevaluated 100007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& bitrem == 0
bitrem == 0Description
TRUEevaluated 100007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-100007
53 while (bits
bitsDescription
TRUEevaluated 112508 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 100007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
100007-112508
54 if (bitoff == 0
bitoff == 0Description
TRUEevaluated 15633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 96875 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& (
(n = bits / 512)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 15632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
n = bits / 512)
(n = bits / 512)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 15632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1-96875
55 whirlpool_block(c, inp, n);-
56 inp += n * 512 / 8;-
57 bits %= 512;-
58 }
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
1
59 unsigned int byteoff = bitoff / 8;-
60-
61 bitrem = 512 - bitoff;-
62 if (bits >= bitrem
bits >= bitremDescription
TRUEevaluated 15625 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 96882 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
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: end of block
Executed by:
  • libcrypto.so.1.1
else {
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:
  • libcrypto.so.1.1
96882
74 c->bitoff = bitoff;-
75 }
executed 112507 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
112507
76 }-
77 }
executed 100007 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else
100007
78-
79 {-
80 while (bits
bitsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
81 unsigned int byteoff = bitoff / 8;-
82 unsigned char b;-
83-
84-
85 if (bitrem == inpgap
bitrem == inpgapDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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
bitoff == 512Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: goto reconsider;
reconsider;
never executed: goto reconsider;
0
99 } else-
100-
101 if (bits > 8
bits > 8Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
102 b = ((inp[0] << inpgap) | (inp[1] >> (8 - inpgap)));-
103 b &= 0xff;-
104 if (bitrem
bitremDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
bitoff >= 512Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 whirlpool_block(c, c->data, 1);-
113 byteoff = 0;-
114 bitoff %= 512;-
115 }
never executed: end of block
0
116 if (bitrem
bitremDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
117 c->data[byteoff] = b << (8 - bitrem);
never executed: c->data[byteoff] = b << (8 - bitrem);
0
118 }
never executed: end of block
else {
0
119-
120 b = (inp[0] << inpgap) & 0xff;-
121 if (bitrem
bitremDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
bitoff == 512Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
127 whirlpool_block(c, c->data, 1);-
128 byteoff = 0;-
129 bitoff %= 512;-
130 }
never executed: end of block
0
131 if (bitrem
bitremDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
140int 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
bitoffDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
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:
  • libcrypto.so.1.1
9
151 byteoff++;-
152-
153-
154 if (byteoff > (512 / 8 - (256/8))
byteoff > (512 / 8 - (256/8))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
2-7
155 if (byteoff < 512 / 8
byteoff < 512 / 8Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
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:
  • libcrypto.so.1.1
2
157 whirlpool_block(c, c->data, 1);-
158 byteoff = 0;-
159 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
160 if (byteoff < (512 / 8 - (256/8))
byteoff < (512 / 8 - (256/8))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
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:
  • libcrypto.so.1.1
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:
  • libcrypto.so.1.1
9
163-
164 p = &c->data[512 / 8 - 1];-
165 for (i = 0; i < (256/8) / sizeof(size_t)
i < (256/8) / sizeof(size_t)Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++)
9-36
166 for (v = c->bitlen[i], j = 0; j < sizeof(size_t)
j < sizeof(size_t)Description
TRUEevaluated 288 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 36 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; j++, v >>= 8)
36-288
167 *
executed 288 times by 1 test: *p-- = (unsigned char)(v & 0xff);
Executed by:
  • libcrypto.so.1.1
p-- = (unsigned char)(v & 0xff);
executed 288 times by 1 test: *p-- = (unsigned char)(v & 0xff);
Executed by:
  • libcrypto.so.1.1
288
168-
169 whirlpool_block(c, c->data, 1);-
170-
171 if (md
mdDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-9
172 memcpy(md, c->H.c, (512/8));-
173 OPENSSL_cleanse(c, sizeof(*c));-
174 return
executed 9 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 9 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
9
175 }-
176 return
never executed: return 0;
0;
never executed: return 0;
0
177}-
178-
179unsigned 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 ==
md == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
185 ((void *)0)
md == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
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: return md;
md;
never executed: return md;
0
192}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2