OpenCoverage

rc2_cbc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/rc2/rc2_cbc.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,-
3 RC2_KEY *ks, unsigned char *iv, int encrypt)-
4 {-
5 unsigned long tin0,tin1;-
6 unsigned long tout0,tout1,xor0,xor1;-
7 long l=length;-
8 unsigned long tin[2];-
9-
10 if (encrypt
encryptDescription
TRUEevaluated 12 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-12
11 {-
12 (tout0 =((unsigned long)(*((iv)++))) , tout0|=((unsigned long)(*((iv)++)))<< 8L, tout0|=((unsigned long)(*((iv)++)))<<16L, tout0|=((unsigned long)(*((iv)++)))<<24L);-
13 (tout1 =((unsigned long)(*((iv)++))) , tout1|=((unsigned long)(*((iv)++)))<< 8L, tout1|=((unsigned long)(*((iv)++)))<<16L, tout1|=((unsigned long)(*((iv)++)))<<24L);-
14 iv-=8;-
15 for (l-=8; l>=0
l>=0Description
TRUEevaluated 672 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
; l-=8)
12-672
16 {-
17 (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L);-
18 (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L);-
19 tin0^=tout0;-
20 tin1^=tout1;-
21 tin[0]=tin0;-
22 tin[1]=tin1;-
23 RC2_encrypt(tin,ks);-
24 tout0=tin[0]; (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff));-
25 tout1=tin[1]; (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff));-
26 }
executed 672 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
672
27 if (l != -8
l != -8Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
0-12
28 {-
29 { in+=l+8; tin0=tin1=0; switch (l+8) { case
never executed: case 8:
8:
never executed: case 8:
tin1 =((unsigned long)(*(--(in))))<<24L; case
never executed: case 7:
7:
never executed: case 7:
code before this statement never executed: case 7:
tin1|=((unsigned long)(*(--(in))))<<16L; case
never executed: case 6:
6:
never executed: case 6:
code before this statement never executed: case 6:
tin1|=((unsigned long)(*(--(in))))<< 8L; case
never executed: case 5:
5:
never executed: case 5:
code before this statement never executed: case 5:
tin1|=((unsigned long)(*(--(in)))); case
never executed: case 4:
4:
never executed: case 4:
code before this statement never executed: case 4:
tin0 =((unsigned long)(*(--(in))))<<24L; case
never executed: case 3:
3:
never executed: case 3:
code before this statement never executed: case 3:
tin0|=((unsigned long)(*(--(in))))<<16L; case
never executed: case 2:
2:
never executed: case 2:
code before this statement never executed: case 2:
tin0|=((unsigned long)(*(--(in))))<< 8L; case
never executed: case 1:
1:
never executed: case 1:
code before this statement never executed: case 1:
tin0|=((unsigned long)(*(--(in)))); }
never executed: end of block
};
0
30 tin0^=tout0;-
31 tin1^=tout1;-
32 tin[0]=tin0;-
33 tin[1]=tin1;-
34 RC2_encrypt(tin,ks);-
35 tout0=tin[0]; (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff));-
36 tout1=tin[1]; (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff));-
37 }
never executed: end of block
0
38 (*((iv)++)=(unsigned char)(((tout0) )&0xff), *((iv)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((tout0)>>16L)&0xff), *((iv)++)=(unsigned char)(((tout0)>>24L)&0xff));-
39 (*((iv)++)=(unsigned char)(((tout1) )&0xff), *((iv)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((tout1)>>16L)&0xff), *((iv)++)=(unsigned char)(((tout1)>>24L)&0xff));-
40 }
executed 12 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
12
41 else-
42 {-
43 (xor0 =((unsigned long)(*((iv)++))) , xor0|=((unsigned long)(*((iv)++)))<< 8L, xor0|=((unsigned long)(*((iv)++)))<<16L, xor0|=((unsigned long)(*((iv)++)))<<24L);-
44 (xor1 =((unsigned long)(*((iv)++))) , xor1|=((unsigned long)(*((iv)++)))<< 8L, xor1|=((unsigned long)(*((iv)++)))<<16L, xor1|=((unsigned long)(*((iv)++)))<<24L);-
45 iv-=8;-
46 for (l-=8; l>=0
l>=0Description
TRUEevaluated 672 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
; l-=8)
6-672
47 {-
48 (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L); tin[0]=tin0;-
49 (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L); tin[1]=tin1;-
50 RC2_decrypt(tin,ks);-
51 tout0=tin[0]^xor0;-
52 tout1=tin[1]^xor1;-
53 (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff));-
54 (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff));-
55 xor0=tin0;-
56 xor1=tin1;-
57 }
executed 672 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
672
58 if (l != -8
l != -8Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
0-6
59 {-
60 (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L); tin[0]=tin0;-
61 (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L); tin[1]=tin1;-
62 RC2_decrypt(tin,ks);-
63 tout0=tin[0]^xor0;-
64 tout1=tin[1]^xor1;-
65 { out+=l+8; switch (l+8) { case
never executed: case 8:
8:
never executed: case 8:
*(--(out))=(unsigned char)(((tout1)>>24L)&0xff); case
never executed: case 7:
7:
never executed: case 7:
code before this statement never executed: case 7:
*(--(out))=(unsigned char)(((tout1)>>16L)&0xff); case
never executed: case 6:
6:
never executed: case 6:
code before this statement never executed: case 6:
*(--(out))=(unsigned char)(((tout1)>> 8L)&0xff); case
never executed: case 5:
5:
never executed: case 5:
code before this statement never executed: case 5:
*(--(out))=(unsigned char)(((tout1) )&0xff); case
never executed: case 4:
4:
never executed: case 4:
code before this statement never executed: case 4:
*(--(out))=(unsigned char)(((tout0)>>24L)&0xff); case
never executed: case 3:
3:
never executed: case 3:
code before this statement never executed: case 3:
*(--(out))=(unsigned char)(((tout0)>>16L)&0xff); case
never executed: case 2:
2:
never executed: case 2:
code before this statement never executed: case 2:
*(--(out))=(unsigned char)(((tout0)>> 8L)&0xff); case
never executed: case 1:
1:
never executed: case 1:
code before this statement never executed: case 1:
*(--(out))=(unsigned char)(((tout0) )&0xff); }
never executed: end of block
};
0
66 xor0=tin0;-
67 xor1=tin1;-
68 }
never executed: end of block
0
69 (*((iv)++)=(unsigned char)(((xor0) )&0xff), *((iv)++)=(unsigned char)(((xor0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((xor0)>>16L)&0xff), *((iv)++)=(unsigned char)(((xor0)>>24L)&0xff));-
70 (*((iv)++)=(unsigned char)(((xor1) )&0xff), *((iv)++)=(unsigned char)(((xor1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((xor1)>>16L)&0xff), *((iv)++)=(unsigned char)(((xor1)>>24L)&0xff));-
71 }
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
6
72 tin0=tin1=tout0=tout1=xor0=xor1=0;-
73 tin[0]=tin[1]=0;-
74 }
executed 18 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
18
75-
76void RC2_encrypt(unsigned long *d, RC2_KEY *key)-
77 {-
78 int i,n;-
79 unsigned int *p0,*p1;-
80 unsigned int x0,x1,x2,x3,t;-
81 unsigned long l;-
82-
83 l=d[0];-
84 x0=(unsigned int)l&0xffff;-
85 x1=(unsigned int)(l>>16L);-
86 l=d[1];-
87 x2=(unsigned int)l&0xffff;-
88 x3=(unsigned int)(l>>16L);-
89-
90 n=3;-
91 i=5;-
92-
93 p0=p1= &(key->data[0]);-
94 for (;;)-
95 {-
96 t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff;-
97 x0=(t<<1)|(t>>15);-
98 t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff;-
99 x1=(t<<2)|(t>>14);-
100 t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff;-
101 x2=(t<<3)|(t>>13);-
102 t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff;-
103 x3=(t<<5)|(t>>11);-
104-
105 if (--
--i == 0Description
TRUEevaluated 5364 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 23244 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
i == 0
--i == 0Description
TRUEevaluated 5364 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 23244 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
)
5364-23244
106 {-
107 if (--
--n == 0Description
TRUEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 3576 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
n == 0
--n == 0Description
TRUEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 3576 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
) break;
executed 1788 times by 2 tests: break;
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
1788-3576
108 i=(
(n == 2)Description
TRUEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
n == 2)
(n == 2)Description
TRUEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 1788 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
?6:5;
1788
109-
110 x0+=p1[x3&0x3f];-
111 x1+=p1[x0&0x3f];-
112 x2+=p1[x1&0x3f];-
113 x3+=p1[x2&0x3f];-
114 }
executed 3576 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
3576
115 }
executed 26820 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
26820
116-
117 d[0]=(unsigned long)(x0&0xffff)|((unsigned long)(x1&0xffff)<<16L);-
118 d[1]=(unsigned long)(x2&0xffff)|((unsigned long)(x3&0xffff)<<16L);-
119 }
executed 1788 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
1788
120-
121void RC2_decrypt(unsigned long *d, RC2_KEY *key)-
122 {-
123 int i,n;-
124 unsigned int *p0,*p1;-
125 unsigned int x0,x1,x2,x3,t;-
126 unsigned long l;-
127-
128 l=d[0];-
129 x0=(unsigned int)l&0xffff;-
130 x1=(unsigned int)(l>>16L);-
131 l=d[1];-
132 x2=(unsigned int)l&0xffff;-
133 x3=(unsigned int)(l>>16L);-
134-
135 n=3;-
136 i=5;-
137-
138 p0= &(key->data[63]);-
139 p1= &(key->data[0]);-
140 for (;;)-
141 {-
142 t=((x3<<11)|(x3>>5))&0xffff;-
143 x3=(t-(x0& ~x2)-(x1&x2)- *(p0--))&0xffff;-
144 t=((x2<<13)|(x2>>3))&0xffff;-
145 x2=(t-(x3& ~x1)-(x0&x1)- *(p0--))&0xffff;-
146 t=((x1<<14)|(x1>>2))&0xffff;-
147 x1=(t-(x2& ~x0)-(x3&x0)- *(p0--))&0xffff;-
148 t=((x0<<15)|(x0>>1))&0xffff;-
149 x0=(t-(x1& ~x3)-(x2&x3)- *(p0--))&0xffff;-
150-
151 if (--
--i == 0Description
TRUEevaluated 2700 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 11700 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
i == 0
--i == 0Description
TRUEevaluated 2700 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 11700 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
)
2700-11700
152 {-
153 if (--
--n == 0Description
TRUEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 1800 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
n == 0
--n == 0Description
TRUEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 1800 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
) break;
executed 900 times by 2 tests: break;
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
900-1800
154 i=(
(n == 2)Description
TRUEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
n == 2)
(n == 2)Description
TRUEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
FALSEevaluated 900 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • rc2test
?6:5;
900
155-
156 x3=(x3-p1[x2&0x3f])&0xffff;-
157 x2=(x2-p1[x1&0x3f])&0xffff;-
158 x1=(x1-p1[x0&0x3f])&0xffff;-
159 x0=(x0-p1[x3&0x3f])&0xffff;-
160 }
executed 1800 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
1800
161 }
executed 13500 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
13500
162-
163 d[0]=(unsigned long)(x0&0xffff)|((unsigned long)(x1&0xffff)<<16L);-
164 d[1]=(unsigned long)(x2&0xffff)|((unsigned long)(x3&0xffff)<<16L);-
165 }
executed 900 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • rc2test
900
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2