OpenCoverage

siphash.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/siphash/siphash.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2size_t SipHash_ctx_size(void)-
3{-
4 return
never executed: return sizeof(SIPHASH);
sizeof(SIPHASH);
never executed: return sizeof(SIPHASH);
0
5}-
6-
7size_t SipHash_hash_size(SIPHASH *ctx)-
8{-
9 return
executed 52 times by 1 test: return ctx->hash_size;
Executed by:
  • libcrypto.so.1.1
ctx->hash_size;
executed 52 times by 1 test: return ctx->hash_size;
Executed by:
  • libcrypto.so.1.1
52
10}-
11-
12static size_t siphash_adjust_hash_size(size_t hash_size)-
13{-
14 if (hash_size == 0
hash_size == 0Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 885 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
28-885
15 hash_size = 16;
executed 28 times by 2 tests: hash_size = 16;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
28
16 return
executed 913 times by 2 tests: return hash_size;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
hash_size;
executed 913 times by 2 tests: return hash_size;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
913
17}-
18-
19int SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size)-
20{-
21 hash_size = siphash_adjust_hash_size(hash_size);-
22 if (hash_size != 8
hash_size != 8Description
TRUEevaluated 225 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 221 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
221-225
23 && hash_size != 16
hash_size != 16Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 223 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
2-223
24 return
executed 2 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
0;
executed 2 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
2
25-
26 ctx->hash_size = hash_size;-
27 return
executed 444 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
1;
executed 444 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
444
28}-
29-
30-
31int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int crounds, int drounds)-
32{-
33 uint64_t k0 = (((uint64_t)((k)[0])) | ((uint64_t)((k)[1]) << 8) | ((uint64_t)((k)[2]) << 16) | ((uint64_t)((k)[3]) << 24) | ((uint64_t)((k)[4]) << 32) | ((uint64_t)((k)[5]) << 40) | ((uint64_t)((k)[6]) << 48) | ((uint64_t)((k)[7]) << 56));-
34 uint64_t k1 = (((uint64_t)((k + 8)[0])) | ((uint64_t)((k + 8)[1]) << 8) | ((uint64_t)((k + 8)[2]) << 16) | ((uint64_t)((k + 8)[3]) << 24) | ((uint64_t)((k + 8)[4]) << 32) | ((uint64_t)((k + 8)[5]) << 40) | ((uint64_t)((k + 8)[6]) << 48) | ((uint64_t)((k + 8)[7]) << 56));-
35-
36-
37 ctx->hash_size = siphash_adjust_hash_size(ctx->hash_size);-
38-
39 if (drounds == 0
drounds == 0Description
TRUEevaluated 467 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEnever evaluated
)
0-467
40 drounds = 4;
executed 467 times by 2 tests: drounds = 4;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
467
41 if (crounds == 0
crounds == 0Description
TRUEevaluated 467 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEnever evaluated
)
0-467
42 crounds = 2;
executed 467 times by 2 tests: crounds = 2;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
467
43-
44 ctx->crounds = crounds;-
45 ctx->drounds = drounds;-
46-
47 ctx->len = 0;-
48 ctx->total_inlen = 0;-
49-
50 ctx->v0 = 0x736f6d6570736575ULL ^ k0;-
51 ctx->v1 = 0x646f72616e646f6dULL ^ k1;-
52 ctx->v2 = 0x6c7967656e657261ULL ^ k0;-
53 ctx->v3 = 0x7465646279746573ULL ^ k1;-
54-
55 if (ctx->hash_size == 16
ctx->hash_size == 16Description
TRUEevaluated 247 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 220 times by 1 test
Evaluated by:
  • siphash_internal_test
)
220-247
56 ctx->v1 ^= 0xee;
executed 247 times by 2 tests: ctx->v1 ^= 0xee;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
247
57-
58 return
executed 467 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
1;
executed 467 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
467
59}-
60-
61void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen)-
62{-
63 uint64_t m;-
64 const uint8_t *end;-
65 int left;-
66 int i;-
67 uint64_t v0 = ctx->v0;-
68 uint64_t v1 = ctx->v1;-
69 uint64_t v2 = ctx->v2;-
70 uint64_t v3 = ctx->v3;-
71-
72 ctx->total_inlen += inlen;-
73-
74 if (ctx->len
ctx->lenDescription
TRUEevaluated 150 times by 1 test
Evaluated by:
  • siphash_internal_test
FALSEevaluated 624 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
) {
150-624
75-
76 size_t available = 8 - ctx->len;-
77-
78-
79 if (inlen < available
inlen < availableDescription
TRUEnever evaluated
FALSEevaluated 150 times by 1 test
Evaluated by:
  • siphash_internal_test
) {
0-150
80 memcpy(&ctx->leavings[ctx->len], in, inlen);-
81 ctx->len += inlen;-
82 return;
never executed: return;
0
83 }-
84-
85-
86 memcpy(&ctx->leavings[ctx->len], in, available);-
87 inlen -= available;-
88 in += available;-
89-
90-
91 m = (((uint64_t)((ctx->leavings)[0])) | ((uint64_t)((ctx->leavings)[1]) << 8) | ((uint64_t)((ctx->leavings)[2]) << 16) | ((uint64_t)((ctx->leavings)[3]) << 24) | ((uint64_t)((ctx->leavings)[4]) << 32) | ((uint64_t)((ctx->leavings)[5]) << 40) | ((uint64_t)((ctx->leavings)[6]) << 48) | ((uint64_t)((ctx->leavings)[7]) << 56));-
92 v3 ^= m;-
93 for (i = 0; i < ctx->crounds
i < ctx->croundsDescription
TRUEevaluated 300 times by 1 test
Evaluated by:
  • siphash_internal_test
FALSEevaluated 150 times by 1 test
Evaluated by:
  • siphash_internal_test
; ++i)
150-300
94 do { v0 += v1; v1 = (uint64_t)(((v1) << (13)) | ((v1) >> (64 - (13)))); v1 ^= v0; v0 = (uint64_t)(((v0) << (32)) | ((v0) >> (64 - (32)))); v2 += v3; v3 = (uint64_t)(((v3) << (16)) | ((v3) >> (64 - (16)))); v3 ^= v2; v0 += v3; v3 = (uint64_t)(((v3) << (21)) | ((v3) >> (64 - (21)))); v3 ^= v0; v2 += v1; v1 = (uint64_t)(((v1) << (17)) | ((v1) >> (64 - (17)))); v1 ^= v2; v2 = (uint64_t)(((v2) << (32)) | ((v2) >> (64 - (32)))); }
executed 300 times by 1 test: end of block
Executed by:
  • siphash_internal_test
while (0);
300
95 v0 ^= m;-
96 }
executed 150 times by 1 test: end of block
Executed by:
  • siphash_internal_test
150
97 left = inlen & (8 -1);-
98 end = in + inlen - left;-
99-
100 for (; in != end
in != endDescription
TRUEevaluated 2000 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 774 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
; in += 8) {
774-2000
101 m = (((uint64_t)((in)[0])) | ((uint64_t)((in)[1]) << 8) | ((uint64_t)((in)[2]) << 16) | ((uint64_t)((in)[3]) << 24) | ((uint64_t)((in)[4]) << 32) | ((uint64_t)((in)[5]) << 40) | ((uint64_t)((in)[6]) << 48) | ((uint64_t)((in)[7]) << 56));-
102 v3 ^= m;-
103 for (i = 0; i < ctx->crounds
i < ctx->croundsDescription
TRUEevaluated 4000 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 2000 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
; ++i)
2000-4000
104 do { v0 += v1; v1 = (uint64_t)(((v1) << (13)) | ((v1) >> (64 - (13)))); v1 ^= v0; v0 = (uint64_t)(((v0) << (32)) | ((v0) >> (64 - (32)))); v2 += v3; v3 = (uint64_t)(((v3) << (16)) | ((v3) >> (64 - (16)))); v3 ^= v2; v0 += v3; v3 = (uint64_t)(((v3) << (21)) | ((v3) >> (64 - (21)))); v3 ^= v0; v2 += v1; v1 = (uint64_t)(((v1) << (17)) | ((v1) >> (64 - (17)))); v1 ^= v2; v2 = (uint64_t)(((v2) << (32)) | ((v2) >> (64 - (32)))); }
executed 4000 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
while (0);
4000
105 v0 ^= m;-
106 }
executed 2000 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
2000
107-
108-
109 if (left
leftDescription
TRUEevaluated 564 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 210 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
210-564
110 memcpy(ctx->leavings, end, left);
executed 564 times by 2 tests: memcpy(ctx->leavings, end, left);
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
564
111 ctx->len = left;-
112-
113 ctx->v0 = v0;-
114 ctx->v1 = v1;-
115 ctx->v2 = v2;-
116 ctx->v3 = v3;-
117}
executed 774 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
774
118-
119int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen)-
120{-
121-
122 int i;-
123 uint64_t b = ctx->total_inlen << 56;-
124 uint64_t v0 = ctx->v0;-
125 uint64_t v1 = ctx->v1;-
126 uint64_t v2 = ctx->v2;-
127 uint64_t v3 = ctx->v3;-
128-
129 if (outlen != (size_t)ctx->hash_size
outlen != (siz...ctx->hash_sizeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • siphash_internal_test
FALSEevaluated 467 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
3-467
130 return
executed 3 times by 1 test: return 0;
Executed by:
  • siphash_internal_test
0;
executed 3 times by 1 test: return 0;
Executed by:
  • siphash_internal_test
3
131-
132 switch (ctx->len) {-
133 case
executed 64 times by 2 tests: case 7:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
7:
executed 64 times by 2 tests: case 7:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
64
134 b |= ((uint64_t)ctx->leavings[6]) << 48;-
135-
136 case
executed 58 times by 2 tests: case 6:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
6:
executed 58 times by 2 tests: case 6:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 64 times by 2 tests: case 6:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
58-64
137 b |= ((uint64_t)ctx->leavings[5]) << 40;-
138-
139 case
executed 58 times by 2 tests: case 5:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
5:
executed 58 times by 2 tests: case 5:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 122 times by 2 tests: case 5:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
58-122
140 b |= ((uint64_t)ctx->leavings[4]) << 32;-
141-
142 case
executed 58 times by 2 tests: case 4:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
4:
executed 58 times by 2 tests: case 4:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 180 times by 2 tests: case 4:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
58-180
143 b |= ((uint64_t)ctx->leavings[3]) << 24;-
144-
145 case
executed 58 times by 2 tests: case 3:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
3:
executed 58 times by 2 tests: case 3:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 238 times by 2 tests: case 3:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
58-238
146 b |= ((uint64_t)ctx->leavings[2]) << 16;-
147-
148 case
executed 58 times by 2 tests: case 2:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
2:
executed 58 times by 2 tests: case 2:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 296 times by 2 tests: case 2:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
58-296
149 b |= ((uint64_t)ctx->leavings[1]) << 8;-
150-
151 case
executed 60 times by 2 tests: case 1:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
1:
executed 60 times by 2 tests: case 1:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 354 times by 2 tests: case 1:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
60-354
152 b |= ((uint64_t)ctx->leavings[0]);-
153 case
executed 467 times by 2 tests: case 0:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
0:
executed 467 times by 2 tests: case 0:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
code before this statement executed 414 times by 2 tests: case 0:
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
414-467
154 break;
executed 467 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
467
155 }-
156-
157 v3 ^= b;-
158 for (i = 0; i < ctx->crounds
i < ctx->croundsDescription
TRUEevaluated 934 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 467 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
; ++i)
467-934
159 do { v0 += v1; v1 = (uint64_t)(((v1) << (13)) | ((v1) >> (64 - (13)))); v1 ^= v0; v0 = (uint64_t)(((v0) << (32)) | ((v0) >> (64 - (32)))); v2 += v3; v3 = (uint64_t)(((v3) << (16)) | ((v3) >> (64 - (16)))); v3 ^= v2; v0 += v3; v3 = (uint64_t)(((v3) << (21)) | ((v3) >> (64 - (21)))); v3 ^= v0; v2 += v1; v1 = (uint64_t)(((v1) << (17)) | ((v1) >> (64 - (17)))); v1 ^= v2; v2 = (uint64_t)(((v2) << (32)) | ((v2) >> (64 - (32)))); }
executed 934 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
while (0);
934
160 v0 ^= b;-
161 if (ctx->hash_size == 16
ctx->hash_size == 16Description
TRUEevaluated 246 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 221 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
221-246
162 v2 ^= 0xee;
executed 246 times by 2 tests: v2 ^= 0xee;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
246
163 else-
164 v2 ^= 0xff;
executed 221 times by 2 tests: v2 ^= 0xff;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
221
165 for (i = 0; i < ctx->drounds
i < ctx->droundsDescription
TRUEevaluated 1868 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 467 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
; ++i)
467-1868
166 do { v0 += v1; v1 = (uint64_t)(((v1) << (13)) | ((v1) >> (64 - (13)))); v1 ^= v0; v0 = (uint64_t)(((v0) << (32)) | ((v0) >> (64 - (32)))); v2 += v3; v3 = (uint64_t)(((v3) << (16)) | ((v3) >> (64 - (16)))); v3 ^= v2; v0 += v3; v3 = (uint64_t)(((v3) << (21)) | ((v3) >> (64 - (21)))); v3 ^= v0; v2 += v1; v1 = (uint64_t)(((v1) << (17)) | ((v1) >> (64 - (17)))); v1 ^= v2; v2 = (uint64_t)(((v2) << (32)) | ((v2) >> (64 - (32)))); }
executed 1868 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
while (0);
1868
167 b = v0 ^ v1 ^ v2 ^ v3;-
168 ((out))[0] = (uint8_t)(((uint32_t)((b)))); ((out))[1] = (uint8_t)(((uint32_t)((b))) >> 8); ((out))[2] = (uint8_t)(((uint32_t)((b))) >> 16); ((out))[3] = (uint8_t)(((uint32_t)((b))) >> 24);; ((out) + 4)[0] = (uint8_t)(((uint32_t)((b) >> 32))); ((out) + 4)[1] = (uint8_t)(((uint32_t)((b) >> 32)) >> 8); ((out) + 4)[2] = (uint8_t)(((uint32_t)((b) >> 32)) >> 16); ((out) + 4)[3] = (uint8_t)(((uint32_t)((b) >> 32)) >> 24);;;-
169 if (ctx->hash_size == 8
ctx->hash_size == 8Description
TRUEevaluated 221 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 246 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
)
221-246
170 return
executed 221 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
1;
executed 221 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
221
171 v1 ^= 0xdd;-
172 for (i = 0; i < ctx->drounds
i < ctx->droundsDescription
TRUEevaluated 984 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
FALSEevaluated 246 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • siphash_internal_test
; ++i)
246-984
173 do { v0 += v1; v1 = (uint64_t)(((v1) << (13)) | ((v1) >> (64 - (13)))); v1 ^= v0; v0 = (uint64_t)(((v0) << (32)) | ((v0) >> (64 - (32)))); v2 += v3; v3 = (uint64_t)(((v3) << (16)) | ((v3) >> (64 - (16)))); v3 ^= v2; v0 += v3; v3 = (uint64_t)(((v3) << (21)) | ((v3) >> (64 - (21)))); v3 ^= v0; v2 += v1; v1 = (uint64_t)(((v1) << (17)) | ((v1) >> (64 - (17)))); v1 ^= v2; v2 = (uint64_t)(((v2) << (32)) | ((v2) >> (64 - (32)))); }
executed 984 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
while (0);
984
174 b = v0 ^ v1 ^ v2 ^ v3;-
175 ((out + 8))[0] = (uint8_t)(((uint32_t)((b)))); ((out + 8))[1] = (uint8_t)(((uint32_t)((b))) >> 8); ((out + 8))[2] = (uint8_t)(((uint32_t)((b))) >> 16); ((out + 8))[3] = (uint8_t)(((uint32_t)((b))) >> 24);; ((out + 8) + 4)[0] = (uint8_t)(((uint32_t)((b) >> 32))); ((out + 8) + 4)[1] = (uint8_t)(((uint32_t)((b) >> 32)) >> 8); ((out + 8) + 4)[2] = (uint8_t)(((uint32_t)((b) >> 32)) >> 16); ((out + 8) + 4)[3] = (uint8_t)(((uint32_t)((b) >> 32)) >> 24);;;-
176 return
executed 246 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
1;
executed 246 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • siphash_internal_test
246
177}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2