OpenCoverage

cfb128.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/cfb128.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,-
9 size_t len, const void *key,-
10 unsigned char ivec[16], int *num,-
11 int enc, block128_f block)-
12{-
13 unsigned int n;-
14 size_t l = 0;-
15-
16 n = *num;-
17-
18 if (enc
encDescription
TRUEevaluated 10087 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10027 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10027-10087
19-
20 if (16 % sizeof(size_t) == 0
16 % sizeof(size_t) == 0Description
TRUEevaluated 10087 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-10087
21 do {-
22 while (n
nDescription
TRUEevaluated 35028 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9933 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& len
lenDescription
TRUEevaluated 34874 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 154 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
154-35028
23 *(out++) = ivec[n] ^= *(in++);-
24 --len;-
25 n = (n + 1) % 16;-
26 }
executed 34874 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34874
27-
28-
29-
30-
31-
32 while (len >= 16
len >= 16Description
TRUEevaluated 195632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10087 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10087-195632
33 (*block) (ivec, ivec, key);-
34 for (; n < 16
n < 16Description
TRUEevaluated 391264 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 195632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; n += sizeof(size_t)) {
195632-391264
35 *(size_t *)(out + n) =-
36 *(size_t *)(ivec + n) ^= *(size_t *)(in + n);-
37 }
executed 391264 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
391264
38 len -= 16;-
39 out += 16;-
40 in += 16;-
41 n = 0;-
42 }
executed 195632 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
195632
43 if (len
lenDescription
TRUEevaluated 4223 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5864 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4223-5864
44 (*block) (ivec, ivec, key);-
45 while (len--
len--Description
TRUEevaluated 32596 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4223 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4223-32596
46 out[n] = ivec[n] ^= in[n];-
47 ++n;-
48 }
executed 32596 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32596
49 }
executed 4223 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4223
50 *num = n;-
51 return;
executed 10087 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
10087
52 } while (0);-
53 }
never executed: end of block
0
54-
55-
56 while (l < len
l < lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
57 if (n == 0
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
58 (*block) (ivec, ivec, key);-
59 }
never executed: end of block
0
60 out[l] = ivec[n] ^= in[l];-
61 ++l;-
62 n = (n + 1) % 16;-
63 }
never executed: end of block
0
64 *num = n;-
65 }
never executed: end of block
else {
0
66-
67 if (16 % sizeof(size_t) == 0
16 % sizeof(size_t) == 0Description
TRUEevaluated 10027 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-10027
68 do {-
69 while (n
nDescription
TRUEevaluated 34378 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9883 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& len
lenDescription
TRUEevaluated 34234 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 144 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
144-34378
70 unsigned char c;-
71 *(out++) = ivec[n] ^ (c = *(in++));-
72 ivec[n] = c;-
73 --len;-
74 n = (n + 1) % 16;-
75 }
executed 34234 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34234
76-
77-
78-
79-
80-
81 while (len >= 16
len >= 16Description
TRUEevaluated 195672 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10027 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10027-195672
82 (*block) (ivec, ivec, key);-
83 for (; n < 16
n < 16Description
TRUEevaluated 391344 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 195672 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; n += sizeof(size_t)) {
195672-391344
84 size_t t = *(size_t *)(in + n);-
85 *(size_t *)(out + n) = *(size_t *)(ivec + n) ^ t;-
86 *(size_t *)(ivec + n) = t;-
87 }
executed 391344 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
391344
88 len -= 16;-
89 out += 16;-
90 in += 16;-
91 n = 0;-
92 }
executed 195672 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
195672
93 if (len
lenDescription
TRUEevaluated 4183 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5844 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4183-5844
94 (*block) (ivec, ivec, key);-
95 while (len--
len--Description
TRUEevaluated 32596 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4183 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4183-32596
96 unsigned char c;-
97 out[n] = ivec[n] ^ (c = in[n]);-
98 ivec[n] = c;-
99 ++n;-
100 }
executed 32596 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32596
101 }
executed 4183 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4183
102 *num = n;-
103 return;
executed 10027 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
10027
104 } while (0);-
105 }
never executed: end of block
0
106-
107-
108 while (l < len
l < lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
109 unsigned char c;-
110 if (n == 0
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
111 (*block) (ivec, ivec, key);-
112 }
never executed: end of block
0
113 out[l] = ivec[n] ^ (c = in[l]);-
114 ivec[n] = c;-
115 ++l;-
116 n = (n + 1) % 16;-
117 }
never executed: end of block
0
118 *num = n;-
119 }
never executed: end of block
0
120}-
121-
122-
123-
124-
125-
126static void cfbr_encrypt_block(const unsigned char *in, unsigned char *out,-
127 int nbits, const void *key,-
128 unsigned char ivec[16], int enc,-
129 block128_f block)-
130{-
131 int n, rem, num;-
132 unsigned char ovec[16 * 2 + 1];-
133-
134-
135 if (nbits <= 0
nbits <= 0Description
TRUEnever evaluated
FALSEevaluated 562212 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| nbits > 128
nbits > 128Description
TRUEnever evaluated
FALSEevaluated 562212 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-562212
136 return;
never executed: return;
0
137-
138-
139 memcpy(ovec, ivec, 16);-
140-
141 (*block) (ivec, ivec, key);-
142 num = (nbits + 7) / 8;-
143 if (enc
encDescription
TRUEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
281106
144 for (n = 0; n < num
n < numDescription
TRUEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n)
281106
145 out[n] = (ovec[16 + n] = in[n] ^ ivec[n]);
executed 281106 times by 1 test: out[n] = (ovec[16 + n] = in[n] ^ ivec[n]);
Executed by:
  • libcrypto.so.1.1
281106
146 else-
147 for (n = 0; n < num
n < numDescription
TRUEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 281106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n)
281106
148 out[n] = (ovec[16 + n] = in[n]) ^ ivec[n];
executed 281106 times by 1 test: out[n] = (ovec[16 + n] = in[n]) ^ ivec[n];
Executed by:
  • libcrypto.so.1.1
281106
149-
150 rem = nbits % 8;-
151 num = nbits / 8;-
152 if (rem == 0
rem == 0Description
TRUEevaluated 72708 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 489504 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
72708-489504
153 memcpy(ivec, ovec + num, 16);
executed 72708 times by 1 test: memcpy(ivec, ovec + num, 16);
Executed by:
  • libcrypto.so.1.1
72708
154 else-
155 for (n = 0; n < 16
n < 16Description
TRUEevaluated 7832064 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 489504 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n)
489504-7832064
156 ivec[n] = ovec[n + num] << rem | ovec[n + num + 1] >> (8 - rem);
executed 7832064 times by 1 test: ivec[n] = ovec[n + num] << rem | ovec[n + num + 1] >> (8 - rem);
Executed by:
  • libcrypto.so.1.1
7832064
157-
158-
159}
executed 562212 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
562212
160-
161-
162void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,-
163 size_t bits, const void *key,-
164 unsigned char ivec[16], int *num,-
165 int enc, block128_f block)-
166{-
167 size_t n;-
168 unsigned char c[1], d[1];-
169-
170 for (n = 0; n < bits
n < bitsDescription
TRUEevaluated 489504 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n) {
222-489504
171 c[0] = (
(in[n / 8] & (... (7 - n % 8)))Description
TRUEevaluated 224519 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 264985 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
in[n / 8] & (1 << (7 - n % 8)))
(in[n / 8] & (... (7 - n % 8)))Description
TRUEevaluated 224519 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 264985 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
? 0x80 : 0;
224519-264985
172 cfbr_encrypt_block(c, d, 1, key, ivec, enc, block);-
173 out[n / 8] = (out[n / 8] & ~(1 << (unsigned int)(7 - n % 8))) |-
174 ((d[0] & 0x80) >> (unsigned int)(n % 8));-
175 }
executed 489504 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
489504
176}
executed 222 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
222
177-
178void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,-
179 size_t length, const void *key,-
180 unsigned char ivec[16], int *num,-
181 int enc, block128_f block)-
182{-
183 size_t n;-
184-
185 for (n = 0; n < length
n < lengthDescription
TRUEevaluated 72708 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 366 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n)
366-72708
186 cfbr_encrypt_block(&in[n], &out[n], 8, key, ivec, enc, block);
executed 72708 times by 1 test: cfbr_encrypt_block(&in[n], &out[n], 8, key, ivec, enc, block);
Executed by:
  • libcrypto.so.1.1
72708
187}
executed 366 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
366
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2