Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dh/dh_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | int DH_set_method(DH *dh, const DH_METHOD *meth) | - | ||||||||||||
3 | { | - | ||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | const DH_METHOD *mtmp; | - | ||||||||||||
9 | mtmp = dh->meth; | - | ||||||||||||
10 | if (mtmp->finish
| 0 | ||||||||||||
11 | mtmp->finish(dh); never executed: mtmp->finish(dh); | 0 | ||||||||||||
12 | - | |||||||||||||
13 | ENGINE_finish(dh->engine); | - | ||||||||||||
14 | dh->engine = | - | ||||||||||||
15 | ((void *)0) | - | ||||||||||||
16 | ; | - | ||||||||||||
17 | - | |||||||||||||
18 | dh->meth = meth; | - | ||||||||||||
19 | if (meth->init
| 0 | ||||||||||||
20 | meth->init(dh); never executed: meth->init(dh); | 0 | ||||||||||||
21 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
22 | } | - | ||||||||||||
23 | - | |||||||||||||
24 | DH *DH_new(void) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | return executed 12258 times by 1 test: DH_new_method(return DH_new_method( ((void *)0) ); Executed by:
executed 12258 times by 1 test: return DH_new_method( ((void *)0) ); Executed by:
| 12258 | ||||||||||||
27 | ((void *)0) executed 12258 times by 1 test: return DH_new_method( ((void *)0) ); Executed by:
| 12258 | ||||||||||||
28 | ); executed 12258 times by 1 test: return DH_new_method( ((void *)0) ); Executed by:
| 12258 | ||||||||||||
29 | } | - | ||||||||||||
30 | - | |||||||||||||
31 | DH *DH_new_method(ENGINE *engine) | - | ||||||||||||
32 | { | - | ||||||||||||
33 | DH *ret = CRYPTO_zalloc(sizeof(*ret), __FILE__, 44); | - | ||||||||||||
34 | - | |||||||||||||
35 | if (ret ==
| 0-12258 | ||||||||||||
36 | ((void *)0)
| 0-12258 | ||||||||||||
37 | ) { | - | ||||||||||||
38 | ERR_put_error(5,(105),((1|64)),__FILE__,47); | - | ||||||||||||
39 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
40 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
41 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | ret->references = 1; | - | ||||||||||||
45 | ret->lock = CRYPTO_THREAD_lock_new(); | - | ||||||||||||
46 | if (ret->lock ==
| 0-12258 | ||||||||||||
47 | ((void *)0)
| 0-12258 | ||||||||||||
48 | ) { | - | ||||||||||||
49 | ERR_put_error(5,(105),((1|64)),__FILE__,54); | - | ||||||||||||
50 | CRYPTO_free(ret, __FILE__, 55); | - | ||||||||||||
51 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
52 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
53 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
54 | } | - | ||||||||||||
55 | - | |||||||||||||
56 | ret->meth = DH_get_default_method(); | - | ||||||||||||
57 | - | |||||||||||||
58 | ret->flags = ret->meth->flags; | - | ||||||||||||
59 | if (engine
| 0-12258 | ||||||||||||
60 | if (!ENGINE_init(engine)
| 0 | ||||||||||||
61 | ERR_put_error(5,(105),(38),__FILE__,64); | - | ||||||||||||
62 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
63 | } | - | ||||||||||||
64 | ret->engine = engine; | - | ||||||||||||
65 | } never executed: elseend of block | 0 | ||||||||||||
66 | ret->engine = ENGINE_get_default_DH(); executed 12258 times by 1 test: ret->engine = ENGINE_get_default_DH(); Executed by:
| 12258 | ||||||||||||
67 | if (ret->engine
| 0-12258 | ||||||||||||
68 | ret->meth = ENGINE_get_DH(ret->engine); | - | ||||||||||||
69 | if (ret->meth ==
| 0 | ||||||||||||
70 | ((void *)0)
| 0 | ||||||||||||
71 | ) { | - | ||||||||||||
72 | ERR_put_error(5,(105),(38),__FILE__,73); | - | ||||||||||||
73 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
74 | } | - | ||||||||||||
75 | } never executed: end of block | 0 | ||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | ret->flags = ret->meth->flags; | - | ||||||||||||
79 | - | |||||||||||||
80 | if (!CRYPTO_new_ex_data(6, ret, &ret->ex_data)
| 0-12258 | ||||||||||||
81 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
82 | - | |||||||||||||
83 | if ((
| 0-12258 | ||||||||||||
84 | ((void *)0)
| 0-12258 | ||||||||||||
85 | )
| 0-12258 | ||||||||||||
86 | ERR_put_error(5,(105),((6|64)),__FILE__,85); | - | ||||||||||||
87 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
88 | } | - | ||||||||||||
89 | - | |||||||||||||
90 | return executed 12258 times by 1 test: ret;return ret; Executed by:
executed 12258 times by 1 test: return ret; Executed by:
| 12258 | ||||||||||||
91 | - | |||||||||||||
92 | err: | - | ||||||||||||
93 | DH_free(ret); | - | ||||||||||||
94 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
95 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
96 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
97 | } | - | ||||||||||||
98 | - | |||||||||||||
99 | void DH_free(DH *r) | - | ||||||||||||
100 | { | - | ||||||||||||
101 | int i; | - | ||||||||||||
102 | - | |||||||||||||
103 | if (r ==
| 4649-12493 | ||||||||||||
104 | ((void *)0)
| 4649-12493 | ||||||||||||
105 | ) | - | ||||||||||||
106 | return; executed 4649 times by 1 test: return; Executed by:
| 4649 | ||||||||||||
107 | - | |||||||||||||
108 | CRYPTO_DOWN_REF(&r->references, &i, r->lock); | - | ||||||||||||
109 | ; | - | ||||||||||||
110 | if (i > 0
| 235-12258 | ||||||||||||
111 | return; executed 235 times by 1 test: return; Executed by:
| 235 | ||||||||||||
112 | ; | - | ||||||||||||
113 | - | |||||||||||||
114 | if (r->meth !=
| 0-12258 | ||||||||||||
115 | ((void *)0)
| 0-12258 | ||||||||||||
116 | && r->meth->finish !=
| 0-12258 | ||||||||||||
117 | ((void *)0)
| 0-12258 | ||||||||||||
118 | ) | - | ||||||||||||
119 | r->meth->finish(r); executed 12258 times by 1 test: r->meth->finish(r); Executed by:
| 12258 | ||||||||||||
120 | - | |||||||||||||
121 | ENGINE_finish(r->engine); | - | ||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | CRYPTO_free_ex_data(6, r, &r->ex_data); | - | ||||||||||||
125 | - | |||||||||||||
126 | CRYPTO_THREAD_lock_free(r->lock); | - | ||||||||||||
127 | - | |||||||||||||
128 | BN_clear_free(r->p); | - | ||||||||||||
129 | BN_clear_free(r->g); | - | ||||||||||||
130 | BN_clear_free(r->q); | - | ||||||||||||
131 | BN_clear_free(r->j); | - | ||||||||||||
132 | CRYPTO_free(r->seed, __FILE__, 123); | - | ||||||||||||
133 | BN_clear_free(r->counter); | - | ||||||||||||
134 | BN_clear_free(r->pub_key); | - | ||||||||||||
135 | BN_clear_free(r->priv_key); | - | ||||||||||||
136 | CRYPTO_free(r, __FILE__, 127); | - | ||||||||||||
137 | } executed 12258 times by 1 test: end of block Executed by:
| 12258 | ||||||||||||
138 | - | |||||||||||||
139 | int DH_up_ref(DH *r) | - | ||||||||||||
140 | { | - | ||||||||||||
141 | int i; | - | ||||||||||||
142 | - | |||||||||||||
143 | if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0
| 0-235 | ||||||||||||
144 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
145 | - | |||||||||||||
146 | ; | - | ||||||||||||
147 | ; | - | ||||||||||||
148 | return executed 235 times by 1 test: ((return ((i > 1) ? 1 : 0); Executed by:
executed 235 times by 1 test: return ((i > 1) ? 1 : 0); Executed by:
| 0-235 | ||||||||||||
149 | } | - | ||||||||||||
150 | - | |||||||||||||
151 | int DH_set_ex_data(DH *d, int idx, void *arg) | - | ||||||||||||
152 | { | - | ||||||||||||
153 | return never executed: CRYPTO_set_ex_data(&d->ex_data, idx, arg);return CRYPTO_set_ex_data(&d->ex_data, idx, arg); never executed: return CRYPTO_set_ex_data(&d->ex_data, idx, arg); | 0 | ||||||||||||
154 | } | - | ||||||||||||
155 | - | |||||||||||||
156 | void *DH_get_ex_data(DH *d, int idx) | - | ||||||||||||
157 | { | - | ||||||||||||
158 | return never executed: CRYPTO_get_ex_data(&d->ex_data, idx);return CRYPTO_get_ex_data(&d->ex_data, idx); never executed: return CRYPTO_get_ex_data(&d->ex_data, idx); | 0 | ||||||||||||
159 | } | - | ||||||||||||
160 | - | |||||||||||||
161 | int DH_bits(const DH *dh) | - | ||||||||||||
162 | { | - | ||||||||||||
163 | return never executed: BN_num_bits(dh->p);return BN_num_bits(dh->p); never executed: return BN_num_bits(dh->p); | 0 | ||||||||||||
164 | } | - | ||||||||||||
165 | - | |||||||||||||
166 | int DH_size(const DH *dh) | - | ||||||||||||
167 | { | - | ||||||||||||
168 | return executed 242 times by 1 test: ((BN_num_bits(dh->p)+7)/8);return ((BN_num_bits(dh->p)+7)/8); Executed by:
executed 242 times by 1 test: return ((BN_num_bits(dh->p)+7)/8); Executed by:
| 242 | ||||||||||||
169 | } | - | ||||||||||||
170 | - | |||||||||||||
171 | int DH_security_bits(const DH *dh) | - | ||||||||||||
172 | { | - | ||||||||||||
173 | int N; | - | ||||||||||||
174 | if (dh->q
| 9-663 | ||||||||||||
175 | N = BN_num_bits(dh->q); executed 9 times by 1 test: N = BN_num_bits(dh->q); Executed by:
| 9 | ||||||||||||
176 | else if (dh->length
| 16-647 | ||||||||||||
177 | N = dh->length; executed 16 times by 1 test: N = dh->length; Executed by:
| 16 | ||||||||||||
178 | else | - | ||||||||||||
179 | N = -1; executed 647 times by 1 test: N = -1; Executed by:
| 647 | ||||||||||||
180 | return executed 672 times by 1 test: BN_security_bits(BN_num_bits(dh->p), N);return BN_security_bits(BN_num_bits(dh->p), N); Executed by:
executed 672 times by 1 test: return BN_security_bits(BN_num_bits(dh->p), N); Executed by:
| 672 | ||||||||||||
181 | } | - | ||||||||||||
182 | - | |||||||||||||
183 | - | |||||||||||||
184 | void DH_get0_pqg(const DH *dh, | - | ||||||||||||
185 | const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) | - | ||||||||||||
186 | { | - | ||||||||||||
187 | if (p !=
| 0-63 | ||||||||||||
188 | ((void *)0)
| 0-63 | ||||||||||||
189 | ) | - | ||||||||||||
190 | * executed 63 times by 1 test: p = dh->p;*p = dh->p; Executed by:
executed 63 times by 1 test: *p = dh->p; Executed by:
| 63 | ||||||||||||
191 | if (q !=
| 1-62 | ||||||||||||
192 | ((void *)0)
| 1-62 | ||||||||||||
193 | ) | - | ||||||||||||
194 | * executed 1 time by 1 test: q = dh->q;*q = dh->q; Executed by:
executed 1 time by 1 test: *q = dh->q; Executed by:
| 1 | ||||||||||||
195 | if (g !=
| 0-63 | ||||||||||||
196 | ((void *)0)
| 0-63 | ||||||||||||
197 | ) | - | ||||||||||||
198 | * executed 63 times by 1 test: g = dh->g;*g = dh->g; Executed by:
executed 63 times by 1 test: *g = dh->g; Executed by:
| 63 | ||||||||||||
199 | } executed 63 times by 1 test: end of block Executed by:
| 63 | ||||||||||||
200 | - | |||||||||||||
201 | int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) | - | ||||||||||||
202 | { | - | ||||||||||||
203 | - | |||||||||||||
204 | - | |||||||||||||
205 | - | |||||||||||||
206 | if ((dh->p ==
| 0-504 | ||||||||||||
207 | ((void *)0)
| 0-504 | ||||||||||||
208 | && p ==
| 0-504 | ||||||||||||
209 | ((void *)0)
| 0-504 | ||||||||||||
210 | ) | - | ||||||||||||
211 | || (dh->g ==
| 0-504 | ||||||||||||
212 | ((void *)0)
| 0-504 | ||||||||||||
213 | && g ==
| 0-504 | ||||||||||||
214 | ((void *)0)
| 0-504 | ||||||||||||
215 | )) | - | ||||||||||||
216 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
217 | - | |||||||||||||
218 | if (p !=
| 0-504 | ||||||||||||
219 | ((void *)0)
| 0-504 | ||||||||||||
220 | ) { | - | ||||||||||||
221 | BN_free(dh->p); | - | ||||||||||||
222 | dh->p = p; | - | ||||||||||||
223 | } executed 504 times by 1 test: end of block Executed by:
| 504 | ||||||||||||
224 | if (q !=
| 1-503 | ||||||||||||
225 | ((void *)0)
| 1-503 | ||||||||||||
226 | ) { | - | ||||||||||||
227 | BN_free(dh->q); | - | ||||||||||||
228 | dh->q = q; | - | ||||||||||||
229 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
230 | if (g !=
| 0-504 | ||||||||||||
231 | ((void *)0)
| 0-504 | ||||||||||||
232 | ) { | - | ||||||||||||
233 | BN_free(dh->g); | - | ||||||||||||
234 | dh->g = g; | - | ||||||||||||
235 | } executed 504 times by 1 test: end of block Executed by:
| 504 | ||||||||||||
236 | - | |||||||||||||
237 | if (q !=
| 1-503 | ||||||||||||
238 | ((void *)0)
| 1-503 | ||||||||||||
239 | ) { | - | ||||||||||||
240 | dh->length = BN_num_bits(q); | - | ||||||||||||
241 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
242 | - | |||||||||||||
243 | return executed 504 times by 1 test: 1;return 1; Executed by:
executed 504 times by 1 test: return 1; Executed by:
| 504 | ||||||||||||
244 | } | - | ||||||||||||
245 | - | |||||||||||||
246 | long DH_get_length(const DH *dh) | - | ||||||||||||
247 | { | - | ||||||||||||
248 | return never executed: dh->length;return dh->length; never executed: return dh->length; | 0 | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | int DH_set_length(DH *dh, long length) | - | ||||||||||||
252 | { | - | ||||||||||||
253 | dh->length = length; | - | ||||||||||||
254 | return executed 3 times by 1 test: 1;return 1; Executed by:
executed 3 times by 1 test: return 1; Executed by:
| 3 | ||||||||||||
255 | } | - | ||||||||||||
256 | - | |||||||||||||
257 | void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) | - | ||||||||||||
258 | { | - | ||||||||||||
259 | if (pub_key !=
| 0-210 | ||||||||||||
260 | ((void *)0)
| 0-210 | ||||||||||||
261 | ) | - | ||||||||||||
262 | * executed 210 times by 1 test: pub_key = dh->pub_key;*pub_key = dh->pub_key; Executed by:
executed 210 times by 1 test: *pub_key = dh->pub_key; Executed by:
| 210 | ||||||||||||
263 | if (priv_key !=
| 3-207 | ||||||||||||
264 | ((void *)0)
| 3-207 | ||||||||||||
265 | ) | - | ||||||||||||
266 | * executed 3 times by 1 test: priv_key = dh->priv_key;*priv_key = dh->priv_key; Executed by:
executed 3 times by 1 test: *priv_key = dh->priv_key; Executed by:
| 3 | ||||||||||||
267 | } executed 210 times by 1 test: end of block Executed by:
| 210 | ||||||||||||
268 | - | |||||||||||||
269 | int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) | - | ||||||||||||
270 | { | - | ||||||||||||
271 | if (pub_key !=
| 2-441 | ||||||||||||
272 | ((void *)0)
| 2-441 | ||||||||||||
273 | ) { | - | ||||||||||||
274 | BN_free(dh->pub_key); | - | ||||||||||||
275 | dh->pub_key = pub_key; | - | ||||||||||||
276 | } executed 441 times by 1 test: end of block Executed by:
| 441 | ||||||||||||
277 | if (priv_key !=
| 8-435 | ||||||||||||
278 | ((void *)0)
| 8-435 | ||||||||||||
279 | ) { | - | ||||||||||||
280 | BN_free(dh->priv_key); | - | ||||||||||||
281 | dh->priv_key = priv_key; | - | ||||||||||||
282 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
283 | - | |||||||||||||
284 | return executed 443 times by 1 test: 1;return 1; Executed by:
executed 443 times by 1 test: return 1; Executed by:
| 443 | ||||||||||||
285 | } | - | ||||||||||||
286 | - | |||||||||||||
287 | const BIGNUM *DH_get0_p(const DH *dh) | - | ||||||||||||
288 | { | - | ||||||||||||
289 | return executed 1 time by 1 test: dh->p;return dh->p; Executed by:
executed 1 time by 1 test: return dh->p; Executed by:
| 1 | ||||||||||||
290 | } | - | ||||||||||||
291 | - | |||||||||||||
292 | const BIGNUM *DH_get0_q(const DH *dh) | - | ||||||||||||
293 | { | - | ||||||||||||
294 | return executed 1 time by 1 test: dh->q;return dh->q; Executed by:
executed 1 time by 1 test: return dh->q; Executed by:
| 1 | ||||||||||||
295 | } | - | ||||||||||||
296 | - | |||||||||||||
297 | const BIGNUM *DH_get0_g(const DH *dh) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | return executed 1 time by 1 test: dh->g;return dh->g; Executed by:
executed 1 time by 1 test: return dh->g; Executed by:
| 1 | ||||||||||||
300 | } | - | ||||||||||||
301 | - | |||||||||||||
302 | const BIGNUM *DH_get0_priv_key(const DH *dh) | - | ||||||||||||
303 | { | - | ||||||||||||
304 | return executed 2 times by 1 test: dh->priv_key;return dh->priv_key; Executed by:
executed 2 times by 1 test: return dh->priv_key; Executed by:
| 2 | ||||||||||||
305 | } | - | ||||||||||||
306 | - | |||||||||||||
307 | const BIGNUM *DH_get0_pub_key(const DH *dh) | - | ||||||||||||
308 | { | - | ||||||||||||
309 | return executed 2 times by 1 test: dh->pub_key;return dh->pub_key; Executed by:
executed 2 times by 1 test: return dh->pub_key; Executed by:
| 2 | ||||||||||||
310 | } | - | ||||||||||||
311 | - | |||||||||||||
312 | void DH_clear_flags(DH *dh, int flags) | - | ||||||||||||
313 | { | - | ||||||||||||
314 | dh->flags &= ~flags; | - | ||||||||||||
315 | } never executed: end of block | 0 | ||||||||||||
316 | - | |||||||||||||
317 | int DH_test_flags(const DH *dh, int flags) | - | ||||||||||||
318 | { | - | ||||||||||||
319 | return never executed: dh->flags & flags;return dh->flags & flags; never executed: return dh->flags & flags; | 0 | ||||||||||||
320 | } | - | ||||||||||||
321 | - | |||||||||||||
322 | void DH_set_flags(DH *dh, int flags) | - | ||||||||||||
323 | { | - | ||||||||||||
324 | dh->flags |= flags; | - | ||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||
326 | - | |||||||||||||
327 | ENGINE *DH_get0_engine(DH *dh) | - | ||||||||||||
328 | { | - | ||||||||||||
329 | return never executed: dh->engine;return dh->engine; never executed: return dh->engine; | 0 | ||||||||||||
330 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |