OpenCoverage

cfb128.c

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

Generated by Squish Coco 4.2.2