OpenCoverage

rsa_crpt.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/rsa/rsa_crpt.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2int RSA_bits(const RSA *r)-
3{-
4 return
executed 20 times by 1 test: return BN_num_bits(r->n);
Executed by:
  • libcrypto.so.1.1
BN_num_bits(r->n);
executed 20 times by 1 test: return BN_num_bits(r->n);
Executed by:
  • libcrypto.so.1.1
20
5}-
6-
7int RSA_size(const RSA *r)-
8{-
9 return
executed 15070 times by 1 test: return ((BN_num_bits(r->n)+7)/8);
Executed by:
  • libcrypto.so.1.1
((BN_num_bits(r->n)+7)/8);
executed 15070 times by 1 test: return ((BN_num_bits(r->n)+7)/8);
Executed by:
  • libcrypto.so.1.1
15070
10}-
11-
12int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,-
13 RSA *rsa, int padding)-
14{-
15 return
executed 499 times by 1 test: return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);
executed 499 times by 1 test: return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
499
16}-
17-
18int RSA_private_encrypt(int flen, const unsigned char *from,-
19 unsigned char *to, RSA *rsa, int padding)-
20{-
21 return
executed 1651 times by 1 test: return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);
executed 1651 times by 1 test: return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
1651
22}-
23-
24int RSA_private_decrypt(int flen, const unsigned char *from,-
25 unsigned char *to, RSA *rsa, int padding)-
26{-
27 return
executed 735 times by 1 test: return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);
executed 735 times by 1 test: return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
735
28}-
29-
30int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,-
31 RSA *rsa, int padding)-
32{-
33 return
executed 2776 times by 1 test: return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);
executed 2776 times by 1 test: return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);
Executed by:
  • libcrypto.so.1.1
2776
34}-
35-
36int RSA_flags(const RSA *r)-
37{-
38 return
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;
Executed by:
  • libcrypto.so.1.1
r ==
r == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3942 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;
Executed by:
  • libcrypto.so.1.1
0-3942
39 ((void *)0)
r == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3942 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;
Executed by:
  • libcrypto.so.1.1
0-3942
40 ? 0 : r->meth->flags;
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;
Executed by:
  • libcrypto.so.1.1
3942
41}-
42-
43void RSA_blinding_off(RSA *rsa)-
44{-
45 BN_BLINDING_free(rsa->blinding);-
46 rsa->blinding = -
47 ((void *)0)-
48 ;-
49 rsa->flags &= ~0x0008;-
50 rsa->flags |= 0x0080;-
51}
never executed: end of block
0
52-
53int RSA_blinding_on(RSA *rsa, BN_CTX *ctx)-
54{-
55 int ret = 0;-
56-
57 if (rsa->blinding !=
rsa->blinding != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
58 ((void *)0)
rsa->blinding != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
59 )-
60 RSA_blinding_off(rsa);
never executed: RSA_blinding_off(rsa);
0
61-
62 rsa->blinding = RSA_setup_blinding(rsa, ctx);-
63 if (rsa->blinding ==
rsa->blinding == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
64 ((void *)0)
rsa->blinding == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
65 )-
66 goto
never executed: goto err;
err;
never executed: goto err;
0
67-
68 rsa->flags |= 0x0008;-
69 rsa->flags &= ~0x0080;-
70 ret = 1;-
71 err:
code before this statement never executed: err:
0
72 return
never executed: return ret;
ret;
never executed: return ret;
0
73}-
74-
75static BIGNUM *rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p,-
76 const BIGNUM *q, BN_CTX *ctx)-
77{-
78 BIGNUM *ret = -
79 ((void *)0)-
80 , *r0, *r1, *r2;-
81-
82 if (d ==
d == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
83 ((void *)0)
d == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
84 || p ==
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
85 ((void *)0)
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
86 || q ==
q == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
87 ((void *)0)
q == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
88 )-
89 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
90 ((void *)0)
never executed: return ((void *)0) ;
0
91 ;
never executed: return ((void *)0) ;
0
92-
93 BN_CTX_start(ctx);-
94 r0 = BN_CTX_get(ctx);-
95 r1 = BN_CTX_get(ctx);-
96 r2 = BN_CTX_get(ctx);-
97 if (r2 ==
r2 == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
98 ((void *)0)
r2 == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
99 )-
100 goto
never executed: goto err;
err;
never executed: goto err;
0
101-
102 if (!BN_sub(r1, p, BN_value_one())
!BN_sub(r1, p, BN_value_one())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
103 goto
never executed: goto err;
err;
never executed: goto err;
0
104 if (!BN_sub(r2, q, BN_value_one())
!BN_sub(r2, q, BN_value_one())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
105 goto
never executed: goto err;
err;
never executed: goto err;
0
106 if (!BN_mul(r0, r1, r2, ctx)
!BN_mul(r0, r1, r2, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
107 goto
never executed: goto err;
err;
never executed: goto err;
0
108-
109 ret = BN_mod_inverse(-
110 ((void *)0)-
111 , d, r0, ctx);-
112 err:
code before this statement never executed: err:
0
113 BN_CTX_end(ctx);-
114 return
never executed: return ret;
ret;
never executed: return ret;
0
115}-
116-
117BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)-
118{-
119 BIGNUM *e;-
120 BN_CTX *ctx;-
121 BN_BLINDING *ret = -
122 ((void *)0)-
123 ;-
124-
125 if (in_ctx ==
in_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
126 ((void *)0)
in_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
127 ) {-
128 if ((
(ctx = BN_CTX_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
ctx = BN_CTX_new()) ==
(ctx = BN_CTX_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
129 ((void *)0)
(ctx = BN_CTX_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
130 )-
131 return
never executed: return 0;
0;
never executed: return 0;
0
132 }
never executed: end of block
else {
0
133 ctx = in_ctx;-
134 }
executed 1733 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1733
135-
136 BN_CTX_start(ctx);-
137 e = BN_CTX_get(ctx);-
138 if (e ==
e == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
139 ((void *)0)
e == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
140 ) {-
141 ERR_put_error(4,(136),((1|64)),__FILE__,126);-
142 goto
never executed: goto err;
err;
never executed: goto err;
0
143 }-
144-
145 if (rsa->e ==
rsa->e == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
146 ((void *)0)
rsa->e == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
147 ) {-
148 e = rsa_get_public_exp(rsa->d, rsa->p, rsa->q, ctx);-
149 if (e ==
e == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
150 ((void *)0)
e == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
151 ) {-
152 ERR_put_error(4,(136),(140),__FILE__,133);-
153 goto
never executed: goto err;
err;
never executed: goto err;
0
154 }-
155 }
never executed: end of block
else {
0
156 e = rsa->e;-
157 }
executed 1733 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1733
158-
159 {-
160 BIGNUM *n = BN_new();-
161-
162 if (n ==
n == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
163 ((void *)0)
n == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
164 ) {-
165 ERR_put_error(4,(136),((1|64)),__FILE__,144);-
166 goto
never executed: goto err;
err;
never executed: goto err;
0
167 }-
168 BN_with_flags(n, rsa->n, 0x04);-
169-
170 ret = BN_BLINDING_create_param(-
171 ((void *)0)-
172 , e, n, ctx, rsa->meth->bn_mod_exp,-
173 rsa->_method_mod_n);-
174-
175 BN_free(n);-
176 }-
177 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
178 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1733
179 ) {-
180 ERR_put_error(4,(136),(3),__FILE__,155);-
181 goto
never executed: goto err;
err;
never executed: goto err;
0
182 }-
183-
184 BN_BLINDING_set_current_thread(ret);-
185-
186 err:
code before this statement executed 1733 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1733
187 BN_CTX_end(ctx);-
188 if (ctx != in_ctx
ctx != in_ctxDescription
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-1733
189 BN_CTX_free(ctx);
never executed: BN_CTX_free(ctx);
0
190 if (e != rsa->e
e != rsa->eDescription
TRUEnever evaluated
FALSEevaluated 1733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-1733
191 BN_free(e);
never executed: BN_free(e);
0
192-
193 return
executed 1733 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 1733 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
1733
194}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2