OpenCoverage

e_des.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/e_des.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4typedef struct {-
5 union {-
6 double align;-
7 DES_key_schedule ks;-
8 } ks;-
9 union {-
10 void (*cbc) (const void *, void *, size_t,-
11 const DES_key_schedule *, unsigned char *);-
12 } stream;-
13} EVP_DES_KEY;-
14static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,-
15 const unsigned char *iv, int enc);-
16static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);-
17-
18-
19-
20-
21-
22-
23static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
24 const unsigned char *in, size_t inl)-
25{-
26 size_t i, bl; bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; if (inl < bl
inl < blDescription
TRUEnever evaluated
FALSEevaluated 297 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) return
never executed: return 1;
1;
never executed: return 1;
inl -= bl; for (i=0; i <= inl
i <= inlDescription
TRUEevaluated 1740 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 297 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i+=bl)
0-1740
27 DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i),
executed 1740 times by 1 test: DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), EVP_CIPHER_CTX_get_cipher_data(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
1740
28 EVP_CIPHER_CTX_get_cipher_data(ctx),
executed 1740 times by 1 test: DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), EVP_CIPHER_CTX_get_cipher_data(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
1740
29 EVP_CIPHER_CTX_encrypting(ctx));
executed 1740 times by 1 test: DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), EVP_CIPHER_CTX_get_cipher_data(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
1740
30 return
executed 297 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 297 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
297
31}-
32-
33static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
34 const unsigned char *in, size_t inl)-
35{-
36 while (inl >= ((size_t)1<<(sizeof(long)*8-2))
inl >= ((size_...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-70
37 int num = EVP_CIPHER_CTX_num(ctx);-
38 DES_ofb64_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)),-
39 EVP_CIPHER_CTX_get_cipher_data(ctx),-
40 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &num);-
41 EVP_CIPHER_CTX_set_num(ctx, num);-
42 inl -= ((size_t)1<<(sizeof(long)*8-2));-
43 in += ((size_t)1<<(sizeof(long)*8-2));-
44 out += ((size_t)1<<(sizeof(long)*8-2));-
45 }
never executed: end of block
0
46 if (inl
inlDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-70
47 int num = EVP_CIPHER_CTX_num(ctx);-
48 DES_ofb64_encrypt(in, out, (long)inl,-
49 EVP_CIPHER_CTX_get_cipher_data(ctx),-
50 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &num);-
51 EVP_CIPHER_CTX_set_num(ctx, num);-
52 }
executed 70 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
70
53 return
executed 70 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 70 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
70
54}-
55-
56static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
57 const unsigned char *in, size_t inl)-
58{-
59 EVP_DES_KEY *dat = (EVP_DES_KEY *) EVP_CIPHER_CTX_get_cipher_data(ctx);-
60-
61 if (dat->stream.cbc !=
dat->stream.cbc != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-258
62 ((void *)0)
dat->stream.cbc != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-258
63 ) {-
64 (*dat->stream.cbc) (in, out, inl, &dat->ks.ks,-
65 EVP_CIPHER_CTX_iv_noconst(ctx));-
66 return
never executed: return 1;
1;
never executed: return 1;
0
67 }-
68 while (inl >= ((size_t)1<<(sizeof(long)*8-2))
inl >= ((size_...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-258
69 DES_ncbc_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)),-
70 EVP_CIPHER_CTX_get_cipher_data(ctx),-
71 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx),-
72 EVP_CIPHER_CTX_encrypting(ctx));-
73 inl -= ((size_t)1<<(sizeof(long)*8-2));-
74 in += ((size_t)1<<(sizeof(long)*8-2));-
75 out += ((size_t)1<<(sizeof(long)*8-2));-
76 }
never executed: end of block
0
77 if (inl
inlDescription
TRUEevaluated 258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-258
78 DES_ncbc_encrypt(in, out, (long)inl,
executed 258 times by 1 test: DES_ncbc_encrypt(in, out, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
258
79 EVP_CIPHER_CTX_get_cipher_data(ctx),
executed 258 times by 1 test: DES_ncbc_encrypt(in, out, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
258
80 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx),
executed 258 times by 1 test: DES_ncbc_encrypt(in, out, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
258
81 EVP_CIPHER_CTX_encrypting(ctx));
executed 258 times by 1 test: DES_ncbc_encrypt(in, out, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
258
82 return
executed 258 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 258 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
258
83}-
84-
85static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
86 const unsigned char *in, size_t inl)-
87{-
88 while (inl >= ((size_t)1<<(sizeof(long)*8-2))
inl >= ((size_...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-70
89 int num = EVP_CIPHER_CTX_num(ctx);-
90 DES_cfb64_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)),-
91 EVP_CIPHER_CTX_get_cipher_data(ctx),-
92 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &num,-
93 EVP_CIPHER_CTX_encrypting(ctx));-
94 EVP_CIPHER_CTX_set_num(ctx, num);-
95 inl -= ((size_t)1<<(sizeof(long)*8-2));-
96 in += ((size_t)1<<(sizeof(long)*8-2));-
97 out += ((size_t)1<<(sizeof(long)*8-2));-
98 }
never executed: end of block
0
99 if (inl
inlDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-70
100 int num = EVP_CIPHER_CTX_num(ctx);-
101 DES_cfb64_encrypt(in, out, (long)inl,-
102 EVP_CIPHER_CTX_get_cipher_data(ctx),-
103 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), &num,-
104 EVP_CIPHER_CTX_encrypting(ctx));-
105 EVP_CIPHER_CTX_set_num(ctx, num);-
106 }
executed 70 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
70
107 return
executed 70 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 70 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
70
108}-
109-
110-
111-
112-
113-
114static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
115 const unsigned char *in, size_t inl)-
116{-
117 size_t n, chunk = ((size_t)1<<(sizeof(long)*8-2)) / 8;-
118 unsigned char c[1], d[1];-
119-
120 if (inl < chunk
inl < chunkDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-2
121 chunk = inl;
executed 2 times by 1 test: chunk = inl;
Executed by:
  • libcrypto.so.1.1
2
122-
123 while (inl
inlDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& inl >= chunk
inl >= chunkDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-2
124 for (n = 0; n < chunk * 8
n < chunk * 8Description
TRUEevaluated 31360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; ++n) {
2-31360
125 c[0] = (
(in[n / 8] & (... (7 - n % 8)))Description
TRUEevaluated 14277 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17083 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
in[n / 8] & (1 << (7 - n % 8)))
(in[n / 8] & (... (7 - n % 8)))Description
TRUEevaluated 14277 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17083 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
? 0x80 : 0;
14277-17083
126 DES_cfb_encrypt(c, d, 1, 1, EVP_CIPHER_CTX_get_cipher_data(ctx),-
127 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx),-
128 EVP_CIPHER_CTX_encrypting(ctx));-
129 out[n / 8] =-
130 (out[n / 8] & ~(0x80 >> (unsigned int)(n % 8))) |-
131 ((d[0] & 0x80) >> (unsigned int)(n % 8));-
132 }
executed 31360 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
31360
133 inl -= chunk;-
134 in += chunk;-
135 out += chunk;-
136 if (inl < chunk
inl < chunkDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-2
137 chunk = inl;
executed 2 times by 1 test: chunk = inl;
Executed by:
  • libcrypto.so.1.1
2
138 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
139-
140 return
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2
141}-
142-
143static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,-
144 const unsigned char *in, size_t inl)-
145{-
146 while (inl >= ((size_t)1<<(sizeof(long)*8-2))
inl >= ((size_...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-2
147 DES_cfb_encrypt(in, out, 8, (long)((size_t)1<<(sizeof(long)*8-2)),-
148 EVP_CIPHER_CTX_get_cipher_data(ctx),-
149 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx),-
150 EVP_CIPHER_CTX_encrypting(ctx));-
151 inl -= ((size_t)1<<(sizeof(long)*8-2));-
152 in += ((size_t)1<<(sizeof(long)*8-2));-
153 out += ((size_t)1<<(sizeof(long)*8-2));-
154 }
never executed: end of block
0
155 if (inl
inlDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-2
156 DES_cfb_encrypt(in, out, 8, (long)inl,
executed 2 times by 1 test: DES_cfb_encrypt(in, out, 8, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
2
157 EVP_CIPHER_CTX_get_cipher_data(ctx),
executed 2 times by 1 test: DES_cfb_encrypt(in, out, 8, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
2
158 (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx),
executed 2 times by 1 test: DES_cfb_encrypt(in, out, 8, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
2
159 EVP_CIPHER_CTX_encrypting(ctx));
executed 2 times by 1 test: DES_cfb_encrypt(in, out, 8, (long)inl, EVP_CIPHER_CTX_get_cipher_data(ctx), (DES_cblock *)EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
2
160 return
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2
161}-
162-
163static const EVP_CIPHER des_cbc = { 31, 8, 8, 8, 0x200 | 0x2, des_init_key, des_cbc_cipher, -
164((void *)0)-
165, sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
166((void *)0) -
167}; const EVP_CIPHER *EVP_des_cbc(void) { return
executed 3920 times by 1 test: return &des_cbc;
Executed by:
  • libcrypto.so.1.1
&des_cbc;
executed 3920 times by 1 test: return &des_cbc;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER des_cfb64 = { 30, 1, 8, 8, 0x200 | 0x3, des_init_key, des_cfb64_cipher,
3920
168((void *)0)-
169, sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
170((void *)0) -
171}; const EVP_CIPHER *EVP_des_cfb64(void) { return
executed 1962 times by 1 test: return &des_cfb64;
Executed by:
  • libcrypto.so.1.1
&des_cfb64;
executed 1962 times by 1 test: return &des_cfb64;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER des_ofb = { 45, 1, 8, 8, 0x200 | 0x4, des_init_key, des_ofb_cipher,
1962
172((void *)0)-
173, sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
174((void *)0) -
175}; const EVP_CIPHER *EVP_des_ofb(void) { return
executed 1962 times by 1 test: return &des_ofb;
Executed by:
  • libcrypto.so.1.1
&des_ofb;
executed 1962 times by 1 test: return &des_ofb;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER des_ecb = { 29, 8, 8, 0, 0x200 | 0x1, des_init_key, des_ecb_cipher,
1962
176((void *)0)-
177, sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
178((void *)0) -
179}; const EVP_CIPHER *EVP_des_ecb(void) { return
executed 1962 times by 1 test: return &des_ecb;
Executed by:
  • libcrypto.so.1.1
&des_ecb;
executed 1962 times by 1 test: return &des_ecb;
Executed by:
  • libcrypto.so.1.1
}
1962
180-
181-
182-
183 static const EVP_CIPHER des_cfb1 = { 656, 1, 8, 8, 0x200 | 0x3, des_init_key, des_cfb1_cipher, -
184 ((void *)0)-
185 , sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
186 ((void *)0) -
187 }; const EVP_CIPHER *EVP_des_cfb1(void) { return
executed 1962 times by 1 test: return &des_cfb1;
Executed by:
  • libcrypto.so.1.1
&des_cfb1;
executed 1962 times by 1 test: return &des_cfb1;
Executed by:
  • libcrypto.so.1.1
}
1962
188-
189-
190-
191 static const EVP_CIPHER des_cfb8 = { 657, 1, 8, 8, 0x200 | 0x3, des_init_key, des_cfb8_cipher, -
192 ((void *)0)-
193 , sizeof(EVP_DES_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl, -
194 ((void *)0) -
195 }; const EVP_CIPHER *EVP_des_cfb8(void) { return
executed 1962 times by 1 test: return &des_cfb8;
Executed by:
  • libcrypto.so.1.1
&des_cfb8;
executed 1962 times by 1 test: return &des_cfb8;
Executed by:
  • libcrypto.so.1.1
}
1962
196-
197-
198-
199static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,-
200 const unsigned char *iv, int enc)-
201{-
202 DES_cblock *deskey = (DES_cblock *)key;-
203 EVP_DES_KEY *dat = (EVP_DES_KEY *) EVP_CIPHER_CTX_get_cipher_data(ctx);-
204-
205 dat->stream.cbc = -
206 ((void *)0)-
207 ;-
208 DES_set_key_unchecked(deskey, EVP_CIPHER_CTX_get_cipher_data(ctx));-
209 return
executed 202 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 202 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
202
210}-
211-
212static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)-
213{-
214-
215 switch (type) {-
216 case
never executed: case 0x6:
0x6:
never executed: case 0x6:
0
217 if (RAND_priv_bytes(ptr, 8) <= 0
RAND_priv_bytes(ptr, 8) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
218 return
never executed: return 0;
0;
never executed: return 0;
0
219 DES_set_odd_parity((DES_cblock *)ptr);-
220 return
never executed: return 1;
1;
never executed: return 1;
0
221-
222 default
never executed: default:
:
never executed: default:
0
223 return
never executed: return -1;
-1;
never executed: return -1;
0
224 }-
225}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2