OpenCoverage

cfb64ede.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/des/cfb64ede.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2017 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 "des_locl.h"-
11-
12/*-
13 * The input and output encrypted as though 64bit cfb mode is being used.-
14 * The extra state information to record how much of the 64bit block we have-
15 * used is contained in *num;-
16 */-
17-
18void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,-
19 long length, DES_key_schedule *ks1,-
20 DES_key_schedule *ks2, DES_key_schedule *ks3,-
21 DES_cblock *ivec, int *num, int enc)-
22{-
23 register DES_LONG v0, v1;-
24 register long l = length;-
25 register int n = *num;-
26 DES_LONG ti[2];-
27 unsigned char *iv, c, cc;-
28-
29 iv = &(*ivec)[0];-
30 if (enc) {
encDescription
TRUEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 60 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
60-84
31 while (l--) {
l--Description
TRUEevaluated 12580 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
84-12580
32 if (n == 0) {
n == 0Description
TRUEevaluated 1573 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1573-11007
33 c2l(iv, v0);-
34 c2l(iv, v1);-
35-
36 ti[0] = v0;-
37 ti[1] = v1;-
38 DES_encrypt3(ti, ks1, ks2, ks3);-
39 v0 = ti[0];-
40 v1 = ti[1];-
41-
42 iv = &(*ivec)[0];-
43 l2c(v0, iv);-
44 l2c(v1, iv);-
45 iv = &(*ivec)[0];-
46 }
executed 1573 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1573
47 c = *(in++) ^ iv[n];-
48 *(out++) = c;-
49 iv[n] = c;-
50 n = (n + 1) & 0x07;-
51 }
executed 12580 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12580
52 } else {
executed 84 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
84
53 while (l--) {
l--Description
TRUEevaluated 12580 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 60 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
60-12580
54 if (n == 0) {
n == 0Description
TRUEevaluated 1573 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1573-11007
55 c2l(iv, v0);-
56 c2l(iv, v1);-
57-
58 ti[0] = v0;-
59 ti[1] = v1;-
60 DES_encrypt3(ti, ks1, ks2, ks3);-
61 v0 = ti[0];-
62 v1 = ti[1];-
63-
64 iv = &(*ivec)[0];-
65 l2c(v0, iv);-
66 l2c(v1, iv);-
67 iv = &(*ivec)[0];-
68 }
executed 1573 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1573
69 cc = *(in++);-
70 c = iv[n];-
71 iv[n] = cc;-
72 *(out++) = c ^ cc;-
73 n = (n + 1) & 0x07;-
74 }
executed 12580 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12580
75 }
executed 60 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
60
76 v0 = v1 = ti[0] = ti[1] = c = cc = 0;-
77 *num = n;-
78}
executed 144 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
144
79-
80/*-
81 * This is compatible with the single key CFB-r for DES, even thought that's-
82 * not what EVP needs.-
83 */-
84-
85void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,-
86 int numbits, long length, DES_key_schedule *ks1,-
87 DES_key_schedule *ks2, DES_key_schedule *ks3,-
88 DES_cblock *ivec, int enc)-
89{-
90 register DES_LONG d0, d1, v0, v1;-
91 register unsigned long l = length, n = ((unsigned int)numbits + 7) / 8;-
92 register int num = numbits, i;-
93 DES_LONG ti[2];-
94 unsigned char *iv;-
95 unsigned char ovec[16];-
96-
97 if (num > 64)
num > 64Description
TRUEnever evaluated
FALSEevaluated 34530 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-34530
98 return;
never executed: return;
0
99 iv = &(*ivec)[0];-
100 c2l(iv, v0);-
101 c2l(iv, v1);-
102 if (enc) {
encDescription
TRUEevaluated 16737 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17793 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16737-17793
103 while (l >= n) {
l >= nDescription
TRUEevaluated 18696 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16737 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16737-18696
104 l -= n;-
105 ti[0] = v0;-
106 ti[1] = v1;-
107 DES_encrypt3(ti, ks1, ks2, ks3);-
108 c2ln(in, d0, d1, n);
executed 18696 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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:
executed 18696 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
0-18696
109 in += n;-
110 d0 ^= ti[0];-
111 d1 ^= ti[1];-
112 l2cn(d0, d1, out, n);
executed 18696 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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:
executed 18696 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
0-18696
113 out += n;-
114 /*-
115 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under-
116 * gcc :-(-
117 */-
118 if (num == 32) {
num == 32Description
TRUEnever evaluated
FALSEevaluated 18696 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-18696
119 v0 = v1;-
120 v1 = d0;-
121 } else if (num == 64) {
never executed: end of block
num == 64Description
TRUEnever evaluated
FALSEevaluated 18696 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-18696
122 v0 = d0;-
123 v1 = d1;-
124 } else {
never executed: end of block
0
125 iv = &ovec[0];-
126 l2c(v0, iv);-
127 l2c(v1, iv);-
128 l2c(d0, iv);-
129 l2c(d1, iv);-
130 /* shift ovec left most of the bits... */-
131 memmove(ovec, ovec + num / 8, 8 + (num % 8 ? 1 : 0));-
132 /* now the remaining bits */-
133 if (num % 8 != 0)
num % 8 != 0Description
TRUEevaluated 16736 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1960 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1960-16736
134 for (i = 0; i < 8; ++i) {
i < 8Description
TRUEevaluated 133888 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16736 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16736-133888
135 ovec[i] <<= num % 8;-
136 ovec[i] |= ovec[i + 1] >> (8 - num % 8);-
137 }
executed 133888 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
133888
138 iv = &ovec[0];-
139 c2l(iv, v0);-
140 c2l(iv, v1);-
141 }
executed 18696 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18696
142 }-
143 } else {
executed 16737 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
16737
144 while (l >= n) {
l >= nDescription
TRUEevaluated 19752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17793 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17793-19752
145 l -= n;-
146 ti[0] = v0;-
147 ti[1] = v1;-
148 DES_encrypt3(ti, ks1, ks2, ks3);-
149 c2ln(in, d0, d1, n);
executed 19752 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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:
executed 19752 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
0-19752
150 in += n;-
151 /*-
152 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under-
153 * gcc :-(-
154 */-
155 if (num == 32) {
num == 32Description
TRUEnever evaluated
FALSEevaluated 19752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-19752
156 v0 = v1;-
157 v1 = d0;-
158 } else if (num == 64) {
never executed: end of block
num == 64Description
TRUEnever evaluated
FALSEevaluated 19752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-19752
159 v0 = d0;-
160 v1 = d1;-
161 } else {
never executed: end of block
0
162 iv = &ovec[0];-
163 l2c(v0, iv);-
164 l2c(v1, iv);-
165 l2c(d0, iv);-
166 l2c(d1, iv);-
167 /* shift ovec left most of the bits... */-
168 memmove(ovec, ovec + num / 8, 8 + (num % 8 ? 1 : 0));-
169 /* now the remaining bits */-
170 if (num % 8 != 0)
num % 8 != 0Description
TRUEevaluated 17792 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1960 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1960-17792
171 for (i = 0; i < 8; ++i) {
i < 8Description
TRUEevaluated 142336 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17792 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17792-142336
172 ovec[i] <<= num % 8;-
173 ovec[i] |= ovec[i + 1] >> (8 - num % 8);-
174 }
executed 142336 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
142336
175 iv = &ovec[0];-
176 c2l(iv, v0);-
177 c2l(iv, v1);-
178 }
executed 19752 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
19752
179 d0 ^= ti[0];-
180 d1 ^= ti[1];-
181 l2cn(d0, d1, out, n);
executed 19752 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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:
executed 19752 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
0-19752
182 out += n;-
183 }
executed 19752 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
19752
184 }
executed 17793 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
17793
185 iv = &(*ivec)[0];-
186 l2c(v0, iv);-
187 l2c(v1, iv);-
188 v0 = v1 = d0 = d1 = ti[0] = ti[1] = 0;-
189}
executed 34530 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34530
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2