Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/dh/dh_key.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | static int generate_key(DH *dh); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | static int dh_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | static int dh_init(DH *dh); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | static int dh_finish(DH *dh); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
12 | DH_generate_key(DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
13 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
14 | return executed 62 times by 4 tests: dh->meth->generate_key(dh);return dh->meth->generate_key(dh); Executed by:
executed 62 times by 4 tests: return dh->meth->generate_key(dh); Executed by:
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
17 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
18 | DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
19 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
20 | return executed 60 times by 3 tests: dh->meth->compute_key(key, pub_key, dh);return dh->meth->compute_key(key, pub_key, dh); Executed by:
executed 60 times by 3 tests: return dh->meth->compute_key(key, pub_key, dh); Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
23 | static DH_METHOD dh_ossl = { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
24 | .name = "OpenSSL DH Method", | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
25 | .generate_key = generate_key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
26 | .compute_key = compute_key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
27 | .bn_mod_exp = dh_bn_mod_exp, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 | .init = dh_init, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
29 | .finish = dh_finish, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
30 | }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
32 | const DH_METHOD * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33 | DH_OpenSSL(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
34 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
35 | return executed 52 times by 4 tests: &dh_ossl;return &dh_ossl; Executed by:
executed 52 times by 4 tests: return &dh_ossl; Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
36 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
38 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
39 | generate_key(DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
40 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
41 | int ok = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
42 | int generate_new_key = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
43 | unsigned l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
44 | BN_CTX *ctx; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
45 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
46 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
47 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
48 | BIGNUM *pub_key = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
49 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
50 | , *priv_key = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
51 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
52 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
54 | if (BN_num_bits(dh->p) > 10000
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
55 | ERR_put_error(5,(0xfff),(103),__FILE__,112); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
56 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
57 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
59 | ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
60 | if (ctx ==
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
61 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
62 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
63 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
65 | if (dh->priv_key ==
| 17-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | ((void *)0)
| 17-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
67 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
68 | priv_key = BN_new(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
69 | if (priv_key ==
| 0-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
70 | ((void *)0)
| 0-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
73 | generate_new_key = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
74 | } executed 45 times by 3 tests: elseend of block Executed by:
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
75 | priv_key = dh->priv_key; executed 17 times by 1 test: priv_key = dh->priv_key; Executed by:
| 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
77 | if (dh->pub_key ==
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
78 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
79 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
80 | pub_key = BN_new(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
81 | if (pub_key ==
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
82 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
83 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
84 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
85 | } executed 62 times by 4 tests: elseend of block Executed by:
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
86 | pub_key = dh->pub_key; never executed: pub_key = dh->pub_key; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
88 | if (dh->flags & 0x01
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
89 | mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
90 | 26, dh->p, ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
91 | if (!mont
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
92 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
93 | } executed 62 times by 4 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | if (generate_new_key
| 17-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
96 | if (dh->q
| 0-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
97 | do { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
98 | if (!BN_rand_range(priv_key, dh->q)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
99 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
100 | } never executed: while (((end of block
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
101 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
103 | l = dh->length
| 10-35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
104 | if (!BN_rand(priv_key, l, 0, 0)
| 0-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
105 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
106 | } executed 45 times by 3 tests: end of block Executed by:
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
107 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
109 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
110 | BIGNUM prk; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
112 | BN_init(&prk); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
113 | ((&prk)->d=(priv_key)->d, (&prk)->top=(priv_key)->top, (&prk)->dmax=(priv_key)->dmax, (&prk)->neg=(priv_key)->neg, (&prk)->flags=(((&prk)->flags & 0x01) | ((priv_key)->flags & ~0x01) | 0x02 | (0x04))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
115 | if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, &prk, dh->p, ctx,
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
116 | mont)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
117 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
118 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
119 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
121 | dh->pub_key = pub_key; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
122 | dh->priv_key = priv_key; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
123 | ok = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
124 | err: code before this statement executed 62 times by 4 tests: err: Executed by:
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
125 | if (ok != 1
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
126 | ERR_put_error(5,(0xfff),(3),__FILE__,173); never executed: ERR_put_error(5,(0xfff),(3),__FILE__,173); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
128 | if (pub_key !=
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
129 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
130 | && dh->pub_key ==
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
131 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
132 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
133 | BN_free(pub_key); never executed: BN_free(pub_key); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
134 | if (priv_key !=
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
135 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
136 | && dh->priv_key ==
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
137 | ((void *)0)
| 0-62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
138 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
139 | BN_free(priv_key); never executed: BN_free(priv_key); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
140 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
141 | return executed 62 times by 4 tests: ok;return ok; Executed by:
executed 62 times by 4 tests: return ok; Executed by:
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
144 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
145 | compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
146 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
147 | BN_CTX *ctx = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
148 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
149 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
150 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
151 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
153 | BIGNUM *tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
154 | int ret = -1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
155 | int check_result; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
157 | if (BN_num_bits(dh->p) > 10000
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
158 | ERR_put_error(5,(0xfff),(103),__FILE__,193); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
159 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
160 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
162 | ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
163 | if (ctx ==
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
164 | ((void *)0)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
165 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
166 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
167 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
168 | if ((
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
169 | ((void *)0)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
170 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
171 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
173 | if (dh->priv_key ==
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
174 | ((void *)0)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
175 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | ERR_put_error(5,(0xfff),(100),__FILE__,205); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
178 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
180 | if (dh->flags & 0x01
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
181 | mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
182 | 26, dh->p, ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
184 | ((dh->priv_key)->flags|=(0x04)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
185 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
186 | if (!mont
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
187 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
188 | } executed 60 times by 3 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
190 | if (!DH_check_pub_key(dh, pub_key, &check_result)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
191 | ERR_put_error(5,(0xfff),(102),__FILE__,220); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
192 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
193 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
195 | if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key, dh->p, ctx,
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
196 | mont)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
197 | ERR_put_error(5,(0xfff),(3),__FILE__,226); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
198 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
199 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
201 | ret = BN_bn2bin(tmp, key); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
202 | err: code before this statement executed 60 times by 3 tests: err: Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
203 | if (ctx !=
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
204 | ((void *)0)
| 0-60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
205 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
206 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
207 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
208 | } executed 60 times by 3 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
209 | return executed 60 times by 3 tests: ret;return ret; Executed by:
executed 60 times by 3 tests: return ret; Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
210 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
212 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
213 | dh_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
214 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
215 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
216 | return executed 122 times by 4 tests: BN_mod_exp_mont_ct(r, a, p, m, ctx, m_ctx);return BN_mod_exp_mont_ct(r, a, p, m, ctx, m_ctx); Executed by:
executed 122 times by 4 tests: return BN_mod_exp_mont_ct(r, a, p, m, ctx, m_ctx); Executed by:
| 122 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
217 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
219 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
220 | dh_init(DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
221 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
222 | dh->flags |= 0x01; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
223 | return executed 230 times by 4 tests: 1;return 1; Executed by:
executed 230 times by 4 tests: return 1; Executed by:
| 230 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
224 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
226 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
227 | dh_finish(DH *dh) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
228 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
229 | BN_MONT_CTX_free(dh->method_mont_p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
230 | return executed 230 times by 4 tests: 1;return 1; Executed by:
executed 230 times by 4 tests: return 1; Executed by:
| 230 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
231 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |