OpenCoverage

rc2_cbc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/rc2/rc2_cbc.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <openssl/rc2.h>-
11#include "rc2_locl.h"-
12-
13void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,-
14 RC2_KEY *ks, unsigned char *iv, int encrypt)-
15{-
16 register unsigned long tin0, tin1;-
17 register unsigned long tout0, tout1, xor0, xor1;-
18 register long l = length;-
19 unsigned long tin[2];-
20-
21 if (encrypt) {
encryptDescription
TRUEevaluated 314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-314
22 c2l(iv, tout0);-
23 c2l(iv, tout1);-
24 iv -= 8;-
25 for (l -= 8; l >= 0; l -= 8) {
l >= 0Description
TRUEevaluated 3904 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
314-3904
26 c2l(in, tin0);-
27 c2l(in, tin1);-
28 tin0 ^= tout0;-
29 tin1 ^= tout1;-
30 tin[0] = tin0;-
31 tin[1] = tin1;-
32 RC2_encrypt(tin, ks);-
33 tout0 = tin[0];-
34 l2c(tout0, out);-
35 tout1 = tin[1];-
36 l2c(tout1, out);-
37 }
executed 3904 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3904
38 if (l != -8) {
l != -8Description
TRUEnever evaluated
FALSEevaluated 314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-314
39 c2ln(in, tin0, tin1, l + 8);
never executed: end of block
code before this statement never executed: case 7:
code before this statement never executed: case 6:
code before this statement never executed: case 5:
code before this statement never executed: case 4:
code before this statement never executed: case 3:
code before this statement never executed: case 2:
code before this statement never executed: case 1:
never executed: case 8:
never executed: case 7:
never executed: case 6:
never executed: case 5:
never executed: case 4:
never executed: case 3:
never executed: case 2:
never executed: case 1:
0
40 tin0 ^= tout0;-
41 tin1 ^= tout1;-
42 tin[0] = tin0;-
43 tin[1] = tin1;-
44 RC2_encrypt(tin, ks);-
45 tout0 = tin[0];-
46 l2c(tout0, out);-
47 tout1 = tin[1];-
48 l2c(tout1, out);-
49 }
never executed: end of block
0
50 l2c(tout0, iv);-
51 l2c(tout1, iv);-
52 } else {
executed 314 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
314
53 c2l(iv, xor0);-
54 c2l(iv, xor1);-
55 iv -= 8;-
56 for (l -= 8; l >= 0; l -= 8) {
l >= 0Description
TRUEevaluated 3904 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-3904
57 c2l(in, tin0);-
58 tin[0] = tin0;-
59 c2l(in, tin1);-
60 tin[1] = tin1;-
61 RC2_decrypt(tin, ks);-
62 tout0 = tin[0] ^ xor0;-
63 tout1 = tin[1] ^ xor1;-
64 l2c(tout0, out);-
65 l2c(tout1, out);-
66 xor0 = tin0;-
67 xor1 = tin1;-
68 }
executed 3904 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3904
69 if (l != -8) {
l != -8Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-217
70 c2l(in, tin0);-
71 tin[0] = tin0;-
72 c2l(in, tin1);-
73 tin[1] = tin1;-
74 RC2_decrypt(tin, ks);-
75 tout0 = tin[0] ^ xor0;-
76 tout1 = tin[1] ^ xor1;-
77 l2cn(tout0, tout1, out, l + 8);
never executed: end of block
code before this statement never executed: case 7:
code before this statement never executed: case 6:
code before this statement never executed: case 5:
code before this statement never executed: case 4:
code before this statement never executed: case 3:
code before this statement never executed: case 2:
code before this statement never executed: case 1:
never executed: case 8:
never executed: case 7:
never executed: case 6:
never executed: case 5:
never executed: case 4:
never executed: case 3:
never executed: case 2:
never executed: case 1:
0
78 xor0 = tin0;-
79 xor1 = tin1;-
80 }
never executed: end of block
0
81 l2c(xor0, iv);-
82 l2c(xor1, iv);-
83 }
executed 217 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
217
84 tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0;-
85 tin[0] = tin[1] = 0;-
86}
executed 531 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
531
87-
88void RC2_encrypt(unsigned long *d, RC2_KEY *key)-
89{-
90 int i, n;-
91 register RC2_INT *p0, *p1;-
92 register RC2_INT x0, x1, x2, x3, t;-
93 unsigned long l;-
94-
95 l = d[0];-
96 x0 = (RC2_INT) l & 0xffff;-
97 x1 = (RC2_INT) (l >> 16L);-
98 l = d[1];-
99 x2 = (RC2_INT) l & 0xffff;-
100 x3 = (RC2_INT) (l >> 16L);-
101-
102 n = 3;-
103 i = 5;-
104-
105 p0 = p1 = &(key->data[0]);-
106 for (;;) {-
107 t = (x0 + (x1 & ~x3) + (x2 & x3) + *(p0++)) & 0xffff;-
108 x0 = (t << 1) | (t >> 15);-
109 t = (x1 + (x2 & ~x0) + (x3 & x0) + *(p0++)) & 0xffff;-
110 x1 = (t << 2) | (t >> 14);-
111 t = (x2 + (x3 & ~x1) + (x0 & x1) + *(p0++)) & 0xffff;-
112 x2 = (t << 3) | (t >> 13);-
113 t = (x3 + (x0 & ~x2) + (x1 & x2) + *(p0++)) & 0xffff;-
114 x3 = (t << 5) | (t >> 11);-
115-
116 if (--i == 0) {
--i == 0Description
TRUEevaluated 23502 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 101842 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
23502-101842
117 if (--n == 0)
--n == 0Description
TRUEevaluated 7834 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 15668 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7834-15668
118 break;
executed 7834 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
7834
119 i = (n == 2) ? 6 : 5;
(n == 2)Description
TRUEevaluated 7834 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7834 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7834
120-
121 x0 += p1[x3 & 0x3f];-
122 x1 += p1[x0 & 0x3f];-
123 x2 += p1[x1 & 0x3f];-
124 x3 += p1[x2 & 0x3f];-
125 }
executed 15668 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
15668
126 }
executed 117510 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
117510
127-
128 d[0] =-
129 (unsigned long)(x0 & 0xffff) | ((unsigned long)(x1 & 0xffff) << 16L);-
130 d[1] =-
131 (unsigned long)(x2 & 0xffff) | ((unsigned long)(x3 & 0xffff) << 16L);-
132}
executed 7834 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7834
133-
134void RC2_decrypt(unsigned long *d, RC2_KEY *key)-
135{-
136 int i, n;-
137 register RC2_INT *p0, *p1;-
138 register RC2_INT x0, x1, x2, x3, t;-
139 unsigned long l;-
140-
141 l = d[0];-
142 x0 = (RC2_INT) l & 0xffff;-
143 x1 = (RC2_INT) (l >> 16L);-
144 l = d[1];-
145 x2 = (RC2_INT) l & 0xffff;-
146 x3 = (RC2_INT) (l >> 16L);-
147-
148 n = 3;-
149 i = 5;-
150-
151 p0 = &(key->data[63]);-
152 p1 = &(key->data[0]);-
153 for (;;) {-
154 t = ((x3 << 11) | (x3 >> 5)) & 0xffff;-
155 x3 = (t - (x0 & ~x2) - (x1 & x2) - *(p0--)) & 0xffff;-
156 t = ((x2 << 13) | (x2 >> 3)) & 0xffff;-
157 x2 = (t - (x3 & ~x1) - (x0 & x1) - *(p0--)) & 0xffff;-
158 t = ((x1 << 14) | (x1 >> 2)) & 0xffff;-
159 x1 = (t - (x2 & ~x0) - (x3 & x0) - *(p0--)) & 0xffff;-
160 t = ((x0 << 15) | (x0 >> 1)) & 0xffff;-
161 x0 = (t - (x1 & ~x3) - (x2 & x3) - *(p0--)) & 0xffff;-
162-
163 if (--i == 0) {
--i == 0Description
TRUEevaluated 14082 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 61022 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14082-61022
164 if (--n == 0)
--n == 0Description
TRUEevaluated 4694 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9388 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4694-9388
165 break;
executed 4694 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
4694
166 i = (n == 2) ? 6 : 5;
(n == 2)Description
TRUEevaluated 4694 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4694 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4694
167-
168 x3 = (x3 - p1[x2 & 0x3f]) & 0xffff;-
169 x2 = (x2 - p1[x1 & 0x3f]) & 0xffff;-
170 x1 = (x1 - p1[x0 & 0x3f]) & 0xffff;-
171 x0 = (x0 - p1[x3 & 0x3f]) & 0xffff;-
172 }
executed 9388 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
9388
173 }
executed 70410 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
70410
174-
175 d[0] =-
176 (unsigned long)(x0 & 0xffff) | ((unsigned long)(x1 & 0xffff) << 16L);-
177 d[1] =-
178 (unsigned long)(x2 & 0xffff) | ((unsigned long)(x3 & 0xffff) << 16L);-
179}
executed 4694 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4694
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2