OpenCoverage

e_rc2.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/e_rc2.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,-
7 const unsigned char *iv, int enc);-
8static int rc2_meth_to_magic(EVP_CIPHER_CTX *ctx);-
9static int rc2_magic_to_meth(int i);-
10static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);-
11static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);-
12static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);-
13-
14typedef struct {-
15 int key_bits;-
16 RC2_KEY ks;-
17} EVP_RC2_KEY;-
18-
19-
20-
21static int rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while(inl>=((size_t)1<<(sizeof(long)*8-2))
inl>=((size_t)...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 531 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) { RC2_cbc_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)), &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx)); inl-=((size_t)1<<(sizeof(long)*8-2)); in +=((size_t)1<<(sizeof(long)*8-2)); out+=((size_t)1<<(sizeof(long)*8-2)); }
never executed: end of block
if (inl
inlDescription
TRUEevaluated 531 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) RC2_cbc_encrypt(in, out, (long)inl, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
executed 531 times by 1 test: RC2_cbc_encrypt(in, out, (long)inl, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
return
executed 531 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 531 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
} static int rc2_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t chunk = ((size_t)1<<(sizeof(long)*8-2)); if (64 == 1
64 == 1Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) chunk >>= 3;
never executed: chunk >>= 3;
if (inl < chunk
inl < chunkDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) chunk = inl;
executed 70 times by 1 test: chunk = inl;
Executed by:
  • libcrypto.so.1.1
while (inl
inlDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& inl >= chunk
inl >= chunkDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) { int num = EVP_CIPHER_CTX_num(ctx); RC2_cfb64_encrypt(in, out, (long) ((64 == 1) && !EVP_CIPHER_CTX_test_flags(ctx, 0x2000) ? chunk*8 : chunk), &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), &num, EVP_CIPHER_CTX_encrypting(ctx)); EVP_CIPHER_CTX_set_num(ctx, num); inl -= chunk; in += chunk; out += chunk; if (inl < chunk
inl < chunkDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) chunk = inl;
executed 70 times by 1 test: chunk = inl;
Executed by:
  • libcrypto.so.1.1
}
executed 70 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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
} static int rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t i, bl; bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; if (inl < bl
inl < blDescription
TRUEnever evaluated
FALSEevaluated 129 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 1572 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 129 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i+=bl) RC2_ecb_encrypt(in + i, out + i, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_encrypting(ctx));
executed 1572 times by 1 test: RC2_ecb_encrypt(in + i, out + i, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_encrypting(ctx));
Executed by:
  • libcrypto.so.1.1
return
executed 129 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 129 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
} static int rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while(inl>=((size_t)1<<(sizeof(long)*8-2))
inl>=((size_t)...of(long)*8-2))Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) { int num = EVP_CIPHER_CTX_num(ctx); RC2_ofb64_encrypt(in, out, (long)((size_t)1<<(sizeof(long)*8-2)), &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), &num); EVP_CIPHER_CTX_set_num(ctx, num); inl-=((size_t)1<<(sizeof(long)*8-2)); in +=((size_t)1<<(sizeof(long)*8-2)); out+=((size_t)1<<(sizeof(long)*8-2)); }
never executed: end of block
if (inl
inlDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) { int num = EVP_CIPHER_CTX_num(ctx); RC2_ofb64_encrypt(in, out, (long)inl, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), &num); EVP_CIPHER_CTX_set_num(ctx, num); }
executed 70 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
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
} static const EVP_CIPHER rc2_cbc = { 37, 8, 16, 8, 0x8 | 0x40 | 0x2, rc2_init_key, rc2_cbc_cipher,
0-1572
22((void *)0)-
23, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, -
24((void *)0) -
25}; const EVP_CIPHER *EVP_rc2_cbc(void) { return
executed 3920 times by 1 test: return &rc2_cbc;
Executed by:
  • libcrypto.so.1.1
&rc2_cbc;
executed 3920 times by 1 test: return &rc2_cbc;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER rc2_cfb64 = { 39, 1, 16, 8, 0x8 | 0x40 | 0x3, rc2_init_key, rc2_cfb64_cipher,
3920
26((void *)0)-
27, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, -
28((void *)0) -
29}; const EVP_CIPHER *EVP_rc2_cfb64(void) { return
executed 1962 times by 1 test: return &rc2_cfb64;
Executed by:
  • libcrypto.so.1.1
&rc2_cfb64;
executed 1962 times by 1 test: return &rc2_cfb64;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER rc2_ofb = { 40, 1, 16, 8, 0x8 | 0x40 | 0x4, rc2_init_key, rc2_ofb_cipher,
1962
30((void *)0)-
31, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, -
32((void *)0) -
33}; const EVP_CIPHER *EVP_rc2_ofb(void) { return
executed 1962 times by 1 test: return &rc2_ofb;
Executed by:
  • libcrypto.so.1.1
&rc2_ofb;
executed 1962 times by 1 test: return &rc2_ofb;
Executed by:
  • libcrypto.so.1.1
} static const EVP_CIPHER rc2_ecb = { 38, 8, 16, 0, 0x8 | 0x40 | 0x1, rc2_init_key, rc2_ecb_cipher,
1962
34((void *)0)-
35, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, -
36((void *)0) -
37}; const EVP_CIPHER *EVP_rc2_ecb(void) { return
executed 1962 times by 1 test: return &rc2_ecb;
Executed by:
  • libcrypto.so.1.1
&rc2_ecb;
executed 1962 times by 1 test: return &rc2_ecb;
Executed by:
  • libcrypto.so.1.1
}
1962
38static const EVP_CIPHER r2_64_cbc_cipher = {-
39 166,-
40 8, 8 , 8,-
41 0x2 | 0x8 | 0x40,-
42 rc2_init_key,-
43 rc2_cbc_cipher,-
44 -
45 ((void *)0)-
46 ,-
47 sizeof(EVP_RC2_KEY),-
48 rc2_set_asn1_type_and_iv,-
49 rc2_get_asn1_type_and_iv,-
50 rc2_ctrl,-
51 -
52 ((void *)0)-
53-
54};-
55-
56static const EVP_CIPHER r2_40_cbc_cipher = {-
57 98,-
58 8, 5 , 8,-
59 0x2 | 0x8 | 0x40,-
60 rc2_init_key,-
61 rc2_cbc_cipher,-
62 -
63 ((void *)0)-
64 ,-
65 sizeof(EVP_RC2_KEY),-
66 rc2_set_asn1_type_and_iv,-
67 rc2_get_asn1_type_and_iv,-
68 rc2_ctrl,-
69 -
70 ((void *)0)-
71-
72};-
73-
74const EVP_CIPHER *EVP_rc2_64_cbc(void)-
75{-
76 return
executed 1962 times by 1 test: return &r2_64_cbc_cipher;
Executed by:
  • libcrypto.so.1.1
&r2_64_cbc_cipher;
executed 1962 times by 1 test: return &r2_64_cbc_cipher;
Executed by:
  • libcrypto.so.1.1
1962
77}-
78-
79const EVP_CIPHER *EVP_rc2_40_cbc(void)-
80{-
81 return
executed 3920 times by 1 test: return &r2_40_cbc_cipher;
Executed by:
  • libcrypto.so.1.1
&r2_40_cbc_cipher;
executed 3920 times by 1 test: return &r2_40_cbc_cipher;
Executed by:
  • libcrypto.so.1.1
3920
82}-
83-
84static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,-
85 const unsigned char *iv, int enc)-
86{-
87 RC2_set_key(&((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_key_length(ctx),-
88 key, ((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->key_bits);-
89 return
executed 52 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 52 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
52
90}-
91-
92static int rc2_meth_to_magic(EVP_CIPHER_CTX *e)-
93{-
94 int i;-
95-
96 EVP_CIPHER_CTX_ctrl(e, 0x2, 0, &i);-
97 if (i == 128
i == 128Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-2
98 return
executed 2 times by 1 test: return 0x3a;
Executed by:
  • libcrypto.so.1.1
0x3a;
executed 2 times by 1 test: return 0x3a;
Executed by:
  • libcrypto.so.1.1
2
99 else if (i == 64
i == 64Description
TRUEnever evaluated
FALSEnever evaluated
)
0
100 return
never executed: return 0x78;
0x78;
never executed: return 0x78;
0
101 else if (i == 40
i == 40Description
TRUEnever evaluated
FALSEnever evaluated
)
0
102 return
never executed: return 0xa0;
0xa0;
never executed: return 0xa0;
0
103 else-
104 return
never executed: return 0;
0;
never executed: return 0;
0
105}-
106-
107static int rc2_magic_to_meth(int i)-
108{-
109 if (i == 0x3a
i == 0x3aDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-2
110 return
executed 2 times by 1 test: return 128;
Executed by:
  • libcrypto.so.1.1
128;
executed 2 times by 1 test: return 128;
Executed by:
  • libcrypto.so.1.1
2
111 else if (i == 0x78
i == 0x78Description
TRUEnever evaluated
FALSEnever evaluated
)
0
112 return
never executed: return 64;
64;
never executed: return 64;
0
113 else if (i == 0xa0
i == 0xa0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
114 return
never executed: return 40;
40;
never executed: return 40;
0
115 else {-
116 ERR_put_error(6,(109),(108),__FILE__,115);-
117 return
never executed: return 0;
0;
never executed: return 0;
0
118 }-
119}-
120-
121static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)-
122{-
123 long num = 0;-
124 int i = 0;-
125 int key_bits;-
126 unsigned int l;-
127 unsigned char iv[16];-
128-
129 if (type !=
type != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
130 ((void *)0)
type != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
131 ) {-
132 l = EVP_CIPHER_CTX_iv_length(c);-
133 (void)((l <= sizeof(iv)) ? 0 : (OPENSSL_die("assertion failed: " "l <= sizeof(iv)", __FILE__, 130), 1));-
134 i = ASN1_TYPE_get_int_octetstring(type, &num, iv, l);-
135 if (i != (int)l
i != (int)lDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
136 return
never executed: return -1;
-1;
never executed: return -1;
0
137 key_bits = rc2_magic_to_meth((int)num);-
138 if (!key_bits
!key_bitsDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
139 return
never executed: return -1;
-1;
never executed: return -1;
0
140 if (i > 0
i > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& !EVP_CipherInit_ex(c,
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
141 ((void *)0)
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
142 ,
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
143 ((void *)0)
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
144 ,
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
145 ((void *)0)
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
146 , iv, -1)
!EVP_CipherIni...*)0) , iv, -1)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
147 return
never executed: return -1;
-1;
never executed: return -1;
0
148 EVP_CIPHER_CTX_ctrl(c, 0x3, key_bits, -
149 ((void *)0)-
150 );-
151 if (EVP_CIPHER_CTX_set_key_length(c, key_bits / 8) <= 0
EVP_CIPHER_CTX...bits / 8) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-2
152 return
never executed: return -1;
-1;
never executed: return -1;
0
153 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
154 return
executed 2 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
i;
executed 2 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
2
155}-
156-
157static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)-
158{-
159 long num;-
160 int i = 0, j;-
161-
162 if (type !=
type != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
163 ((void *)0)
type != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
164 ) {-
165 num = rc2_meth_to_magic(c);-
166 j = EVP_CIPHER_CTX_iv_length(c);-
167 i = ASN1_TYPE_set_int_octetstring(type, num,-
168 (unsigned char *)EVP_CIPHER_CTX_original_iv(c),-
169 j);-
170 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
171 return
executed 2 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
i;
executed 2 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
2
172}-
173-
174static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)-
175{-
176 switch (type) {-
177 case
executed 52 times by 1 test: case 0x0:
Executed by:
  • libcrypto.so.1.1
0x0:
executed 52 times by 1 test: case 0x0:
Executed by:
  • libcrypto.so.1.1
52
178 ((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(c))->key_bits = EVP_CIPHER_CTX_key_length(c) * 8;-
179 return
executed 52 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 52 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
52
180-
181 case
executed 2 times by 1 test: case 0x2:
Executed by:
  • libcrypto.so.1.1
0x2:
executed 2 times by 1 test: case 0x2:
Executed by:
  • libcrypto.so.1.1
2
182 *(int *)ptr = ((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(c))->key_bits;-
183 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
184-
185 case
executed 2 times by 1 test: case 0x3:
Executed by:
  • libcrypto.so.1.1
0x3:
executed 2 times by 1 test: case 0x3:
Executed by:
  • libcrypto.so.1.1
2
186 if (arg > 0
arg > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-2
187 ((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(c))->key_bits = arg;-
188 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
189 }-
190 return
never executed: return 0;
0;
never executed: return 0;
0
191-
192-
193-
194-
195-
196-
197 default
never executed: default:
:
never executed: default:
0
198 return
never executed: return -1;
-1;
never executed: return -1;
0
199 }-
200}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2