OpenCoverage

bf_enc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bf/bf_enc.c
Switch to Source codePreprocessed file
LineSourceCount
1void BF_encrypt(unsigned int *data, const BF_KEY *key)-
2 {-
3-
4 unsigned int l,r;-
5 const unsigned int *p,*s;-
6-
7 p=key->P;-
8 s= &(key->S[0]);-
9 l=data[0];-
10 r=data[1];-
11-
12 l^=p[0];-
13 ( r^=p[ 1], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
14 ( l^=p[ 2], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
15 ( r^=p[ 3], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
16 ( l^=p[ 4], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
17 ( r^=p[ 5], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
18 ( l^=p[ 6], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
19 ( r^=p[ 7], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
20 ( l^=p[ 8], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
21 ( r^=p[ 9], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
22 ( l^=p[10], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
23 ( r^=p[11], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
24 ( l^=p[12], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
25 ( r^=p[13], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
26 ( l^=p[14], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
27 ( r^=p[15], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
28 ( l^=p[16], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
29-
30-
31-
32-
33-
34-
35 r^=p[16 +1];-
36-
37 data[1]=l&0xffffffffL;-
38 data[0]=r&0xffffffffL;-
39 }
executed 42575 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
42575
40-
41-
42-
43void BF_decrypt(unsigned int *data, const BF_KEY *key)-
44 {-
45-
46 unsigned int l,r;-
47 const unsigned int *p,*s;-
48-
49 p=key->P;-
50 s= &(key->S[0]);-
51 l=data[0];-
52 r=data[1];-
53-
54 l^=p[16 +1];-
55-
56-
57-
58-
59-
60-
61 ( r^=p[16], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
62 ( l^=p[15], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
63 ( r^=p[14], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
64 ( l^=p[13], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
65 ( r^=p[12], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
66 ( l^=p[11], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
67 ( r^=p[10], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
68 ( l^=p[ 9], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
69 ( r^=p[ 8], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
70 ( l^=p[ 7], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
71 ( r^=p[ 6], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
72 ( l^=p[ 5], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
73 ( r^=p[ 4], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
74 ( l^=p[ 3], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
75 ( r^=p[ 2], r^=((( s[ ((int)(l>>24)&0xff)] + s[0x0100+((int)(l>>16)&0xff)])^ s[0x0200+((int)(l>> 8)&0xff)])+ s[0x0300+((int)(l )&0xff)])&0xffffffffL );-
76 ( l^=p[ 1], l^=((( s[ ((int)(r>>24)&0xff)] + s[0x0100+((int)(r>>16)&0xff)])^ s[0x0200+((int)(r>> 8)&0xff)])+ s[0x0300+((int)(r )&0xff)])&0xffffffffL );-
77 r^=p[0];-
78-
79 data[1]=l&0xffffffffL;-
80 data[0]=r&0xffffffffL;-
81 }
executed 488 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
488
82-
83void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,-
84 const BF_KEY *schedule, unsigned char *ivec, int encrypt)-
85 {-
86 unsigned int tin0,tin1;-
87 unsigned int tout0,tout1,xor0,xor1;-
88 long l=length;-
89 unsigned int tin[2];-
90-
91 if (encrypt
encryptDescription
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
)
3-5
92 {-
93 (tout0 =((unsigned long)(*((ivec)++)))<<24L, tout0|=((unsigned long)(*((ivec)++)))<<16L, tout0|=((unsigned long)(*((ivec)++)))<< 8L, tout0|=((unsigned long)(*((ivec)++))));-
94 (tout1 =((unsigned long)(*((ivec)++)))<<24L, tout1|=((unsigned long)(*((ivec)++)))<<16L, tout1|=((unsigned long)(*((ivec)++)))<< 8L, tout1|=((unsigned long)(*((ivec)++))));-
95 ivec-=8;-
96 for (l-=8; l>=0
l>=0Description
TRUEevaluated 227 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
; l-=8)
5-227
97 {-
98 (tin0 =((unsigned long)(*((in)++)))<<24L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++))));-
99 (tin1 =((unsigned long)(*((in)++)))<<24L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++))));-
100 tin0^=tout0;-
101 tin1^=tout1;-
102 tin[0]=tin0;-
103 tin[1]=tin1;-
104 BF_encrypt(tin,schedule);-
105 tout0=tin[0];-
106 tout1=tin[1];-
107 (*((out)++)=(unsigned char)(((tout0)>>24L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0) )&0xff));-
108 (*((out)++)=(unsigned char)(((tout1)>>24L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1) )&0xff));-
109 }
executed 227 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
227
110 if (l != -8
l != -8Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • bftest
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
1-4
111 {-
112 { in+=l+8; tin0=tin1=0; switch (l+8) { case
never executed: case 8:
8:
never executed: case 8:
tin1 =((unsigned long)(*(--(in)))) ; case
never executed: case 7:
7:
never executed: case 7:
code before this statement never executed: case 7:
tin1|=((unsigned long)(*(--(in))))<< 8; case
never executed: case 6:
6:
never executed: case 6:
code before this statement never executed: case 6:
tin1|=((unsigned long)(*(--(in))))<<16; case
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
code before this statement never executed: case 5:
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
5:
code before this statement never executed: case 5:
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
tin1|=((unsigned long)(*(--(in))))<<24; case
never executed: case 4:
code before this statement executed 1 time by 1 test: case 4:
Executed by:
  • bftest
never executed: case 4:
4:
code before this statement executed 1 time by 1 test: case 4:
Executed by:
  • bftest
never executed: case 4:
tin0 =((unsigned long)(*(--(in)))) ; case
never executed: case 3:
code before this statement executed 1 time by 1 test: case 3:
Executed by:
  • bftest
never executed: case 3:
3:
code before this statement executed 1 time by 1 test: case 3:
Executed by:
  • bftest
never executed: case 3:
tin0|=((unsigned long)(*(--(in))))<< 8; case
never executed: case 2:
code before this statement executed 1 time by 1 test: case 2:
Executed by:
  • bftest
never executed: case 2:
2:
code before this statement executed 1 time by 1 test: case 2:
Executed by:
  • bftest
never executed: case 2:
tin0|=((unsigned long)(*(--(in))))<<16; case
executed 1 time by 1 test: case 1:
Executed by:
  • bftest
1:
executed 1 time by 1 test: case 1:
Executed by:
  • bftest
code before this statement executed 1 time by 1 test: case 1:
Executed by:
  • bftest
tin0|=((unsigned long)(*(--(in))))<<24; }
executed 1 time by 1 test: end of block
Executed by:
  • bftest
};
0-1
113 tin0^=tout0;-
114 tin1^=tout1;-
115 tin[0]=tin0;-
116 tin[1]=tin1;-
117 BF_encrypt(tin,schedule);-
118 tout0=tin[0];-
119 tout1=tin[1];-
120 (*((out)++)=(unsigned char)(((tout0)>>24L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0) )&0xff));-
121 (*((out)++)=(unsigned char)(((tout1)>>24L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1) )&0xff));-
122 }
executed 1 time by 1 test: end of block
Executed by:
  • bftest
1
123 (*((ivec)++)=(unsigned char)(((tout0)>>24L)&0xff), *((ivec)++)=(unsigned char)(((tout0)>>16L)&0xff), *((ivec)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((ivec)++)=(unsigned char)(((tout0) )&0xff));-
124 (*((ivec)++)=(unsigned char)(((tout1)>>24L)&0xff), *((ivec)++)=(unsigned char)(((tout1)>>16L)&0xff), *((ivec)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((ivec)++)=(unsigned char)(((tout1) )&0xff));-
125 }
executed 5 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
5
126 else-
127 {-
128 (xor0 =((unsigned long)(*((ivec)++)))<<24L, xor0|=((unsigned long)(*((ivec)++)))<<16L, xor0|=((unsigned long)(*((ivec)++)))<< 8L, xor0|=((unsigned long)(*((ivec)++))));-
129 (xor1 =((unsigned long)(*((ivec)++)))<<24L, xor1|=((unsigned long)(*((ivec)++)))<<16L, xor1|=((unsigned long)(*((ivec)++)))<< 8L, xor1|=((unsigned long)(*((ivec)++))));-
130 ivec-=8;-
131 for (l-=8; l>=0
l>=0Description
TRUEevaluated 227 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • bftest
  • libcrypto.so.44.0.1
; l-=8)
3-227
132 {-
133 (tin0 =((unsigned long)(*((in)++)))<<24L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++))));-
134 (tin1 =((unsigned long)(*((in)++)))<<24L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++))));-
135 tin[0]=tin0;-
136 tin[1]=tin1;-
137 BF_decrypt(tin,schedule);-
138 tout0=tin[0]^xor0;-
139 tout1=tin[1]^xor1;-
140 (*((out)++)=(unsigned char)(((tout0)>>24L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0) )&0xff));-
141 (*((out)++)=(unsigned char)(((tout1)>>24L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1) )&0xff));-
142 xor0=tin0;-
143 xor1=tin1;-
144 }
executed 227 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
227
145 if (l != -8
l != -8Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • bftest
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
1-2
146 {-
147 (tin0 =((unsigned long)(*((in)++)))<<24L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++))));-
148 (tin1 =((unsigned long)(*((in)++)))<<24L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++))));-
149 tin[0]=tin0;-
150 tin[1]=tin1;-
151 BF_decrypt(tin,schedule);-
152 tout0=tin[0]^xor0;-
153 tout1=tin[1]^xor1;-
154 { out+=l+8; switch (l+8) { case
never executed: case 8:
8:
never executed: case 8:
*(--(out))=(unsigned char)(((tout1) )&0xff); case
never executed: case 7:
7:
never executed: case 7:
code before this statement never executed: case 7:
*(--(out))=(unsigned char)(((tout1)>> 8)&0xff); case
never executed: case 6:
6:
never executed: case 6:
code before this statement never executed: case 6:
*(--(out))=(unsigned char)(((tout1)>>16)&0xff); case
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
code before this statement never executed: case 5:
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
5:
code before this statement never executed: case 5:
executed 1 time by 1 test: case 5:
Executed by:
  • bftest
*(--(out))=(unsigned char)(((tout1)>>24)&0xff); case
never executed: case 4:
code before this statement executed 1 time by 1 test: case 4:
Executed by:
  • bftest
never executed: case 4:
4:
code before this statement executed 1 time by 1 test: case 4:
Executed by:
  • bftest
never executed: case 4:
*(--(out))=(unsigned char)(((tout0) )&0xff); case
never executed: case 3:
code before this statement executed 1 time by 1 test: case 3:
Executed by:
  • bftest
never executed: case 3:
3:
code before this statement executed 1 time by 1 test: case 3:
Executed by:
  • bftest
never executed: case 3:
*(--(out))=(unsigned char)(((tout0)>> 8)&0xff); case
never executed: case 2:
code before this statement executed 1 time by 1 test: case 2:
Executed by:
  • bftest
never executed: case 2:
2:
code before this statement executed 1 time by 1 test: case 2:
Executed by:
  • bftest
never executed: case 2:
*(--(out))=(unsigned char)(((tout0)>>16)&0xff); case
executed 1 time by 1 test: case 1:
Executed by:
  • bftest
1:
executed 1 time by 1 test: case 1:
Executed by:
  • bftest
code before this statement executed 1 time by 1 test: case 1:
Executed by:
  • bftest
*(--(out))=(unsigned char)(((tout0)>>24)&0xff); }
executed 1 time by 1 test: end of block
Executed by:
  • bftest
};
0-1
155 xor0=tin0;-
156 xor1=tin1;-
157 }
executed 1 time by 1 test: end of block
Executed by:
  • bftest
1
158 (*((ivec)++)=(unsigned char)(((xor0)>>24L)&0xff), *((ivec)++)=(unsigned char)(((xor0)>>16L)&0xff), *((ivec)++)=(unsigned char)(((xor0)>> 8L)&0xff), *((ivec)++)=(unsigned char)(((xor0) )&0xff));-
159 (*((ivec)++)=(unsigned char)(((xor1)>>24L)&0xff), *((ivec)++)=(unsigned char)(((xor1)>>16L)&0xff), *((ivec)++)=(unsigned char)(((xor1)>> 8L)&0xff), *((ivec)++)=(unsigned char)(((xor1) )&0xff));-
160 }
executed 3 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
3
161 tin0=tin1=tout0=tout1=xor0=xor1=0;-
162 tin[0]=tin[1]=0;-
163 }
executed 8 times by 2 tests: end of block
Executed by:
  • bftest
  • libcrypto.so.44.0.1
8
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2