OpenCoverage

ctr128.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/ctr128.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static void ctr128_inc(unsigned char *counter)-
10{-
11 u32 n = 16, c = 1;-
12-
13 do {-
14 --n;-
15 c += counter[n];-
16 counter[n] = (u8)c;-
17 c >>= 8;-
18 }
executed 78624 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
while (n
nDescription
TRUEevaluated 73710 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4914 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
);
4914-78624
19}
executed 4914 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4914
20-
21-
22static void ctr128_inc_aligned(unsigned char *counter)-
23{-
24 size_t *data, c, d, n;-
25 const union {-
26 long one;-
27 char little;-
28 } is_endian = {-
29 1-
30 };-
31-
32 if (is_endian.little
is_endian.littleDescription
TRUEevaluated 4914 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
|| ((
((size_t)count...(size_t)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
size_t)counter % sizeof(size_t)) != 0
((size_t)count...(size_t)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-4914
33 ctr128_inc(counter);-
34 return;
executed 4914 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
4914
35 }-
36-
37 data = (size_t *)counter;-
38 c = 1;-
39 n = 16 / sizeof(size_t);-
40 do {-
41 --n;-
42 d = data[n] += c;-
43-
44 c = ((d - c) & ~d) >> (sizeof(size_t) * 8 - 1);-
45 }
never executed: end of block
while (n
nDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
46}
never executed: end of block
0
47void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,-
48 size_t len, const void *key,-
49 unsigned char ivec[16],-
50 unsigned char ecount_buf[16], unsigned int *num,-
51 block128_f block)-
52{-
53 unsigned int n;-
54 size_t l = 0;-
55-
56 n = *num;-
57-
58-
59 if (16 % sizeof(size_t) == 0
16 % sizeof(size_t) == 0Description
TRUEevaluated 694 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-694
60 do {-
61 while (n
nDescription
TRUEevaluated 3722 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& len
lenDescription
TRUEevaluated 3678 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
44-3722
62 *(out++) = *(in++) ^ ecount_buf[n];-
63 --len;-
64 n = (n + 1) % 16;-
65 }
executed 3678 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3678
66-
67-
68-
69-
70-
71-
72 while (len >= 16
len >= 16Description
TRUEevaluated 4440 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 694 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
694-4440
73 (*block) (ivec, ecount_buf, key);-
74 ctr128_inc_aligned(ivec);-
75 for (n = 0; n < 16
n < 16Description
TRUEevaluated 8880 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4440 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; n += sizeof(size_t))
4440-8880
76 *(
executed 8880 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(ecount_buf + n);
Executed by:
  • libcrypto.so.1.1
size_t *)(out + n) =
executed 8880 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(ecount_buf + n);
Executed by:
  • libcrypto.so.1.1
8880
77 *(size_t *)(in + n) ^ *(size_t *)(ecount_buf + n);
executed 8880 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(ecount_buf + n);
Executed by:
  • libcrypto.so.1.1
8880
78 len -= 16;-
79 out += 16;-
80 in += 16;-
81 n = 0;-
82 }
executed 4440 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4440
83 if (len
lenDescription
TRUEevaluated 474 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 220 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
220-474
84 (*block) (ivec, ecount_buf, key);-
85 ctr128_inc_aligned(ivec);-
86 while (len--
len--Description
TRUEevaluated 3346 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 474 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
474-3346
87 out[n] = in[n] ^ ecount_buf[n];-
88 ++n;-
89 }
executed 3346 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3346
90 }
executed 474 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
474
91 *num = n;-
92 return;
executed 694 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
694
93 } while (0);-
94 }
never executed: end of block
0
95-
96-
97 while (l < len
l < lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
98 if (n == 0
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
99 (*block) (ivec, ecount_buf, key);-
100 ctr128_inc(ivec);-
101 }
never executed: end of block
0
102 out[l] = in[l] ^ ecount_buf[n];-
103 ++l;-
104 n = (n + 1) % 16;-
105 }
never executed: end of block
0
106-
107 *num = n;-
108}
never executed: end of block
0
109-
110-
111static void ctr96_inc(unsigned char *counter)-
112{-
113 u32 n = 12, c = 1;-
114-
115 do {-
116 --n;-
117 c += counter[n];-
118 counter[n] = (u8)c;-
119 c >>= 8;-
120 }
executed 144 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
while (n
nDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
);
12-144
121}
executed 12 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12
122-
123void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,-
124 size_t len, const void *key,-
125 unsigned char ivec[16],-
126 unsigned char ecount_buf[16],-
127 unsigned int *num, ctr128_f func)-
128{-
129 unsigned int n, ctr32;-
130-
131 n = *num;-
132-
133 while (n
nDescription
TRUEevaluated 62514 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18636 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& len
lenDescription
TRUEevaluated 62472 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 42 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
42-62514
134 *(out++) = *(in++) ^ ecount_buf[n];-
135 --len;-
136 n = (n + 1) % 16;-
137 }
executed 62472 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
62472
138-
139 ctr32 = ({ u32 ret_=(*(const u32 *)(ivec + 12)); asm ("bswapl %0" : "+r"(ret_)); ret_; });-
140 while (len >= 16
len >= 16Description
TRUEevaluated 18324 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18678 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
18324-18678
141 size_t blocks = len / 16;-
142-
143-
144-
145-
146-
147 if (sizeof(size_t) > sizeof(unsigned int)
sizeof(size_t)...(unsigned int)Description
TRUEevaluated 18324 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& blocks > (1U << 28)
blocks > (1U << 28)Description
TRUEnever evaluated
FALSEevaluated 18324 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-18324
148 blocks = (1U << 28);
never executed: blocks = (1U << 28);
0
149-
150-
151-
152-
153-
154-
155 ctr32 += (u32)blocks;-
156 if (ctr32 < blocks
ctr32 < blocksDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18318 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
6-18318
157 blocks -= ctr32;-
158 ctr32 = 0;-
159 }
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
160 (*func) (in, out, blocks, key, ivec);-
161-
162 *(u32 *)(ivec + 12) = ({ u32 ret_=(ctr32); asm ("bswapl %0" : "+r"(ret_)); ret_; });-
163-
164 if (ctr32 == 0
ctr32 == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18318 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
6-18318
165 ctr96_inc(ivec);
executed 6 times by 1 test: ctr96_inc(ivec);
Executed by:
  • libcrypto.so.1.1
6
166 blocks *= 16;-
167 len -= blocks;-
168 out += blocks;-
169 in += blocks;-
170 }
executed 18324 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18324
171 if (len
lenDescription
TRUEevaluated 7812 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10866 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
7812-10866
172 memset(ecount_buf, 0, 16);-
173 (*func) (ecount_buf, ecount_buf, 1, key, ivec);-
174 ++ctr32;-
175 *(u32 *)(ivec + 12) = ({ u32 ret_=(ctr32); asm ("bswapl %0" : "+r"(ret_)); ret_; });-
176 if (ctr32 == 0
ctr32 == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7806 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
6-7806
177 ctr96_inc(ivec);
executed 6 times by 1 test: ctr96_inc(ivec);
Executed by:
  • libcrypto.so.1.1
6
178 while (len--
len--Description
TRUEevaluated 62040 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7812 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
7812-62040
179 out[n] = in[n] ^ ecount_buf[n];-
180 ++n;-
181 }
executed 62040 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
62040
182 }
executed 7812 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7812
183-
184 *num = n;-
185}
executed 18678 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18678
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2