Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/rc2/rc2_cbc.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | - | ||||||||||||
3 | RC2_KEY *ks, unsigned char *iv, int encrypt) | - | ||||||||||||
4 | { | - | ||||||||||||
5 | register unsigned long tin0, tin1; | - | ||||||||||||
6 | register unsigned long tout0, tout1, xor0, xor1; | - | ||||||||||||
7 | register long l = length; | - | ||||||||||||
8 | unsigned long tin[2]; | - | ||||||||||||
9 | - | |||||||||||||
10 | if (encrypt
| 217-314 | ||||||||||||
11 | (tout0 =((unsigned long)(*((iv)++))) , tout0|=((unsigned long)(*((iv)++)))<< 8L, tout0|=((unsigned long)(*((iv)++)))<<16L, tout0|=((unsigned long)(*((iv)++)))<<24L); | - | ||||||||||||
12 | (tout1 =((unsigned long)(*((iv)++))) , tout1|=((unsigned long)(*((iv)++)))<< 8L, tout1|=((unsigned long)(*((iv)++)))<<16L, tout1|=((unsigned long)(*((iv)++)))<<24L); | - | ||||||||||||
13 | iv -= 8; | - | ||||||||||||
14 | for (l -= 8; l >= 0
| 314-3904 | ||||||||||||
15 | (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
16 | (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
17 | tin0 ^= tout0; | - | ||||||||||||
18 | tin1 ^= tout1; | - | ||||||||||||
19 | tin[0] = tin0; | - | ||||||||||||
20 | tin[1] = tin1; | - | ||||||||||||
21 | RC2_encrypt(tin, ks); | - | ||||||||||||
22 | tout0 = tin[0]; | - | ||||||||||||
23 | (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff)); | - | ||||||||||||
24 | tout1 = tin[1]; | - | ||||||||||||
25 | (*((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 3904 times by 1 test: end of block Executed by:
| 3904 | ||||||||||||
27 | if (l != -8
| 0-314 | ||||||||||||
28 | { in+=l + 8; tin0=tin1=0; switch (l + 8) { case never executed: 8:case 8: never executed: tin1 =((unsigned long)(*(--(in))))<<24L; casecase 8: never executed: 7:case 7: never executed: case 7: code before this statement never executed: tin1|=((unsigned long)(*(--(in))))<<16L; casecase 7: never executed: 6:case 6: never executed: case 6: code before this statement never executed: tin1|=((unsigned long)(*(--(in))))<< 8L; casecase 6: never executed: 5:case 5: never executed: case 5: code before this statement never executed: tin1|=((unsigned long)(*(--(in)))); casecase 5: never executed: 4:case 4: never executed: case 4: code before this statement never executed: tin0 =((unsigned long)(*(--(in))))<<24L; casecase 4: never executed: 3:case 3: never executed: case 3: code before this statement never executed: tin0|=((unsigned long)(*(--(in))))<<16L; casecase 3: never executed: 2:case 2: never executed: case 2: code before this statement never executed: tin0|=((unsigned long)(*(--(in))))<< 8L; casecase 2: never executed: 1:case 1: never executed: case 1: code before this statement never executed: tin0|=((unsigned long)(*(--(in)))); }case 1: never executed: };end of block | 0 | ||||||||||||
29 | tin0 ^= tout0; | - | ||||||||||||
30 | tin1 ^= tout1; | - | ||||||||||||
31 | tin[0] = tin0; | - | ||||||||||||
32 | tin[1] = tin1; | - | ||||||||||||
33 | RC2_encrypt(tin, ks); | - | ||||||||||||
34 | tout0 = tin[0]; | - | ||||||||||||
35 | (*((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]; | - | ||||||||||||
37 | (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff)); | - | ||||||||||||
38 | } never executed: end of block | 0 | ||||||||||||
39 | (*((iv)++)=(unsigned char)(((tout0) )&0xff), *((iv)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((tout0)>>16L)&0xff), *((iv)++)=(unsigned char)(((tout0)>>24L)&0xff)); | - | ||||||||||||
40 | (*((iv)++)=(unsigned char)(((tout1) )&0xff), *((iv)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((tout1)>>16L)&0xff), *((iv)++)=(unsigned char)(((tout1)>>24L)&0xff)); | - | ||||||||||||
41 | } executed 314 times by 1 test: else {end of block Executed by:
| 314 | ||||||||||||
42 | (xor0 =((unsigned long)(*((iv)++))) , xor0|=((unsigned long)(*((iv)++)))<< 8L, xor0|=((unsigned long)(*((iv)++)))<<16L, xor0|=((unsigned long)(*((iv)++)))<<24L); | - | ||||||||||||
43 | (xor1 =((unsigned long)(*((iv)++))) , xor1|=((unsigned long)(*((iv)++)))<< 8L, xor1|=((unsigned long)(*((iv)++)))<<16L, xor1|=((unsigned long)(*((iv)++)))<<24L); | - | ||||||||||||
44 | iv -= 8; | - | ||||||||||||
45 | for (l -= 8; l >= 0
| 217-3904 | ||||||||||||
46 | (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
47 | tin[0] = tin0; | - | ||||||||||||
48 | (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
49 | 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 3904 times by 1 test: end of block Executed by:
| 3904 | ||||||||||||
58 | if (l != -8
| 0-217 | ||||||||||||
59 | (tin0 =((unsigned long)(*((in)++))) , tin0|=((unsigned long)(*((in)++)))<< 8L, tin0|=((unsigned long)(*((in)++)))<<16L, tin0|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
60 | tin[0] = tin0; | - | ||||||||||||
61 | (tin1 =((unsigned long)(*((in)++))) , tin1|=((unsigned long)(*((in)++)))<< 8L, tin1|=((unsigned long)(*((in)++)))<<16L, tin1|=((unsigned long)(*((in)++)))<<24L); | - | ||||||||||||
62 | tin[1] = tin1; | - | ||||||||||||
63 | RC2_decrypt(tin, ks); | - | ||||||||||||
64 | tout0 = tin[0] ^ xor0; | - | ||||||||||||
65 | tout1 = tin[1] ^ xor1; | - | ||||||||||||
66 | { out+=l + 8; switch (l + 8) { case never executed: 8:case 8: never executed: *(--(out))=(unsigned char)(((tout1)>>24L)&0xff); casecase 8: never executed: 7:case 7: never executed: case 7: code before this statement never executed: *(--(out))=(unsigned char)(((tout1)>>16L)&0xff); casecase 7: never executed: 6:case 6: never executed: case 6: code before this statement never executed: *(--(out))=(unsigned char)(((tout1)>> 8L)&0xff); casecase 6: never executed: 5:case 5: never executed: case 5: code before this statement never executed: *(--(out))=(unsigned char)(((tout1) )&0xff); casecase 5: never executed: 4:case 4: never executed: case 4: code before this statement never executed: *(--(out))=(unsigned char)(((tout0)>>24L)&0xff); casecase 4: never executed: 3:case 3: never executed: case 3: code before this statement never executed: *(--(out))=(unsigned char)(((tout0)>>16L)&0xff); casecase 3: never executed: 2:case 2: never executed: case 2: code before this statement never executed: *(--(out))=(unsigned char)(((tout0)>> 8L)&0xff); casecase 2: never executed: 1:case 1: never executed: case 1: code before this statement never executed: *(--(out))=(unsigned char)(((tout0) )&0xff); }case 1: never executed: };end of block | 0 | ||||||||||||
67 | xor0 = tin0; | - | ||||||||||||
68 | xor1 = tin1; | - | ||||||||||||
69 | } never executed: end of block | 0 | ||||||||||||
70 | (*((iv)++)=(unsigned char)(((xor0) )&0xff), *((iv)++)=(unsigned char)(((xor0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((xor0)>>16L)&0xff), *((iv)++)=(unsigned char)(((xor0)>>24L)&0xff)); | - | ||||||||||||
71 | (*((iv)++)=(unsigned char)(((xor1) )&0xff), *((iv)++)=(unsigned char)(((xor1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((xor1)>>16L)&0xff), *((iv)++)=(unsigned char)(((xor1)>>24L)&0xff)); | - | ||||||||||||
72 | } executed 217 times by 1 test: end of block Executed by:
| 217 | ||||||||||||
73 | tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; | - | ||||||||||||
74 | tin[0] = tin[1] = 0; | - | ||||||||||||
75 | } executed 531 times by 1 test: end of block Executed by:
| 531 | ||||||||||||
76 | - | |||||||||||||
77 | void RC2_encrypt(unsigned long *d, RC2_KEY *key) | - | ||||||||||||
78 | { | - | ||||||||||||
79 | int i, n; | - | ||||||||||||
80 | register RC2_INT *p0, *p1; | - | ||||||||||||
81 | register RC2_INT x0, x1, x2, x3, t; | - | ||||||||||||
82 | unsigned long l; | - | ||||||||||||
83 | - | |||||||||||||
84 | l = d[0]; | - | ||||||||||||
85 | x0 = (RC2_INT) l & 0xffff; | - | ||||||||||||
86 | x1 = (RC2_INT) (l >> 16L); | - | ||||||||||||
87 | l = d[1]; | - | ||||||||||||
88 | x2 = (RC2_INT) l & 0xffff; | - | ||||||||||||
89 | x3 = (RC2_INT) (l >> 16L); | - | ||||||||||||
90 | - | |||||||||||||
91 | n = 3; | - | ||||||||||||
92 | i = 5; | - | ||||||||||||
93 | - | |||||||||||||
94 | p0 = p1 = &(key->data[0]); | - | ||||||||||||
95 | for (;;) { | - | ||||||||||||
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 (--
| 23502-101842 | ||||||||||||
106 | if (--
| 7834-15668 | ||||||||||||
107 | break; executed 7834 times by 1 test: break; Executed by:
| 7834 | ||||||||||||
108 | i = (
| 7834 | ||||||||||||
109 | - | |||||||||||||
110 | x0 += p1[x3 & 0x3f]; | - | ||||||||||||
111 | x1 += p1[x0 & 0x3f]; | - | ||||||||||||
112 | x2 += p1[x1 & 0x3f]; | - | ||||||||||||
113 | x3 += p1[x2 & 0x3f]; | - | ||||||||||||
114 | } executed 15668 times by 1 test: end of block Executed by:
| 15668 | ||||||||||||
115 | } executed 117510 times by 1 test: end of block Executed by:
| 117510 | ||||||||||||
116 | - | |||||||||||||
117 | d[0] = | - | ||||||||||||
118 | (unsigned long)(x0 & 0xffff) | ((unsigned long)(x1 & 0xffff) << 16L); | - | ||||||||||||
119 | d[1] = | - | ||||||||||||
120 | (unsigned long)(x2 & 0xffff) | ((unsigned long)(x3 & 0xffff) << 16L); | - | ||||||||||||
121 | } executed 7834 times by 1 test: end of block Executed by:
| 7834 | ||||||||||||
122 | - | |||||||||||||
123 | void RC2_decrypt(unsigned long *d, RC2_KEY *key) | - | ||||||||||||
124 | { | - | ||||||||||||
125 | int i, n; | - | ||||||||||||
126 | register RC2_INT *p0, *p1; | - | ||||||||||||
127 | register RC2_INT x0, x1, x2, x3, t; | - | ||||||||||||
128 | unsigned long l; | - | ||||||||||||
129 | - | |||||||||||||
130 | l = d[0]; | - | ||||||||||||
131 | x0 = (RC2_INT) l & 0xffff; | - | ||||||||||||
132 | x1 = (RC2_INT) (l >> 16L); | - | ||||||||||||
133 | l = d[1]; | - | ||||||||||||
134 | x2 = (RC2_INT) l & 0xffff; | - | ||||||||||||
135 | x3 = (RC2_INT) (l >> 16L); | - | ||||||||||||
136 | - | |||||||||||||
137 | n = 3; | - | ||||||||||||
138 | i = 5; | - | ||||||||||||
139 | - | |||||||||||||
140 | p0 = &(key->data[63]); | - | ||||||||||||
141 | p1 = &(key->data[0]); | - | ||||||||||||
142 | for (;;) { | - | ||||||||||||
143 | t = ((x3 << 11) | (x3 >> 5)) & 0xffff; | - | ||||||||||||
144 | x3 = (t - (x0 & ~x2) - (x1 & x2) - *(p0--)) & 0xffff; | - | ||||||||||||
145 | t = ((x2 << 13) | (x2 >> 3)) & 0xffff; | - | ||||||||||||
146 | x2 = (t - (x3 & ~x1) - (x0 & x1) - *(p0--)) & 0xffff; | - | ||||||||||||
147 | t = ((x1 << 14) | (x1 >> 2)) & 0xffff; | - | ||||||||||||
148 | x1 = (t - (x2 & ~x0) - (x3 & x0) - *(p0--)) & 0xffff; | - | ||||||||||||
149 | t = ((x0 << 15) | (x0 >> 1)) & 0xffff; | - | ||||||||||||
150 | x0 = (t - (x1 & ~x3) - (x2 & x3) - *(p0--)) & 0xffff; | - | ||||||||||||
151 | - | |||||||||||||
152 | if (--
| 14082-61022 | ||||||||||||
153 | if (--
| 4694-9388 | ||||||||||||
154 | break; executed 4694 times by 1 test: break; Executed by:
| 4694 | ||||||||||||
155 | i = (
| 4694 | ||||||||||||
156 | - | |||||||||||||
157 | x3 = (x3 - p1[x2 & 0x3f]) & 0xffff; | - | ||||||||||||
158 | x2 = (x2 - p1[x1 & 0x3f]) & 0xffff; | - | ||||||||||||
159 | x1 = (x1 - p1[x0 & 0x3f]) & 0xffff; | - | ||||||||||||
160 | x0 = (x0 - p1[x3 & 0x3f]) & 0xffff; | - | ||||||||||||
161 | } executed 9388 times by 1 test: end of block Executed by:
| 9388 | ||||||||||||
162 | } executed 70410 times by 1 test: end of block Executed by:
| 70410 | ||||||||||||
163 | - | |||||||||||||
164 | d[0] = | - | ||||||||||||
165 | (unsigned long)(x0 & 0xffff) | ((unsigned long)(x1 & 0xffff) << 16L); | - | ||||||||||||
166 | d[1] = | - | ||||||||||||
167 | (unsigned long)(x2 & 0xffff) | ((unsigned long)(x3 & 0xffff) << 16L); | - | ||||||||||||
168 | } executed 4694 times by 1 test: end of block Executed by:
| 4694 | ||||||||||||
Switch to Source code | Preprocessed file |