Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ecp_smpl.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | const EC_METHOD *EC_GFp_simple_method(void) | - | ||||||||||||||||||
5 | { | - | ||||||||||||||||||
6 | static const EC_METHOD ret = { | - | ||||||||||||||||||
7 | 0x1, | - | ||||||||||||||||||
8 | 406, | - | ||||||||||||||||||
9 | ec_GFp_simple_group_init, | - | ||||||||||||||||||
10 | ec_GFp_simple_group_finish, | - | ||||||||||||||||||
11 | ec_GFp_simple_group_clear_finish, | - | ||||||||||||||||||
12 | ec_GFp_simple_group_copy, | - | ||||||||||||||||||
13 | ec_GFp_simple_group_set_curve, | - | ||||||||||||||||||
14 | ec_GFp_simple_group_get_curve, | - | ||||||||||||||||||
15 | ec_GFp_simple_group_get_degree, | - | ||||||||||||||||||
16 | ec_group_simple_order_bits, | - | ||||||||||||||||||
17 | ec_GFp_simple_group_check_discriminant, | - | ||||||||||||||||||
18 | ec_GFp_simple_point_init, | - | ||||||||||||||||||
19 | ec_GFp_simple_point_finish, | - | ||||||||||||||||||
20 | ec_GFp_simple_point_clear_finish, | - | ||||||||||||||||||
21 | ec_GFp_simple_point_copy, | - | ||||||||||||||||||
22 | ec_GFp_simple_point_set_to_infinity, | - | ||||||||||||||||||
23 | ec_GFp_simple_set_Jprojective_coordinates_GFp, | - | ||||||||||||||||||
24 | ec_GFp_simple_get_Jprojective_coordinates_GFp, | - | ||||||||||||||||||
25 | ec_GFp_simple_point_set_affine_coordinates, | - | ||||||||||||||||||
26 | ec_GFp_simple_point_get_affine_coordinates, | - | ||||||||||||||||||
27 | 0, 0, 0, | - | ||||||||||||||||||
28 | ec_GFp_simple_add, | - | ||||||||||||||||||
29 | ec_GFp_simple_dbl, | - | ||||||||||||||||||
30 | ec_GFp_simple_invert, | - | ||||||||||||||||||
31 | ec_GFp_simple_is_at_infinity, | - | ||||||||||||||||||
32 | ec_GFp_simple_is_on_curve, | - | ||||||||||||||||||
33 | ec_GFp_simple_cmp, | - | ||||||||||||||||||
34 | ec_GFp_simple_make_affine, | - | ||||||||||||||||||
35 | ec_GFp_simple_points_make_affine, | - | ||||||||||||||||||
36 | 0 , | - | ||||||||||||||||||
37 | 0 , | - | ||||||||||||||||||
38 | 0 , | - | ||||||||||||||||||
39 | ec_GFp_simple_field_mul, | - | ||||||||||||||||||
40 | ec_GFp_simple_field_sqr, | - | ||||||||||||||||||
41 | 0 , | - | ||||||||||||||||||
42 | 0 , | - | ||||||||||||||||||
43 | 0 , | - | ||||||||||||||||||
44 | 0, | - | ||||||||||||||||||
45 | ec_key_simple_priv2oct, | - | ||||||||||||||||||
46 | ec_key_simple_oct2priv, | - | ||||||||||||||||||
47 | 0, | - | ||||||||||||||||||
48 | ec_key_simple_generate_key, | - | ||||||||||||||||||
49 | ec_key_simple_check_key, | - | ||||||||||||||||||
50 | ec_key_simple_generate_public_key, | - | ||||||||||||||||||
51 | 0, | - | ||||||||||||||||||
52 | 0, | - | ||||||||||||||||||
53 | ecdh_simple_compute_key, | - | ||||||||||||||||||
54 | 0, | - | ||||||||||||||||||
55 | ec_GFp_simple_blind_coordinates, | - | ||||||||||||||||||
56 | ec_GFp_simple_ladder_pre, | - | ||||||||||||||||||
57 | ec_GFp_simple_ladder_step, | - | ||||||||||||||||||
58 | ec_GFp_simple_ladder_post | - | ||||||||||||||||||
59 | }; | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | return never executed: &ret;return &ret; never executed: return &ret; | 0 | ||||||||||||||||||
62 | } | - | ||||||||||||||||||
63 | int ec_GFp_simple_group_init(EC_GROUP *group) | - | ||||||||||||||||||
64 | { | - | ||||||||||||||||||
65 | group->field = BN_new(); | - | ||||||||||||||||||
66 | group->a = BN_new(); | - | ||||||||||||||||||
67 | group->b = BN_new(); | - | ||||||||||||||||||
68 | if (group->field ==
| 0-50449 | ||||||||||||||||||
69 | ((void *)0)
| 0-50449 | ||||||||||||||||||
70 | || group->a ==
| 0-50449 | ||||||||||||||||||
71 | ((void *)0)
| 0-50449 | ||||||||||||||||||
72 | || group->b ==
| 0-50449 | ||||||||||||||||||
73 | ((void *)0)
| 0-50449 | ||||||||||||||||||
74 | ) { | - | ||||||||||||||||||
75 | BN_free(group->field); | - | ||||||||||||||||||
76 | BN_free(group->a); | - | ||||||||||||||||||
77 | BN_free(group->b); | - | ||||||||||||||||||
78 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
79 | } | - | ||||||||||||||||||
80 | group->a_is_minus3 = 0; | - | ||||||||||||||||||
81 | return executed 50449 times by 2 tests: 1;return 1; Executed by:
executed 50449 times by 2 tests: return 1; Executed by:
| 50449 | ||||||||||||||||||
82 | } | - | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | void ec_GFp_simple_group_finish(EC_GROUP *group) | - | ||||||||||||||||||
85 | { | - | ||||||||||||||||||
86 | BN_free(group->field); | - | ||||||||||||||||||
87 | BN_free(group->a); | - | ||||||||||||||||||
88 | BN_free(group->b); | - | ||||||||||||||||||
89 | } executed 49744 times by 2 tests: end of block Executed by:
| 49744 | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | void ec_GFp_simple_group_clear_finish(EC_GROUP *group) | - | ||||||||||||||||||
92 | { | - | ||||||||||||||||||
93 | BN_clear_free(group->field); | - | ||||||||||||||||||
94 | BN_clear_free(group->a); | - | ||||||||||||||||||
95 | BN_clear_free(group->b); | - | ||||||||||||||||||
96 | } executed 705 times by 1 test: end of block Executed by:
| 705 | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | int ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) | - | ||||||||||||||||||
99 | { | - | ||||||||||||||||||
100 | if (!BN_copy(dest->field, src->field)
| 0-24081 | ||||||||||||||||||
101 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
102 | if (!BN_copy(dest->a, src->a)
| 0-24081 | ||||||||||||||||||
103 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
104 | if (!BN_copy(dest->b, src->b)
| 0-24081 | ||||||||||||||||||
105 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | dest->a_is_minus3 = src->a_is_minus3; | - | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | return executed 24081 times by 2 tests: 1;return 1; Executed by:
executed 24081 times by 2 tests: return 1; Executed by:
| 24081 | ||||||||||||||||||
110 | } | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | int ec_GFp_simple_group_set_curve(EC_GROUP *group, | - | ||||||||||||||||||
113 | const BIGNUM *p, const BIGNUM *a, | - | ||||||||||||||||||
114 | const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||
115 | { | - | ||||||||||||||||||
116 | int ret = 0; | - | ||||||||||||||||||
117 | BN_CTX *new_ctx = | - | ||||||||||||||||||
118 | ((void *)0) | - | ||||||||||||||||||
119 | ; | - | ||||||||||||||||||
120 | BIGNUM *tmp_a; | - | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | - | |||||||||||||||||||
123 | if (BN_num_bits(p) <= 2
| 0-25952 | ||||||||||||||||||
124 | ERR_put_error(16,(166),(103),__FILE__,143); | - | ||||||||||||||||||
125 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
126 | } | - | ||||||||||||||||||
127 | - | |||||||||||||||||||
128 | if (ctx ==
| 0-25952 | ||||||||||||||||||
129 | ((void *)0)
| 0-25952 | ||||||||||||||||||
130 | ) { | - | ||||||||||||||||||
131 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
132 | if (ctx ==
| 0 | ||||||||||||||||||
133 | ((void *)0)
| 0 | ||||||||||||||||||
134 | ) | - | ||||||||||||||||||
135 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
136 | } never executed: end of block | 0 | ||||||||||||||||||
137 | - | |||||||||||||||||||
138 | BN_CTX_start(ctx); | - | ||||||||||||||||||
139 | tmp_a = BN_CTX_get(ctx); | - | ||||||||||||||||||
140 | if (tmp_a ==
| 0-25952 | ||||||||||||||||||
141 | ((void *)0)
| 0-25952 | ||||||||||||||||||
142 | ) | - | ||||||||||||||||||
143 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | - | |||||||||||||||||||
146 | if (!BN_copy(group->field, p)
| 0-25952 | ||||||||||||||||||
147 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
148 | BN_set_negative(group->field, 0); | - | ||||||||||||||||||
149 | - | |||||||||||||||||||
150 | - | |||||||||||||||||||
151 | if (!BN_nnmod(tmp_a, a, p, ctx)
| 0-25952 | ||||||||||||||||||
152 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
153 | if (group->meth->field_encode
| 0-25952 | ||||||||||||||||||
154 | if (!group->meth->field_encode(group, group->a, tmp_a, ctx)
| 0-25952 | ||||||||||||||||||
155 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
156 | } executed 25952 times by 2 tests: else if (!BN_copy(group->a, tmp_a)end of block Executed by:
| 0-25952 | ||||||||||||||||||
157 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | - | |||||||||||||||||||
160 | if (!BN_nnmod(group->b, b, p, ctx)
| 0-25952 | ||||||||||||||||||
161 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
162 | if (group->meth->field_encode
| 0-25952 | ||||||||||||||||||
163 | if (!group->meth->field_encode(group, group->b, group->b, ctx)
| 0-25952 | ||||||||||||||||||
164 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | - | |||||||||||||||||||
167 | if (!BN_add_word(tmp_a, 3)
| 0-25952 | ||||||||||||||||||
168 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
169 | group->a_is_minus3 = (0 == BN_cmp(tmp_a, group->field)); | - | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | ret = 1; | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | err: code before this statement executed 25952 times by 2 tests: err: Executed by:
| 25952 | ||||||||||||||||||
174 | BN_CTX_end(ctx); | - | ||||||||||||||||||
175 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
176 | return executed 25952 times by 2 tests: ret;return ret; Executed by:
executed 25952 times by 2 tests: return ret; Executed by:
| 25952 | ||||||||||||||||||
177 | } | - | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, | - | ||||||||||||||||||
180 | BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||
181 | { | - | ||||||||||||||||||
182 | int ret = 0; | - | ||||||||||||||||||
183 | BN_CTX *new_ctx = | - | ||||||||||||||||||
184 | ((void *)0) | - | ||||||||||||||||||
185 | ; | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | if (p !=
| 47-10070 | ||||||||||||||||||
188 | ((void *)0)
| 47-10070 | ||||||||||||||||||
189 | ) { | - | ||||||||||||||||||
190 | if (!BN_copy(p, group->field)
| 0-10070 | ||||||||||||||||||
191 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
192 | } executed 10070 times by 2 tests: end of block Executed by:
| 10070 | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | if (a !=
| 47-10070 | ||||||||||||||||||
195 | ((void *)0)
| 47-10070 | ||||||||||||||||||
196 | || b !=
| 0-47 | ||||||||||||||||||
197 | ((void *)0)
| 0-47 | ||||||||||||||||||
198 | ) { | - | ||||||||||||||||||
199 | if (group->meth->field_decode
| 0-10070 | ||||||||||||||||||
200 | if (ctx ==
| 59-10011 | ||||||||||||||||||
201 | ((void *)0)
| 59-10011 | ||||||||||||||||||
202 | ) { | - | ||||||||||||||||||
203 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
204 | if (ctx ==
| 0-59 | ||||||||||||||||||
205 | ((void *)0)
| 0-59 | ||||||||||||||||||
206 | ) | - | ||||||||||||||||||
207 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
208 | } executed 59 times by 2 tests: end of block Executed by:
| 59 | ||||||||||||||||||
209 | if (a !=
| 0-10070 | ||||||||||||||||||
210 | ((void *)0)
| 0-10070 | ||||||||||||||||||
211 | ) { | - | ||||||||||||||||||
212 | if (!group->meth->field_decode(group, a, group->a, ctx)
| 0-10070 | ||||||||||||||||||
213 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
214 | } executed 10070 times by 2 tests: end of block Executed by:
| 10070 | ||||||||||||||||||
215 | if (b !=
| 0-10070 | ||||||||||||||||||
216 | ((void *)0)
| 0-10070 | ||||||||||||||||||
217 | ) { | - | ||||||||||||||||||
218 | if (!group->meth->field_decode(group, b, group->b, ctx)
| 0-10070 | ||||||||||||||||||
219 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
220 | } executed 10070 times by 2 tests: end of block Executed by:
| 10070 | ||||||||||||||||||
221 | } executed 10070 times by 2 tests: else {end of block Executed by:
| 10070 | ||||||||||||||||||
222 | if (a !=
| 0 | ||||||||||||||||||
223 | ((void *)0)
| 0 | ||||||||||||||||||
224 | ) { | - | ||||||||||||||||||
225 | if (!BN_copy(a, group->a)
| 0 | ||||||||||||||||||
226 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||
228 | if (b !=
| 0 | ||||||||||||||||||
229 | ((void *)0)
| 0 | ||||||||||||||||||
230 | ) { | - | ||||||||||||||||||
231 | if (!BN_copy(b, group->b)
| 0 | ||||||||||||||||||
232 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
233 | } never executed: end of block | 0 | ||||||||||||||||||
234 | } never executed: end of block | 0 | ||||||||||||||||||
235 | } | - | ||||||||||||||||||
236 | - | |||||||||||||||||||
237 | ret = 1; | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | err: code before this statement executed 10117 times by 2 tests: err: Executed by:
| 10117 | ||||||||||||||||||
240 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
241 | return executed 10117 times by 2 tests: ret;return ret; Executed by:
executed 10117 times by 2 tests: return ret; Executed by:
| 10117 | ||||||||||||||||||
242 | } | - | ||||||||||||||||||
243 | - | |||||||||||||||||||
244 | int ec_GFp_simple_group_get_degree(const EC_GROUP *group) | - | ||||||||||||||||||
245 | { | - | ||||||||||||||||||
246 | return executed 1305 times by 1 test: BN_num_bits(group->field);return BN_num_bits(group->field); Executed by:
executed 1305 times by 1 test: return BN_num_bits(group->field); Executed by:
| 1305 | ||||||||||||||||||
247 | } | - | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) | - | ||||||||||||||||||
250 | { | - | ||||||||||||||||||
251 | int ret = 0; | - | ||||||||||||||||||
252 | BIGNUM *a, *b, *order, *tmp_1, *tmp_2; | - | ||||||||||||||||||
253 | const BIGNUM *p = group->field; | - | ||||||||||||||||||
254 | BN_CTX *new_ctx = | - | ||||||||||||||||||
255 | ((void *)0) | - | ||||||||||||||||||
256 | ; | - | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | if (ctx ==
| 0-94 | ||||||||||||||||||
259 | ((void *)0)
| 0-94 | ||||||||||||||||||
260 | ) { | - | ||||||||||||||||||
261 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
262 | if (ctx ==
| 0 | ||||||||||||||||||
263 | ((void *)0)
| 0 | ||||||||||||||||||
264 | ) { | - | ||||||||||||||||||
265 | ERR_put_error(16,(165),((1|64)),__FILE__,253) | - | ||||||||||||||||||
266 | ; | - | ||||||||||||||||||
267 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
268 | } | - | ||||||||||||||||||
269 | } never executed: end of block | 0 | ||||||||||||||||||
270 | BN_CTX_start(ctx); | - | ||||||||||||||||||
271 | a = BN_CTX_get(ctx); | - | ||||||||||||||||||
272 | b = BN_CTX_get(ctx); | - | ||||||||||||||||||
273 | tmp_1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
274 | tmp_2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
275 | order = BN_CTX_get(ctx); | - | ||||||||||||||||||
276 | if (order ==
| 0-94 | ||||||||||||||||||
277 | ((void *)0)
| 0-94 | ||||||||||||||||||
278 | ) | - | ||||||||||||||||||
279 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | if (group->meth->field_decode
| 0-94 | ||||||||||||||||||
282 | if (!group->meth->field_decode(group, a, group->a, ctx)
| 0-94 | ||||||||||||||||||
283 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
284 | if (!group->meth->field_decode(group, b, group->b, ctx)
| 0-94 | ||||||||||||||||||
285 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
286 | } executed 94 times by 1 test: else {end of block Executed by:
| 94 | ||||||||||||||||||
287 | if (!BN_copy(a, group->a)
| 0 | ||||||||||||||||||
288 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
289 | if (!BN_copy(b, group->b)
| 0 | ||||||||||||||||||
290 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
291 | } never executed: end of block | 0 | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | - | |||||||||||||||||||
294 | - | |||||||||||||||||||
295 | - | |||||||||||||||||||
296 | - | |||||||||||||||||||
297 | - | |||||||||||||||||||
298 | if (BN_is_zero(a)
| 18-76 | ||||||||||||||||||
299 | if (BN_is_zero(b)
| 0-18 | ||||||||||||||||||
300 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
301 | } executed 18 times by 1 test: else if (!BN_is_zero(b)end of block Executed by:
| 0-76 | ||||||||||||||||||
302 | if (!BN_mod_sqr(tmp_1, a, p, ctx)
| 0-76 | ||||||||||||||||||
303 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
304 | if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx)
| 0-76 | ||||||||||||||||||
305 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
306 | if (!BN_lshift(tmp_1, tmp_2, 2)
| 0-76 | ||||||||||||||||||
307 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | - | |||||||||||||||||||
310 | if (!BN_mod_sqr(tmp_2, b, p, ctx)
| 0-76 | ||||||||||||||||||
311 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
312 | if (!BN_mul_word(tmp_2, 27)
| 0-76 | ||||||||||||||||||
313 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | - | |||||||||||||||||||
316 | if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx)
| 0-76 | ||||||||||||||||||
317 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
318 | if (BN_is_zero(a)
| 0-76 | ||||||||||||||||||
319 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
320 | } executed 76 times by 1 test: end of block Executed by:
| 76 | ||||||||||||||||||
321 | ret = 1; | - | ||||||||||||||||||
322 | - | |||||||||||||||||||
323 | err: code before this statement executed 94 times by 1 test: err: Executed by:
| 94 | ||||||||||||||||||
324 | if (ctx !=
| 0-94 | ||||||||||||||||||
325 | ((void *)0)
| 0-94 | ||||||||||||||||||
326 | ) | - | ||||||||||||||||||
327 | BN_CTX_end(ctx); executed 94 times by 1 test: BN_CTX_end(ctx); Executed by:
| 94 | ||||||||||||||||||
328 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
329 | return executed 94 times by 1 test: ret;return ret; Executed by:
executed 94 times by 1 test: return ret; Executed by:
| 94 | ||||||||||||||||||
330 | } | - | ||||||||||||||||||
331 | - | |||||||||||||||||||
332 | int ec_GFp_simple_point_init(EC_POINT *point) | - | ||||||||||||||||||
333 | { | - | ||||||||||||||||||
334 | point->X = BN_new(); | - | ||||||||||||||||||
335 | point->Y = BN_new(); | - | ||||||||||||||||||
336 | point->Z = BN_new(); | - | ||||||||||||||||||
337 | point->Z_is_one = 0; | - | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | if (point->X ==
| 0-125938 | ||||||||||||||||||
340 | ((void *)0)
| 0-125938 | ||||||||||||||||||
341 | || point->Y ==
| 0-125938 | ||||||||||||||||||
342 | ((void *)0)
| 0-125938 | ||||||||||||||||||
343 | || point->Z ==
| 0-125938 | ||||||||||||||||||
344 | ((void *)0)
| 0-125938 | ||||||||||||||||||
345 | ) { | - | ||||||||||||||||||
346 | BN_free(point->X); | - | ||||||||||||||||||
347 | BN_free(point->Y); | - | ||||||||||||||||||
348 | BN_free(point->Z); | - | ||||||||||||||||||
349 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
350 | } | - | ||||||||||||||||||
351 | return executed 125938 times by 2 tests: 1;return 1; Executed by:
executed 125938 times by 2 tests: return 1; Executed by:
| 125938 | ||||||||||||||||||
352 | } | - | ||||||||||||||||||
353 | - | |||||||||||||||||||
354 | void ec_GFp_simple_point_finish(EC_POINT *point) | - | ||||||||||||||||||
355 | { | - | ||||||||||||||||||
356 | BN_free(point->X); | - | ||||||||||||||||||
357 | BN_free(point->Y); | - | ||||||||||||||||||
358 | BN_free(point->Z); | - | ||||||||||||||||||
359 | } executed 118822 times by 2 tests: end of block Executed by:
| 118822 | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | void ec_GFp_simple_point_clear_finish(EC_POINT *point) | - | ||||||||||||||||||
362 | { | - | ||||||||||||||||||
363 | BN_clear_free(point->X); | - | ||||||||||||||||||
364 | BN_clear_free(point->Y); | - | ||||||||||||||||||
365 | BN_clear_free(point->Z); | - | ||||||||||||||||||
366 | point->Z_is_one = 0; | - | ||||||||||||||||||
367 | } executed 7116 times by 2 tests: end of block Executed by:
| 7116 | ||||||||||||||||||
368 | - | |||||||||||||||||||
369 | int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) | - | ||||||||||||||||||
370 | { | - | ||||||||||||||||||
371 | if (!BN_copy(dest->X, src->X)
| 0-59140 | ||||||||||||||||||
372 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
373 | if (!BN_copy(dest->Y, src->Y)
| 0-59140 | ||||||||||||||||||
374 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
375 | if (!BN_copy(dest->Z, src->Z)
| 0-59140 | ||||||||||||||||||
376 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
377 | dest->Z_is_one = src->Z_is_one; | - | ||||||||||||||||||
378 | dest->curve_name = src->curve_name; | - | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | return executed 59140 times by 2 tests: 1;return 1; Executed by:
executed 59140 times by 2 tests: return 1; Executed by:
| 59140 | ||||||||||||||||||
381 | } | - | ||||||||||||||||||
382 | - | |||||||||||||||||||
383 | int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, | - | ||||||||||||||||||
384 | EC_POINT *point) | - | ||||||||||||||||||
385 | { | - | ||||||||||||||||||
386 | point->Z_is_one = 0; | - | ||||||||||||||||||
387 | (BN_set_word((point->Z),0)); | - | ||||||||||||||||||
388 | return executed 549 times by 1 test: 1;return 1; Executed by:
executed 549 times by 1 test: return 1; Executed by:
| 549 | ||||||||||||||||||
389 | } | - | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *group, | - | ||||||||||||||||||
392 | EC_POINT *point, | - | ||||||||||||||||||
393 | const BIGNUM *x, | - | ||||||||||||||||||
394 | const BIGNUM *y, | - | ||||||||||||||||||
395 | const BIGNUM *z, | - | ||||||||||||||||||
396 | BN_CTX *ctx) | - | ||||||||||||||||||
397 | { | - | ||||||||||||||||||
398 | BN_CTX *new_ctx = | - | ||||||||||||||||||
399 | ((void *)0) | - | ||||||||||||||||||
400 | ; | - | ||||||||||||||||||
401 | int ret = 0; | - | ||||||||||||||||||
402 | - | |||||||||||||||||||
403 | if (ctx ==
| 2-47759 | ||||||||||||||||||
404 | ((void *)0)
| 2-47759 | ||||||||||||||||||
405 | ) { | - | ||||||||||||||||||
406 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
407 | if (ctx ==
| 0-2 | ||||||||||||||||||
408 | ((void *)0)
| 0-2 | ||||||||||||||||||
409 | ) | - | ||||||||||||||||||
410 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
411 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
412 | - | |||||||||||||||||||
413 | if (x !=
| 0-47761 | ||||||||||||||||||
414 | ((void *)0)
| 0-47761 | ||||||||||||||||||
415 | ) { | - | ||||||||||||||||||
416 | if (!BN_nnmod(point->X, x, group->field, ctx)
| 0-47761 | ||||||||||||||||||
417 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
418 | if (group->meth->field_encode
| 0-47761 | ||||||||||||||||||
419 | if (!group->meth->field_encode(group, point->X, point->X, ctx)
| 0-47761 | ||||||||||||||||||
420 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
421 | } executed 47761 times by 2 tests: end of block Executed by:
| 47761 | ||||||||||||||||||
422 | } executed 47761 times by 2 tests: end of block Executed by:
| 47761 | ||||||||||||||||||
423 | - | |||||||||||||||||||
424 | if (y !=
| 0-47761 | ||||||||||||||||||
425 | ((void *)0)
| 0-47761 | ||||||||||||||||||
426 | ) { | - | ||||||||||||||||||
427 | if (!BN_nnmod(point->Y, y, group->field, ctx)
| 0-47761 | ||||||||||||||||||
428 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
429 | if (group->meth->field_encode
| 0-47761 | ||||||||||||||||||
430 | if (!group->meth->field_encode(group, point->Y, point->Y, ctx)
| 0-47761 | ||||||||||||||||||
431 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
432 | } executed 47761 times by 2 tests: end of block Executed by:
| 47761 | ||||||||||||||||||
433 | } executed 47761 times by 2 tests: end of block Executed by:
| 47761 | ||||||||||||||||||
434 | - | |||||||||||||||||||
435 | if (z !=
| 0-47761 | ||||||||||||||||||
436 | ((void *)0)
| 0-47761 | ||||||||||||||||||
437 | ) { | - | ||||||||||||||||||
438 | int Z_is_one; | - | ||||||||||||||||||
439 | - | |||||||||||||||||||
440 | if (!BN_nnmod(point->Z, z, group->field, ctx)
| 0-47761 | ||||||||||||||||||
441 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
442 | Z_is_one = BN_is_one(point->Z); | - | ||||||||||||||||||
443 | if (group->meth->field_encode
| 0-47761 | ||||||||||||||||||
444 | if (Z_is_one
| 0-47761 | ||||||||||||||||||
445 | if (!group->meth->field_set_to_one(group, point->Z, ctx)
| 0-47761 | ||||||||||||||||||
446 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
447 | } executed 47761 times by 2 tests: else {end of block Executed by:
| 47761 | ||||||||||||||||||
448 | if (!group->
| 0 | ||||||||||||||||||
449 | meth->field_encode(group, point->Z, point->Z, ctx)
| 0 | ||||||||||||||||||
450 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
451 | } never executed: end of block | 0 | ||||||||||||||||||
452 | } | - | ||||||||||||||||||
453 | point->Z_is_one = Z_is_one; | - | ||||||||||||||||||
454 | } executed 47761 times by 2 tests: end of block Executed by:
| 47761 | ||||||||||||||||||
455 | - | |||||||||||||||||||
456 | ret = 1; | - | ||||||||||||||||||
457 | - | |||||||||||||||||||
458 | err: code before this statement executed 47761 times by 2 tests: err: Executed by:
| 47761 | ||||||||||||||||||
459 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
460 | return executed 47761 times by 2 tests: ret;return ret; Executed by:
executed 47761 times by 2 tests: return ret; Executed by:
| 47761 | ||||||||||||||||||
461 | } | - | ||||||||||||||||||
462 | - | |||||||||||||||||||
463 | int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *group, | - | ||||||||||||||||||
464 | const EC_POINT *point, | - | ||||||||||||||||||
465 | BIGNUM *x, BIGNUM *y, | - | ||||||||||||||||||
466 | BIGNUM *z, BN_CTX *ctx) | - | ||||||||||||||||||
467 | { | - | ||||||||||||||||||
468 | BN_CTX *new_ctx = | - | ||||||||||||||||||
469 | ((void *)0) | - | ||||||||||||||||||
470 | ; | - | ||||||||||||||||||
471 | int ret = 0; | - | ||||||||||||||||||
472 | - | |||||||||||||||||||
473 | if (group->meth->field_decode != 0
| 0-1 | ||||||||||||||||||
474 | if (ctx ==
| 0-1 | ||||||||||||||||||
475 | ((void *)0)
| 0-1 | ||||||||||||||||||
476 | ) { | - | ||||||||||||||||||
477 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
478 | if (ctx ==
| 0 | ||||||||||||||||||
479 | ((void *)0)
| 0 | ||||||||||||||||||
480 | ) | - | ||||||||||||||||||
481 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
482 | } never executed: end of block | 0 | ||||||||||||||||||
483 | - | |||||||||||||||||||
484 | if (x !=
| 0-1 | ||||||||||||||||||
485 | ((void *)0)
| 0-1 | ||||||||||||||||||
486 | ) { | - | ||||||||||||||||||
487 | if (!group->meth->field_decode(group, x, point->X, ctx)
| 0-1 | ||||||||||||||||||
488 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
489 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
490 | if (y !=
| 0-1 | ||||||||||||||||||
491 | ((void *)0)
| 0-1 | ||||||||||||||||||
492 | ) { | - | ||||||||||||||||||
493 | if (!group->meth->field_decode(group, y, point->Y, ctx)
| 0-1 | ||||||||||||||||||
494 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
495 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
496 | if (z !=
| 0-1 | ||||||||||||||||||
497 | ((void *)0)
| 0-1 | ||||||||||||||||||
498 | ) { | - | ||||||||||||||||||
499 | if (!group->meth->field_decode(group, z, point->Z, ctx)
| 0-1 | ||||||||||||||||||
500 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
501 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
502 | } executed 1 time by 1 test: else {end of block Executed by:
| 1 | ||||||||||||||||||
503 | if (x !=
| 0 | ||||||||||||||||||
504 | ((void *)0)
| 0 | ||||||||||||||||||
505 | ) { | - | ||||||||||||||||||
506 | if (!BN_copy(x, point->X)
| 0 | ||||||||||||||||||
507 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
508 | } never executed: end of block | 0 | ||||||||||||||||||
509 | if (y !=
| 0 | ||||||||||||||||||
510 | ((void *)0)
| 0 | ||||||||||||||||||
511 | ) { | - | ||||||||||||||||||
512 | if (!BN_copy(y, point->Y)
| 0 | ||||||||||||||||||
513 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
514 | } never executed: end of block | 0 | ||||||||||||||||||
515 | if (z !=
| 0 | ||||||||||||||||||
516 | ((void *)0)
| 0 | ||||||||||||||||||
517 | ) { | - | ||||||||||||||||||
518 | if (!BN_copy(z, point->Z)
| 0 | ||||||||||||||||||
519 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
520 | } never executed: end of block | 0 | ||||||||||||||||||
521 | } never executed: end of block | 0 | ||||||||||||||||||
522 | - | |||||||||||||||||||
523 | ret = 1; | - | ||||||||||||||||||
524 | - | |||||||||||||||||||
525 | err: code before this statement executed 1 time by 1 test: err: Executed by:
| 1 | ||||||||||||||||||
526 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
527 | return executed 1 time by 1 test: ret;return ret; Executed by:
executed 1 time by 1 test: return ret; Executed by:
| 1 | ||||||||||||||||||
528 | } | - | ||||||||||||||||||
529 | - | |||||||||||||||||||
530 | int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, | - | ||||||||||||||||||
531 | EC_POINT *point, | - | ||||||||||||||||||
532 | const BIGNUM *x, | - | ||||||||||||||||||
533 | const BIGNUM *y, BN_CTX *ctx) | - | ||||||||||||||||||
534 | { | - | ||||||||||||||||||
535 | if (x ==
| 0-47761 | ||||||||||||||||||
536 | ((void *)0)
| 0-47761 | ||||||||||||||||||
537 | || y ==
| 0-47761 | ||||||||||||||||||
538 | ((void *)0)
| 0-47761 | ||||||||||||||||||
539 | ) { | - | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | - | |||||||||||||||||||
542 | - | |||||||||||||||||||
543 | ERR_put_error(16,(168),((3|64)),__FILE__,487) | - | ||||||||||||||||||
544 | ; | - | ||||||||||||||||||
545 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
546 | } | - | ||||||||||||||||||
547 | - | |||||||||||||||||||
548 | return executed 47761 times by 2 tests: EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y,return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); Executed by:
executed 47761 times by 2 tests: return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); Executed by:
| 47761 | ||||||||||||||||||
549 | BN_value_one(), ctx); executed 47761 times by 2 tests: return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); Executed by:
| 47761 | ||||||||||||||||||
550 | } | - | ||||||||||||||||||
551 | - | |||||||||||||||||||
552 | int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, | - | ||||||||||||||||||
553 | const EC_POINT *point, | - | ||||||||||||||||||
554 | BIGNUM *x, BIGNUM *y, | - | ||||||||||||||||||
555 | BN_CTX *ctx) | - | ||||||||||||||||||
556 | { | - | ||||||||||||||||||
557 | BN_CTX *new_ctx = | - | ||||||||||||||||||
558 | ((void *)0) | - | ||||||||||||||||||
559 | ; | - | ||||||||||||||||||
560 | BIGNUM *Z, *Z_1, *Z_2, *Z_3; | - | ||||||||||||||||||
561 | const BIGNUM *Z_; | - | ||||||||||||||||||
562 | int ret = 0; | - | ||||||||||||||||||
563 | - | |||||||||||||||||||
564 | if (EC_POINT_is_at_infinity(group, point)
| 0-1571 | ||||||||||||||||||
565 | ERR_put_error(16,(167),(106),__FILE__,507) | - | ||||||||||||||||||
566 | ; | - | ||||||||||||||||||
567 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
568 | } | - | ||||||||||||||||||
569 | - | |||||||||||||||||||
570 | if (ctx ==
| 0-1571 | ||||||||||||||||||
571 | ((void *)0)
| 0-1571 | ||||||||||||||||||
572 | ) { | - | ||||||||||||||||||
573 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
574 | if (ctx ==
| 0 | ||||||||||||||||||
575 | ((void *)0)
| 0 | ||||||||||||||||||
576 | ) | - | ||||||||||||||||||
577 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
578 | } never executed: end of block | 0 | ||||||||||||||||||
579 | - | |||||||||||||||||||
580 | BN_CTX_start(ctx); | - | ||||||||||||||||||
581 | Z = BN_CTX_get(ctx); | - | ||||||||||||||||||
582 | Z_1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
583 | Z_2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
584 | Z_3 = BN_CTX_get(ctx); | - | ||||||||||||||||||
585 | if (Z_3 ==
| 0-1571 | ||||||||||||||||||
586 | ((void *)0)
| 0-1571 | ||||||||||||||||||
587 | ) | - | ||||||||||||||||||
588 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
589 | - | |||||||||||||||||||
590 | - | |||||||||||||||||||
591 | - | |||||||||||||||||||
592 | if (group->meth->field_decode
| 0-1571 | ||||||||||||||||||
593 | if (!group->meth->field_decode(group, Z, point->Z, ctx)
| 0-1571 | ||||||||||||||||||
594 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
595 | Z_ = Z; | - | ||||||||||||||||||
596 | } executed 1571 times by 2 tests: else {end of block Executed by:
| 1571 | ||||||||||||||||||
597 | Z_ = point->Z; | - | ||||||||||||||||||
598 | } never executed: end of block | 0 | ||||||||||||||||||
599 | - | |||||||||||||||||||
600 | if (BN_is_one(Z_)
| 136-1435 | ||||||||||||||||||
601 | if (group->meth->field_decode
| 0-136 | ||||||||||||||||||
602 | if (x !=
| 0-136 | ||||||||||||||||||
603 | ((void *)0)
| 0-136 | ||||||||||||||||||
604 | ) { | - | ||||||||||||||||||
605 | if (!group->meth->field_decode(group, x, point->X, ctx)
| 0-136 | ||||||||||||||||||
606 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
607 | } executed 136 times by 2 tests: end of block Executed by:
| 136 | ||||||||||||||||||
608 | if (y !=
| 0-136 | ||||||||||||||||||
609 | ((void *)0)
| 0-136 | ||||||||||||||||||
610 | ) { | - | ||||||||||||||||||
611 | if (!group->meth->field_decode(group, y, point->Y, ctx)
| 0-136 | ||||||||||||||||||
612 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
613 | } executed 136 times by 2 tests: end of block Executed by:
| 136 | ||||||||||||||||||
614 | } executed 136 times by 2 tests: else {end of block Executed by:
| 136 | ||||||||||||||||||
615 | if (x !=
| 0 | ||||||||||||||||||
616 | ((void *)0)
| 0 | ||||||||||||||||||
617 | ) { | - | ||||||||||||||||||
618 | if (!BN_copy(x, point->X)
| 0 | ||||||||||||||||||
619 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
620 | } never executed: end of block | 0 | ||||||||||||||||||
621 | if (y !=
| 0 | ||||||||||||||||||
622 | ((void *)0)
| 0 | ||||||||||||||||||
623 | ) { | - | ||||||||||||||||||
624 | if (!BN_copy(y, point->Y)
| 0 | ||||||||||||||||||
625 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
626 | } never executed: end of block | 0 | ||||||||||||||||||
627 | } never executed: end of block | 0 | ||||||||||||||||||
628 | } else { | - | ||||||||||||||||||
629 | if (!BN_mod_inverse(Z_1, Z_, group->field, ctx)
| 0-1435 | ||||||||||||||||||
630 | ERR_put_error(16,(167),(3),__FILE__,558) | - | ||||||||||||||||||
631 | ; | - | ||||||||||||||||||
632 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
633 | } | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | if (group->meth->field_encode == 0
| 0-1435 | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)
| 0 | ||||||||||||||||||
638 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
639 | } never executed: else {end of block | 0 | ||||||||||||||||||
640 | if (!BN_mod_sqr(Z_2, Z_1, group->field, ctx)
| 0-1435 | ||||||||||||||||||
641 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
642 | } executed 1435 times by 2 tests: end of block Executed by:
| 1435 | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | if (x !=
| 0-1435 | ||||||||||||||||||
645 | ((void *)0)
| 0-1435 | ||||||||||||||||||
646 | ) { | - | ||||||||||||||||||
647 | - | |||||||||||||||||||
648 | - | |||||||||||||||||||
649 | - | |||||||||||||||||||
650 | - | |||||||||||||||||||
651 | if (!group->meth->field_mul(group, x, point->X, Z_2, ctx)
| 0-1435 | ||||||||||||||||||
652 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
653 | } executed 1435 times by 2 tests: end of block Executed by:
| 1435 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | if (y !=
| 651-784 | ||||||||||||||||||
656 | ((void *)0)
| 651-784 | ||||||||||||||||||
657 | ) { | - | ||||||||||||||||||
658 | if (group->meth->field_encode == 0
| 0-651 | ||||||||||||||||||
659 | - | |||||||||||||||||||
660 | - | |||||||||||||||||||
661 | - | |||||||||||||||||||
662 | if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)
| 0 | ||||||||||||||||||
663 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
664 | } never executed: else {end of block | 0 | ||||||||||||||||||
665 | if (!BN_mod_mul(Z_3, Z_2, Z_1, group->field, ctx)
| 0-651 | ||||||||||||||||||
666 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
667 | } executed 651 times by 2 tests: end of block Executed by:
| 651 | ||||||||||||||||||
668 | - | |||||||||||||||||||
669 | - | |||||||||||||||||||
670 | - | |||||||||||||||||||
671 | - | |||||||||||||||||||
672 | - | |||||||||||||||||||
673 | if (!group->meth->field_mul(group, y, point->Y, Z_3, ctx)
| 0-651 | ||||||||||||||||||
674 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
675 | } executed 651 times by 2 tests: end of block Executed by:
| 651 | ||||||||||||||||||
676 | } executed 1435 times by 2 tests: end of block Executed by:
| 1435 | ||||||||||||||||||
677 | - | |||||||||||||||||||
678 | ret = 1; | - | ||||||||||||||||||
679 | - | |||||||||||||||||||
680 | err: code before this statement executed 1571 times by 2 tests: err: Executed by:
| 1571 | ||||||||||||||||||
681 | BN_CTX_end(ctx); | - | ||||||||||||||||||
682 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
683 | return executed 1571 times by 2 tests: ret;return ret; Executed by:
executed 1571 times by 2 tests: return ret; Executed by:
| 1571 | ||||||||||||||||||
684 | } | - | ||||||||||||||||||
685 | - | |||||||||||||||||||
686 | int ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | - | ||||||||||||||||||
687 | const EC_POINT *b, BN_CTX *ctx) | - | ||||||||||||||||||
688 | { | - | ||||||||||||||||||
689 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, | - | ||||||||||||||||||
690 | const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
691 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
692 | const BIGNUM *p; | - | ||||||||||||||||||
693 | BN_CTX *new_ctx = | - | ||||||||||||||||||
694 | ((void *)0) | - | ||||||||||||||||||
695 | ; | - | ||||||||||||||||||
696 | BIGNUM *n0, *n1, *n2, *n3, *n4, *n5, *n6; | - | ||||||||||||||||||
697 | int ret = 0; | - | ||||||||||||||||||
698 | - | |||||||||||||||||||
699 | if (a == b
| 0-73642 | ||||||||||||||||||
700 | return never executed: EC_POINT_dbl(group, r, a, ctx);return EC_POINT_dbl(group, r, a, ctx); never executed: return EC_POINT_dbl(group, r, a, ctx); | 0 | ||||||||||||||||||
701 | if (EC_POINT_is_at_infinity(group, a)
| 2019-71623 | ||||||||||||||||||
702 | return executed 2019 times by 1 test: EC_POINT_copy(r, b);return EC_POINT_copy(r, b); Executed by:
executed 2019 times by 1 test: return EC_POINT_copy(r, b); Executed by:
| 2019 | ||||||||||||||||||
703 | if (EC_POINT_is_at_infinity(group, b)
| 18316-53307 | ||||||||||||||||||
704 | return executed 18316 times by 1 test: EC_POINT_copy(r, a);return EC_POINT_copy(r, a); Executed by:
executed 18316 times by 1 test: return EC_POINT_copy(r, a); Executed by:
| 18316 | ||||||||||||||||||
705 | - | |||||||||||||||||||
706 | field_mul = group->meth->field_mul; | - | ||||||||||||||||||
707 | field_sqr = group->meth->field_sqr; | - | ||||||||||||||||||
708 | p = group->field; | - | ||||||||||||||||||
709 | - | |||||||||||||||||||
710 | if (ctx ==
| 0-53307 | ||||||||||||||||||
711 | ((void *)0)
| 0-53307 | ||||||||||||||||||
712 | ) { | - | ||||||||||||||||||
713 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
714 | if (ctx ==
| 0 | ||||||||||||||||||
715 | ((void *)0)
| 0 | ||||||||||||||||||
716 | ) | - | ||||||||||||||||||
717 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
718 | } never executed: end of block | 0 | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | BN_CTX_start(ctx); | - | ||||||||||||||||||
721 | n0 = BN_CTX_get(ctx); | - | ||||||||||||||||||
722 | n1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
723 | n2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
724 | n3 = BN_CTX_get(ctx); | - | ||||||||||||||||||
725 | n4 = BN_CTX_get(ctx); | - | ||||||||||||||||||
726 | n5 = BN_CTX_get(ctx); | - | ||||||||||||||||||
727 | n6 = BN_CTX_get(ctx); | - | ||||||||||||||||||
728 | if (n6 ==
| 0-53307 | ||||||||||||||||||
729 | ((void *)0)
| 0-53307 | ||||||||||||||||||
730 | ) | - | ||||||||||||||||||
731 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
732 | if (b->Z_is_one
| 13422-39885 | ||||||||||||||||||
733 | if (!BN_copy(n1, a->X)
| 0-39885 | ||||||||||||||||||
734 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
735 | if (!BN_copy(n2, a->Y)
| 0-39885 | ||||||||||||||||||
736 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | - | |||||||||||||||||||
739 | } executed 39885 times by 2 tests: else {end of block Executed by:
| 39885 | ||||||||||||||||||
740 | if (!field_sqr(group, n0, b->Z, ctx)
| 0-13422 | ||||||||||||||||||
741 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
742 | if (!field_mul(group, n1, a->X, n0, ctx)
| 0-13422 | ||||||||||||||||||
743 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
744 | - | |||||||||||||||||||
745 | - | |||||||||||||||||||
746 | if (!field_mul(group, n0, n0, b->Z, ctx)
| 0-13422 | ||||||||||||||||||
747 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
748 | if (!field_mul(group, n2, a->Y, n0, ctx)
| 0-13422 | ||||||||||||||||||
749 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
750 | - | |||||||||||||||||||
751 | } executed 13422 times by 2 tests: end of block Executed by:
| 13422 | ||||||||||||||||||
752 | - | |||||||||||||||||||
753 | - | |||||||||||||||||||
754 | if (a->Z_is_one
| 550-52757 | ||||||||||||||||||
755 | if (!BN_copy(n3, b->X)
| 0-550 | ||||||||||||||||||
756 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
757 | if (!BN_copy(n4, b->Y)
| 0-550 | ||||||||||||||||||
758 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
759 | - | |||||||||||||||||||
760 | - | |||||||||||||||||||
761 | } executed 550 times by 2 tests: else {end of block Executed by:
| 550 | ||||||||||||||||||
762 | if (!field_sqr(group, n0, a->Z, ctx)
| 0-52757 | ||||||||||||||||||
763 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
764 | if (!field_mul(group, n3, b->X, n0, ctx)
| 0-52757 | ||||||||||||||||||
765 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
766 | - | |||||||||||||||||||
767 | - | |||||||||||||||||||
768 | if (!field_mul(group, n0, n0, a->Z, ctx)
| 0-52757 | ||||||||||||||||||
769 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
770 | if (!field_mul(group, n4, b->Y, n0, ctx)
| 0-52757 | ||||||||||||||||||
771 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
772 | - | |||||||||||||||||||
773 | } executed 52757 times by 2 tests: end of block Executed by:
| 52757 | ||||||||||||||||||
774 | - | |||||||||||||||||||
775 | - | |||||||||||||||||||
776 | if (!BN_mod_sub_quick(n5, n1, n3, p)
| 0-53307 | ||||||||||||||||||
777 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
778 | if (!BN_mod_sub_quick(n6, n2, n4, p)
| 0-53307 | ||||||||||||||||||
779 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | - | |||||||||||||||||||
782 | - | |||||||||||||||||||
783 | if (BN_is_zero(n5)
| 305-53002 | ||||||||||||||||||
784 | if (BN_is_zero(n6)
| 93-212 | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | BN_CTX_end(ctx); | - | ||||||||||||||||||
787 | ret = EC_POINT_dbl(group, r, a, ctx); | - | ||||||||||||||||||
788 | ctx = | - | ||||||||||||||||||
789 | ((void *)0) | - | ||||||||||||||||||
790 | ; | - | ||||||||||||||||||
791 | goto executed 93 times by 1 test: end;goto end; Executed by:
executed 93 times by 1 test: goto end; Executed by:
| 93 | ||||||||||||||||||
792 | } else { | - | ||||||||||||||||||
793 | - | |||||||||||||||||||
794 | (BN_set_word((r->Z),0)); | - | ||||||||||||||||||
795 | r->Z_is_one = 0; | - | ||||||||||||||||||
796 | ret = 1; | - | ||||||||||||||||||
797 | goto executed 212 times by 1 test: end;goto end; Executed by:
executed 212 times by 1 test: goto end; Executed by:
| 212 | ||||||||||||||||||
798 | } | - | ||||||||||||||||||
799 | } | - | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | - | |||||||||||||||||||
802 | if (!BN_mod_add_quick(n1, n1, n3, p)
| 0-53002 | ||||||||||||||||||
803 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
804 | if (!BN_mod_add_quick(n2, n2, n4, p)
| 0-53002 | ||||||||||||||||||
805 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | - | |||||||||||||||||||
808 | - | |||||||||||||||||||
809 | - | |||||||||||||||||||
810 | if (a->Z_is_one
| 44-52547 | ||||||||||||||||||
811 | if (!BN_copy(r->Z, n5)
| 0-44 | ||||||||||||||||||
812 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
813 | } executed 44 times by 1 test: else {end of block Executed by:
| 44 | ||||||||||||||||||
814 | if (a->Z_is_one
| 411-52547 | ||||||||||||||||||
815 | if (!BN_copy(n0, b->Z)
| 0-411 | ||||||||||||||||||
816 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
817 | } executed 411 times by 2 tests: else if (b->Z_is_oneend of block Executed by:
| 411-39627 | ||||||||||||||||||
818 | if (!BN_copy(n0, a->Z)
| 0-39627 | ||||||||||||||||||
819 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
820 | } executed 39627 times by 2 tests: else {end of block Executed by:
| 39627 | ||||||||||||||||||
821 | if (!field_mul(group, n0, a->Z, b->Z, ctx)
| 0-12920 | ||||||||||||||||||
822 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
823 | } executed 12920 times by 2 tests: end of block Executed by:
| 12920 | ||||||||||||||||||
824 | if (!field_mul(group, r->Z, n0, n5, ctx)
| 0-52958 | ||||||||||||||||||
825 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
826 | } executed 52958 times by 2 tests: end of block Executed by:
| 52958 | ||||||||||||||||||
827 | r->Z_is_one = 0; | - | ||||||||||||||||||
828 | - | |||||||||||||||||||
829 | - | |||||||||||||||||||
830 | - | |||||||||||||||||||
831 | if (!field_sqr(group, n0, n6, ctx)
| 0-53002 | ||||||||||||||||||
832 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
833 | if (!field_sqr(group, n4, n5, ctx)
| 0-53002 | ||||||||||||||||||
834 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
835 | if (!field_mul(group, n3, n1, n4, ctx)
| 0-53002 | ||||||||||||||||||
836 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
837 | if (!BN_mod_sub_quick(r->X, n0, n3, p)
| 0-53002 | ||||||||||||||||||
838 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
839 | - | |||||||||||||||||||
840 | - | |||||||||||||||||||
841 | - | |||||||||||||||||||
842 | if (!BN_mod_lshift1_quick(n0, r->X, p)
| 0-53002 | ||||||||||||||||||
843 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
844 | if (!BN_mod_sub_quick(n0, n3, n0, p)
| 0-53002 | ||||||||||||||||||
845 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
846 | - | |||||||||||||||||||
847 | - | |||||||||||||||||||
848 | - | |||||||||||||||||||
849 | if (!field_mul(group, n0, n0, n6, ctx)
| 0-53002 | ||||||||||||||||||
850 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
851 | if (!field_mul(group, n5, n4, n5, ctx)
| 0-53002 | ||||||||||||||||||
852 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
853 | if (!field_mul(group, n1, n2, n5, ctx)
| 0-53002 | ||||||||||||||||||
854 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
855 | if (!BN_mod_sub_quick(n0, n0, n1, p)
| 0-53002 | ||||||||||||||||||
856 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
857 | if (BN_is_odd(n0)
| 26405-26597 | ||||||||||||||||||
858 | if (!BN_add(n0, n0, p)
| 0-26405 | ||||||||||||||||||
859 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
860 | - | |||||||||||||||||||
861 | if (!BN_rshift1(r->Y, n0)
| 0-53002 | ||||||||||||||||||
862 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
863 | - | |||||||||||||||||||
864 | - | |||||||||||||||||||
865 | ret = 1; | - | ||||||||||||||||||
866 | - | |||||||||||||||||||
867 | end: code before this statement executed 53002 times by 2 tests: end: Executed by:
| 53002 | ||||||||||||||||||
868 | if (ctx
| 93-53214 | ||||||||||||||||||
869 | BN_CTX_end(ctx); executed 53214 times by 2 tests: BN_CTX_end(ctx); Executed by:
| 53214 | ||||||||||||||||||
870 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
871 | return executed 53307 times by 2 tests: ret;return ret; Executed by:
executed 53307 times by 2 tests: return ret; Executed by:
| 53307 | ||||||||||||||||||
872 | } | - | ||||||||||||||||||
873 | - | |||||||||||||||||||
874 | int ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | - | ||||||||||||||||||
875 | BN_CTX *ctx) | - | ||||||||||||||||||
876 | { | - | ||||||||||||||||||
877 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, | - | ||||||||||||||||||
878 | const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
879 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
880 | const BIGNUM *p; | - | ||||||||||||||||||
881 | BN_CTX *new_ctx = | - | ||||||||||||||||||
882 | ((void *)0) | - | ||||||||||||||||||
883 | ; | - | ||||||||||||||||||
884 | BIGNUM *n0, *n1, *n2, *n3; | - | ||||||||||||||||||
885 | int ret = 0; | - | ||||||||||||||||||
886 | - | |||||||||||||||||||
887 | if (EC_POINT_is_at_infinity(group, a)
| 681-147151 | ||||||||||||||||||
888 | (BN_set_word((r->Z),0)); | - | ||||||||||||||||||
889 | r->Z_is_one = 0; | - | ||||||||||||||||||
890 | return executed 681 times by 1 test: 1;return 1; Executed by:
executed 681 times by 1 test: return 1; Executed by:
| 681 | ||||||||||||||||||
891 | } | - | ||||||||||||||||||
892 | - | |||||||||||||||||||
893 | field_mul = group->meth->field_mul; | - | ||||||||||||||||||
894 | field_sqr = group->meth->field_sqr; | - | ||||||||||||||||||
895 | p = group->field; | - | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | if (ctx ==
| 0-147151 | ||||||||||||||||||
898 | ((void *)0)
| 0-147151 | ||||||||||||||||||
899 | ) { | - | ||||||||||||||||||
900 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
901 | if (ctx ==
| 0 | ||||||||||||||||||
902 | ((void *)0)
| 0 | ||||||||||||||||||
903 | ) | - | ||||||||||||||||||
904 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
905 | } never executed: end of block | 0 | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | BN_CTX_start(ctx); | - | ||||||||||||||||||
908 | n0 = BN_CTX_get(ctx); | - | ||||||||||||||||||
909 | n1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
910 | n2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
911 | n3 = BN_CTX_get(ctx); | - | ||||||||||||||||||
912 | if (n3 ==
| 0-147151 | ||||||||||||||||||
913 | ((void *)0)
| 0-147151 | ||||||||||||||||||
914 | ) | - | ||||||||||||||||||
915 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
916 | if (a->Z_is_one
| 954-146197 | ||||||||||||||||||
917 | if (!field_sqr(group, n0, a->X, ctx)
| 0-954 | ||||||||||||||||||
918 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
919 | if (!BN_mod_lshift1_quick(n1, n0, p)
| 0-954 | ||||||||||||||||||
920 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
921 | if (!BN_mod_add_quick(n0, n0, n1, p)
| 0-954 | ||||||||||||||||||
922 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
923 | if (!BN_mod_add_quick(n1, n0, group->a, p)
| 0-954 | ||||||||||||||||||
924 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
925 | - | |||||||||||||||||||
926 | } executed 954 times by 2 tests: else if (group->a_is_minus3end of block Executed by:
| 954-112068 | ||||||||||||||||||
927 | if (!field_sqr(group, n1, a->Z, ctx)
| 0-112068 | ||||||||||||||||||
928 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
929 | if (!BN_mod_add_quick(n0, a->X, n1, p)
| 0-112068 | ||||||||||||||||||
930 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
931 | if (!BN_mod_sub_quick(n2, a->X, n1, p)
| 0-112068 | ||||||||||||||||||
932 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
933 | if (!field_mul(group, n1, n0, n2, ctx)
| 0-112068 | ||||||||||||||||||
934 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
935 | if (!BN_mod_lshift1_quick(n0, n1, p)
| 0-112068 | ||||||||||||||||||
936 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
937 | if (!BN_mod_add_quick(n1, n0, n1, p)
| 0-112068 | ||||||||||||||||||
938 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
939 | - | |||||||||||||||||||
940 | - | |||||||||||||||||||
941 | - | |||||||||||||||||||
942 | - | |||||||||||||||||||
943 | } executed 112068 times by 1 test: else {end of block Executed by:
| 112068 | ||||||||||||||||||
944 | if (!field_sqr(group, n0, a->X, ctx)
| 0-34129 | ||||||||||||||||||
945 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
946 | if (!BN_mod_lshift1_quick(n1, n0, p)
| 0-34129 | ||||||||||||||||||
947 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
948 | if (!BN_mod_add_quick(n0, n0, n1, p)
| 0-34129 | ||||||||||||||||||
949 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
950 | if (!field_sqr(group, n1, a->Z, ctx)
| 0-34129 | ||||||||||||||||||
951 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
952 | if (!field_sqr(group, n1, n1, ctx)
| 0-34129 | ||||||||||||||||||
953 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
954 | if (!field_mul(group, n1, n1, group->a, ctx)
| 0-34129 | ||||||||||||||||||
955 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
956 | if (!BN_mod_add_quick(n1, n1, n0, p)
| 0-34129 | ||||||||||||||||||
957 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
958 | - | |||||||||||||||||||
959 | } executed 34129 times by 2 tests: end of block Executed by:
| 34129 | ||||||||||||||||||
960 | - | |||||||||||||||||||
961 | - | |||||||||||||||||||
962 | if (a->Z_is_one
| 954-146197 | ||||||||||||||||||
963 | if (!BN_copy(n0, a->Y)
| 0-954 | ||||||||||||||||||
964 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
965 | } executed 954 times by 2 tests: else {end of block Executed by:
| 954 | ||||||||||||||||||
966 | if (!field_mul(group, n0, a->Y, a->Z, ctx)
| 0-146197 | ||||||||||||||||||
967 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
968 | } executed 146197 times by 2 tests: end of block Executed by:
| 146197 | ||||||||||||||||||
969 | if (!BN_mod_lshift1_quick(r->Z, n0, p)
| 0-147151 | ||||||||||||||||||
970 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
971 | r->Z_is_one = 0; | - | ||||||||||||||||||
972 | - | |||||||||||||||||||
973 | - | |||||||||||||||||||
974 | - | |||||||||||||||||||
975 | if (!field_sqr(group, n3, a->Y, ctx)
| 0-147151 | ||||||||||||||||||
976 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
977 | if (!field_mul(group, n2, a->X, n3, ctx)
| 0-147151 | ||||||||||||||||||
978 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
979 | if (!BN_mod_lshift_quick(n2, n2, 2, p)
| 0-147151 | ||||||||||||||||||
980 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
981 | - | |||||||||||||||||||
982 | - | |||||||||||||||||||
983 | - | |||||||||||||||||||
984 | if (!BN_mod_lshift1_quick(n0, n2, p)
| 0-147151 | ||||||||||||||||||
985 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
986 | if (!field_sqr(group, r->X, n1, ctx)
| 0-147151 | ||||||||||||||||||
987 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
988 | if (!BN_mod_sub_quick(r->X, r->X, n0, p)
| 0-147151 | ||||||||||||||||||
989 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
990 | - | |||||||||||||||||||
991 | - | |||||||||||||||||||
992 | - | |||||||||||||||||||
993 | if (!field_sqr(group, n0, n3, ctx)
| 0-147151 | ||||||||||||||||||
994 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
995 | if (!BN_mod_lshift_quick(n3, n0, 3, p)
| 0-147151 | ||||||||||||||||||
996 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
997 | - | |||||||||||||||||||
998 | - | |||||||||||||||||||
999 | - | |||||||||||||||||||
1000 | if (!BN_mod_sub_quick(n0, n2, r->X, p)
| 0-147151 | ||||||||||||||||||
1001 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1002 | if (!field_mul(group, n0, n1, n0, ctx)
| 0-147151 | ||||||||||||||||||
1003 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1004 | if (!BN_mod_sub_quick(r->Y, n0, n3, p)
| 0-147151 | ||||||||||||||||||
1005 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1006 | - | |||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | ret = 1; | - | ||||||||||||||||||
1009 | - | |||||||||||||||||||
1010 | err: code before this statement executed 147151 times by 2 tests: err: Executed by:
| 147151 | ||||||||||||||||||
1011 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1012 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
1013 | return executed 147151 times by 2 tests: ret;return ret; Executed by:
executed 147151 times by 2 tests: return ret; Executed by:
| 147151 | ||||||||||||||||||
1014 | } | - | ||||||||||||||||||
1015 | - | |||||||||||||||||||
1016 | int ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) | - | ||||||||||||||||||
1017 | { | - | ||||||||||||||||||
1018 | if (EC_POINT_is_at_infinity(group, point)
| 0-20606 | ||||||||||||||||||
1019 | - | |||||||||||||||||||
1020 | return executed 71 times by 1 test: 1;return 1; Executed by:
executed 71 times by 1 test: return 1; Executed by:
| 71 | ||||||||||||||||||
1021 | - | |||||||||||||||||||
1022 | return executed 20606 times by 2 tests: BN_usub(point->Y, group->field, point->Y);return BN_usub(point->Y, group->field, point->Y); Executed by:
executed 20606 times by 2 tests: return BN_usub(point->Y, group->field, point->Y); Executed by:
| 20606 | ||||||||||||||||||
1023 | } | - | ||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | int ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) | - | ||||||||||||||||||
1026 | { | - | ||||||||||||||||||
1027 | return executed 451791 times by 2 tests: BN_is_zero(point->Z);return BN_is_zero(point->Z); Executed by:
executed 451791 times by 2 tests: return BN_is_zero(point->Z); Executed by:
| 451791 | ||||||||||||||||||
1028 | } | - | ||||||||||||||||||
1029 | - | |||||||||||||||||||
1030 | int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, | - | ||||||||||||||||||
1031 | BN_CTX *ctx) | - | ||||||||||||||||||
1032 | { | - | ||||||||||||||||||
1033 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, | - | ||||||||||||||||||
1034 | const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
1035 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
1036 | const BIGNUM *p; | - | ||||||||||||||||||
1037 | BN_CTX *new_ctx = | - | ||||||||||||||||||
1038 | ((void *)0) | - | ||||||||||||||||||
1039 | ; | - | ||||||||||||||||||
1040 | BIGNUM *rh, *tmp, *Z4, *Z6; | - | ||||||||||||||||||
1041 | int ret = -1; | - | ||||||||||||||||||
1042 | - | |||||||||||||||||||
1043 | if (EC_POINT_is_at_infinity(group, point)
| 0-47900 | ||||||||||||||||||
1044 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
1045 | - | |||||||||||||||||||
1046 | field_mul = group->meth->field_mul; | - | ||||||||||||||||||
1047 | field_sqr = group->meth->field_sqr; | - | ||||||||||||||||||
1048 | p = group->field; | - | ||||||||||||||||||
1049 | - | |||||||||||||||||||
1050 | if (ctx ==
| 2-47898 | ||||||||||||||||||
1051 | ((void *)0)
| 2-47898 | ||||||||||||||||||
1052 | ) { | - | ||||||||||||||||||
1053 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
1054 | if (ctx ==
| 0-2 | ||||||||||||||||||
1055 | ((void *)0)
| 0-2 | ||||||||||||||||||
1056 | ) | - | ||||||||||||||||||
1057 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1058 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
1059 | - | |||||||||||||||||||
1060 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1061 | rh = BN_CTX_get(ctx); | - | ||||||||||||||||||
1062 | tmp = BN_CTX_get(ctx); | - | ||||||||||||||||||
1063 | Z4 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1064 | Z6 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1065 | if (Z6 ==
| 0-47900 | ||||||||||||||||||
1066 | ((void *)0)
| 0-47900 | ||||||||||||||||||
1067 | ) | - | ||||||||||||||||||
1068 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1069 | if (!field_sqr(group, rh, point->X, ctx)
| 0-47900 | ||||||||||||||||||
1070 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1071 | - | |||||||||||||||||||
1072 | if (!point->Z_is_one
| 35-47865 | ||||||||||||||||||
1073 | if (!field_sqr(group, tmp, point->Z, ctx)
| 0-35 | ||||||||||||||||||
1074 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1075 | if (!field_sqr(group, Z4, tmp, ctx)
| 0-35 | ||||||||||||||||||
1076 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1077 | if (!field_mul(group, Z6, Z4, tmp, ctx)
| 0-35 | ||||||||||||||||||
1078 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1079 | - | |||||||||||||||||||
1080 | - | |||||||||||||||||||
1081 | if (group->a_is_minus3
| 12-23 | ||||||||||||||||||
1082 | if (!BN_mod_lshift1_quick(tmp, Z4, p)
| 0-23 | ||||||||||||||||||
1083 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1084 | if (!BN_mod_add_quick(tmp, tmp, Z4, p)
| 0-23 | ||||||||||||||||||
1085 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1086 | if (!BN_mod_sub_quick(rh, rh, tmp, p)
| 0-23 | ||||||||||||||||||
1087 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1088 | if (!field_mul(group, rh, rh, point->X, ctx)
| 0-23 | ||||||||||||||||||
1089 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1090 | } executed 23 times by 1 test: else {end of block Executed by:
| 23 | ||||||||||||||||||
1091 | if (!field_mul(group, tmp, Z4, group->a, ctx)
| 0-12 | ||||||||||||||||||
1092 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1093 | if (!BN_mod_add_quick(rh, rh, tmp, p)
| 0-12 | ||||||||||||||||||
1094 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1095 | if (!field_mul(group, rh, rh, point->X, ctx)
| 0-12 | ||||||||||||||||||
1096 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1097 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1098 | - | |||||||||||||||||||
1099 | - | |||||||||||||||||||
1100 | if (!field_mul(group, tmp, group->b, Z6, ctx)
| 0-35 | ||||||||||||||||||
1101 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1102 | if (!BN_mod_add_quick(rh, rh, tmp, p)
| 0-35 | ||||||||||||||||||
1103 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1104 | } executed 35 times by 1 test: else {end of block Executed by:
| 35 | ||||||||||||||||||
1105 | - | |||||||||||||||||||
1106 | - | |||||||||||||||||||
1107 | - | |||||||||||||||||||
1108 | if (!BN_mod_add_quick(rh, rh, group->a, p)
| 0-47865 | ||||||||||||||||||
1109 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1110 | if (!field_mul(group, rh, rh, point->X, ctx)
| 0-47865 | ||||||||||||||||||
1111 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1112 | - | |||||||||||||||||||
1113 | if (!BN_mod_add_quick(rh, rh, group->b, p)
| 0-47865 | ||||||||||||||||||
1114 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1115 | } executed 47865 times by 2 tests: end of block Executed by:
| 47865 | ||||||||||||||||||
1116 | - | |||||||||||||||||||
1117 | - | |||||||||||||||||||
1118 | if (!field_sqr(group, tmp, point->Y, ctx)
| 0-47900 | ||||||||||||||||||
1119 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1120 | - | |||||||||||||||||||
1121 | ret = (0 == BN_ucmp(tmp, rh)); | - | ||||||||||||||||||
1122 | - | |||||||||||||||||||
1123 | err: code before this statement executed 47900 times by 2 tests: err: Executed by:
| 47900 | ||||||||||||||||||
1124 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1125 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
1126 | return executed 47900 times by 2 tests: ret;return ret; Executed by:
executed 47900 times by 2 tests: return ret; Executed by:
| 47900 | ||||||||||||||||||
1127 | } | - | ||||||||||||||||||
1128 | - | |||||||||||||||||||
1129 | int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, | - | ||||||||||||||||||
1130 | const EC_POINT *b, BN_CTX *ctx) | - | ||||||||||||||||||
1131 | { | - | ||||||||||||||||||
1132 | - | |||||||||||||||||||
1133 | - | |||||||||||||||||||
1134 | - | |||||||||||||||||||
1135 | - | |||||||||||||||||||
1136 | - | |||||||||||||||||||
1137 | - | |||||||||||||||||||
1138 | - | |||||||||||||||||||
1139 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, | - | ||||||||||||||||||
1140 | const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
1141 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||
1142 | BN_CTX *new_ctx = | - | ||||||||||||||||||
1143 | ((void *)0) | - | ||||||||||||||||||
1144 | ; | - | ||||||||||||||||||
1145 | BIGNUM *tmp1, *tmp2, *Za23, *Zb23; | - | ||||||||||||||||||
1146 | const BIGNUM *tmp1_, *tmp2_; | - | ||||||||||||||||||
1147 | int ret = -1; | - | ||||||||||||||||||
1148 | - | |||||||||||||||||||
1149 | if (EC_POINT_is_at_infinity(group, a)
| 0-7866 | ||||||||||||||||||
1150 | return never executed: EC_POINT_is_at_infinity(group, b)return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
never executed: return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 0 | ||||||||||||||||||
1151 | } | - | ||||||||||||||||||
1152 | - | |||||||||||||||||||
1153 | if (EC_POINT_is_at_infinity(group, b)
| 0-7866 | ||||||||||||||||||
1154 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
1155 | - | |||||||||||||||||||
1156 | if (a->Z_is_one
| 1-7250 | ||||||||||||||||||
1157 | return executed 7249 times by 1 test: ((return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1; Executed by:
executed 7249 times by 1 test: return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1; Executed by:
| 0-7249 | ||||||||||||||||||
1158 | } | - | ||||||||||||||||||
1159 | - | |||||||||||||||||||
1160 | field_mul = group->meth->field_mul; | - | ||||||||||||||||||
1161 | field_sqr = group->meth->field_sqr; | - | ||||||||||||||||||
1162 | - | |||||||||||||||||||
1163 | if (ctx ==
| 78-539 | ||||||||||||||||||
1164 | ((void *)0)
| 78-539 | ||||||||||||||||||
1165 | ) { | - | ||||||||||||||||||
1166 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
1167 | if (ctx ==
| 0-78 | ||||||||||||||||||
1168 | ((void *)0)
| 0-78 | ||||||||||||||||||
1169 | ) | - | ||||||||||||||||||
1170 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1171 | } executed 78 times by 1 test: end of block Executed by:
| 78 | ||||||||||||||||||
1172 | - | |||||||||||||||||||
1173 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1174 | tmp1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1175 | tmp2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1176 | Za23 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1177 | Zb23 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1178 | if (Zb23 ==
| 0-617 | ||||||||||||||||||
1179 | ((void *)0)
| 0-617 | ||||||||||||||||||
1180 | ) | - | ||||||||||||||||||
1181 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1182 | if (!b->Z_is_one
| 219-398 | ||||||||||||||||||
1183 | if (!field_sqr(group, Zb23, b->Z, ctx)
| 0-398 | ||||||||||||||||||
1184 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1185 | if (!field_mul(group, tmp1, a->X, Zb23, ctx)
| 0-398 | ||||||||||||||||||
1186 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1187 | tmp1_ = tmp1; | - | ||||||||||||||||||
1188 | } executed 398 times by 1 test: elseend of block Executed by:
| 398 | ||||||||||||||||||
1189 | tmp1_ = a->X; executed 219 times by 1 test: tmp1_ = a->X; Executed by:
| 219 | ||||||||||||||||||
1190 | if (!a->Z_is_one
| 1-616 | ||||||||||||||||||
1191 | if (!field_sqr(group, Za23, a->Z, ctx)
| 0-616 | ||||||||||||||||||
1192 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1193 | if (!field_mul(group, tmp2, b->X, Za23, ctx)
| 0-616 | ||||||||||||||||||
1194 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1195 | tmp2_ = tmp2; | - | ||||||||||||||||||
1196 | } executed 616 times by 1 test: elseend of block Executed by:
| 616 | ||||||||||||||||||
1197 | tmp2_ = b->X; executed 1 time by 1 test: tmp2_ = b->X; Executed by:
| 1 | ||||||||||||||||||
1198 | - | |||||||||||||||||||
1199 | - | |||||||||||||||||||
1200 | if (BN_cmp(tmp1_, tmp2_) != 0
| 0-617 | ||||||||||||||||||
1201 | ret = 1; | - | ||||||||||||||||||
1202 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1203 | } | - | ||||||||||||||||||
1204 | - | |||||||||||||||||||
1205 | if (!b->Z_is_one
| 219-398 | ||||||||||||||||||
1206 | if (!field_mul(group, Zb23, Zb23, b->Z, ctx)
| 0-398 | ||||||||||||||||||
1207 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1208 | if (!field_mul(group, tmp1, a->Y, Zb23, ctx)
| 0-398 | ||||||||||||||||||
1209 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1210 | - | |||||||||||||||||||
1211 | } executed 398 times by 1 test: elseend of block Executed by:
| 398 | ||||||||||||||||||
1212 | tmp1_ = a->Y; executed 219 times by 1 test: tmp1_ = a->Y; Executed by:
| 219 | ||||||||||||||||||
1213 | if (!a->Z_is_one
| 1-616 | ||||||||||||||||||
1214 | if (!field_mul(group, Za23, Za23, a->Z, ctx)
| 0-616 | ||||||||||||||||||
1215 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1216 | if (!field_mul(group, tmp2, b->Y, Za23, ctx)
| 0-616 | ||||||||||||||||||
1217 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1218 | - | |||||||||||||||||||
1219 | } executed 616 times by 1 test: elseend of block Executed by:
| 616 | ||||||||||||||||||
1220 | tmp2_ = b->Y; executed 1 time by 1 test: tmp2_ = b->Y; Executed by:
| 1 | ||||||||||||||||||
1221 | - | |||||||||||||||||||
1222 | - | |||||||||||||||||||
1223 | if (BN_cmp(tmp1_, tmp2_) != 0
| 0-617 | ||||||||||||||||||
1224 | ret = 1; | - | ||||||||||||||||||
1225 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
1226 | } | - | ||||||||||||||||||
1227 | - | |||||||||||||||||||
1228 | - | |||||||||||||||||||
1229 | ret = 0; | - | ||||||||||||||||||
1230 | - | |||||||||||||||||||
1231 | end: code before this statement executed 617 times by 1 test: end: Executed by:
| 617 | ||||||||||||||||||
1232 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1233 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
1234 | return executed 617 times by 1 test: ret;return ret; Executed by:
executed 617 times by 1 test: return ret; Executed by:
| 617 | ||||||||||||||||||
1235 | } | - | ||||||||||||||||||
1236 | - | |||||||||||||||||||
1237 | int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, | - | ||||||||||||||||||
1238 | BN_CTX *ctx) | - | ||||||||||||||||||
1239 | { | - | ||||||||||||||||||
1240 | BN_CTX *new_ctx = | - | ||||||||||||||||||
1241 | ((void *)0) | - | ||||||||||||||||||
1242 | ; | - | ||||||||||||||||||
1243 | BIGNUM *x, *y; | - | ||||||||||||||||||
1244 | int ret = 0; | - | ||||||||||||||||||
1245 | - | |||||||||||||||||||
1246 | if (point->Z_is_one
| 0 | ||||||||||||||||||
1247 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
1248 | - | |||||||||||||||||||
1249 | if (ctx ==
| 0 | ||||||||||||||||||
1250 | ((void *)0)
| 0 | ||||||||||||||||||
1251 | ) { | - | ||||||||||||||||||
1252 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
1253 | if (ctx ==
| 0 | ||||||||||||||||||
1254 | ((void *)0)
| 0 | ||||||||||||||||||
1255 | ) | - | ||||||||||||||||||
1256 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1257 | } never executed: end of block | 0 | ||||||||||||||||||
1258 | - | |||||||||||||||||||
1259 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1260 | x = BN_CTX_get(ctx); | - | ||||||||||||||||||
1261 | y = BN_CTX_get(ctx); | - | ||||||||||||||||||
1262 | if (y ==
| 0 | ||||||||||||||||||
1263 | ((void *)0)
| 0 | ||||||||||||||||||
1264 | ) | - | ||||||||||||||||||
1265 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)
| 0 | ||||||||||||||||||
1268 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1269 | if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)
| 0 | ||||||||||||||||||
1270 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1271 | if (!point->Z_is_one
| 0 | ||||||||||||||||||
1272 | ERR_put_error(16,(102),((4|64)),__FILE__,1189); | - | ||||||||||||||||||
1273 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1274 | } | - | ||||||||||||||||||
1275 | - | |||||||||||||||||||
1276 | ret = 1; | - | ||||||||||||||||||
1277 | - | |||||||||||||||||||
1278 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||
1279 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1280 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
1281 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||
1282 | } | - | ||||||||||||||||||
1283 | - | |||||||||||||||||||
1284 | int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, | - | ||||||||||||||||||
1285 | EC_POINT *points[], BN_CTX *ctx) | - | ||||||||||||||||||
1286 | { | - | ||||||||||||||||||
1287 | BN_CTX *new_ctx = | - | ||||||||||||||||||
1288 | ((void *)0) | - | ||||||||||||||||||
1289 | ; | - | ||||||||||||||||||
1290 | BIGNUM *tmp, *tmp_Z; | - | ||||||||||||||||||
1291 | BIGNUM **prod_Z = | - | ||||||||||||||||||
1292 | ((void *)0) | - | ||||||||||||||||||
1293 | ; | - | ||||||||||||||||||
1294 | size_t i; | - | ||||||||||||||||||
1295 | int ret = 0; | - | ||||||||||||||||||
1296 | - | |||||||||||||||||||
1297 | if (num == 0
| 0-563 | ||||||||||||||||||
1298 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
1299 | - | |||||||||||||||||||
1300 | if (ctx ==
| 0-563 | ||||||||||||||||||
1301 | ((void *)0)
| 0-563 | ||||||||||||||||||
1302 | ) { | - | ||||||||||||||||||
1303 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||
1304 | if (ctx ==
| 0 | ||||||||||||||||||
1305 | ((void *)0)
| 0 | ||||||||||||||||||
1306 | ) | - | ||||||||||||||||||
1307 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1308 | } never executed: end of block | 0 | ||||||||||||||||||
1309 | - | |||||||||||||||||||
1310 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1311 | tmp = BN_CTX_get(ctx); | - | ||||||||||||||||||
1312 | tmp_Z = BN_CTX_get(ctx); | - | ||||||||||||||||||
1313 | if (tmp_Z ==
| 0-563 | ||||||||||||||||||
1314 | ((void *)0)
| 0-563 | ||||||||||||||||||
1315 | ) | - | ||||||||||||||||||
1316 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1317 | - | |||||||||||||||||||
1318 | prod_Z = CRYPTO_malloc(num * sizeof(prod_Z[0]), __FILE__, 1225); | - | ||||||||||||||||||
1319 | if (prod_Z ==
| 0-563 | ||||||||||||||||||
1320 | ((void *)0)
| 0-563 | ||||||||||||||||||
1321 | ) | - | ||||||||||||||||||
1322 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1323 | for (i = 0; i < num
| 563-18108 | ||||||||||||||||||
1324 | prod_Z[i] = BN_new(); | - | ||||||||||||||||||
1325 | if (prod_Z[i] ==
| 0-18108 | ||||||||||||||||||
1326 | ((void *)0)
| 0-18108 | ||||||||||||||||||
1327 | ) | - | ||||||||||||||||||
1328 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1329 | } executed 18108 times by 2 tests: end of block Executed by:
| 18108 | ||||||||||||||||||
1330 | - | |||||||||||||||||||
1331 | - | |||||||||||||||||||
1332 | - | |||||||||||||||||||
1333 | - | |||||||||||||||||||
1334 | - | |||||||||||||||||||
1335 | - | |||||||||||||||||||
1336 | if (!BN_is_zero(points[0]->Z)
| 90-473 | ||||||||||||||||||
1337 | if (!BN_copy(prod_Z[0], points[0]->Z)
| 0-473 | ||||||||||||||||||
1338 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1339 | } executed 473 times by 2 tests: else {end of block Executed by:
| 473 | ||||||||||||||||||
1340 | if (group->meth->field_set_to_one != 0
| 0-90 | ||||||||||||||||||
1341 | if (!group->meth->field_set_to_one(group, prod_Z[0], ctx)
| 0-90 | ||||||||||||||||||
1342 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1343 | } executed 90 times by 1 test: else {end of block Executed by:
| 90 | ||||||||||||||||||
1344 | if (!(BN_set_word((prod_Z[0]),1))
| 0 | ||||||||||||||||||
1345 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1346 | } never executed: end of block | 0 | ||||||||||||||||||
1347 | } | - | ||||||||||||||||||
1348 | - | |||||||||||||||||||
1349 | for (i = 1; i < num
| 563-17545 | ||||||||||||||||||
1350 | if (!BN_is_zero(points[i]->Z)
| 2262-15283 | ||||||||||||||||||
1351 | if (!group->
| 0-15283 | ||||||||||||||||||
1352 | meth->field_mul(group, prod_Z[i], prod_Z[i - 1], points[i]->Z,
| 0-15283 | ||||||||||||||||||
1353 | ctx)
| 0-15283 | ||||||||||||||||||
1354 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1355 | } executed 15283 times by 2 tests: else {end of block Executed by:
| 15283 | ||||||||||||||||||
1356 | if (!BN_copy(prod_Z[i], prod_Z[i - 1])
| 0-2262 | ||||||||||||||||||
1357 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1358 | } executed 2262 times by 1 test: end of block Executed by:
| 2262 | ||||||||||||||||||
1359 | } | - | ||||||||||||||||||
1360 | - | |||||||||||||||||||
1361 | - | |||||||||||||||||||
1362 | - | |||||||||||||||||||
1363 | - | |||||||||||||||||||
1364 | - | |||||||||||||||||||
1365 | - | |||||||||||||||||||
1366 | if (!BN_mod_inverse(tmp, prod_Z[num - 1], group->field, ctx)
| 0-563 | ||||||||||||||||||
1367 | ERR_put_error(16,(137),(3),__FILE__,1270); | - | ||||||||||||||||||
1368 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1369 | } | - | ||||||||||||||||||
1370 | if (group->meth->field_encode != 0
| 0-563 | ||||||||||||||||||
1371 | - | |||||||||||||||||||
1372 | - | |||||||||||||||||||
1373 | - | |||||||||||||||||||
1374 | - | |||||||||||||||||||
1375 | - | |||||||||||||||||||
1376 | if (!group->meth->field_encode(group, tmp, tmp, ctx)
| 0-563 | ||||||||||||||||||
1377 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1378 | if (!group->meth->field_encode(group, tmp, tmp, ctx)
| 0-563 | ||||||||||||||||||
1379 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1380 | } executed 563 times by 2 tests: end of block Executed by:
| 563 | ||||||||||||||||||
1381 | - | |||||||||||||||||||
1382 | for (i = num - 1; i > 0
| 563-17545 | ||||||||||||||||||
1383 | - | |||||||||||||||||||
1384 | - | |||||||||||||||||||
1385 | - | |||||||||||||||||||
1386 | - | |||||||||||||||||||
1387 | if (!BN_is_zero(points[i]->Z)
| 2262-15283 | ||||||||||||||||||
1388 | - | |||||||||||||||||||
1389 | - | |||||||||||||||||||
1390 | - | |||||||||||||||||||
1391 | - | |||||||||||||||||||
1392 | if (!group->
| 0-15283 | ||||||||||||||||||
1393 | meth->field_mul(group, tmp_Z, prod_Z[i - 1], tmp, ctx)
| 0-15283 | ||||||||||||||||||
1394 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1395 | - | |||||||||||||||||||
1396 | - | |||||||||||||||||||
1397 | - | |||||||||||||||||||
1398 | if (!group->meth->field_mul(group, tmp, tmp, points[i]->Z, ctx)
| 0-15283 | ||||||||||||||||||
1399 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1400 | - | |||||||||||||||||||
1401 | if (!BN_copy(points[i]->Z, tmp_Z)
| 0-15283 | ||||||||||||||||||
1402 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1403 | } executed 15283 times by 2 tests: end of block Executed by:
| 15283 | ||||||||||||||||||
1404 | } executed 17545 times by 2 tests: end of block Executed by:
| 17545 | ||||||||||||||||||
1405 | - | |||||||||||||||||||
1406 | if (!BN_is_zero(points[0]->Z)
| 90-473 | ||||||||||||||||||
1407 | - | |||||||||||||||||||
1408 | if (!BN_copy(points[0]->Z, tmp)
| 0-473 | ||||||||||||||||||
1409 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1410 | } executed 473 times by 2 tests: end of block Executed by:
| 473 | ||||||||||||||||||
1411 | - | |||||||||||||||||||
1412 | - | |||||||||||||||||||
1413 | - | |||||||||||||||||||
1414 | for (i = 0; i < num
| 563-18108 | ||||||||||||||||||
1415 | EC_POINT *p = points[i]; | - | ||||||||||||||||||
1416 | - | |||||||||||||||||||
1417 | if (!BN_is_zero(p->Z)
| 2352-15756 | ||||||||||||||||||
1418 | - | |||||||||||||||||||
1419 | - | |||||||||||||||||||
1420 | if (!group->meth->field_sqr(group, tmp, p->Z, ctx)
| 0-15756 | ||||||||||||||||||
1421 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1422 | if (!group->meth->field_mul(group, p->X, p->X, tmp, ctx)
| 0-15756 | ||||||||||||||||||
1423 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1424 | - | |||||||||||||||||||
1425 | if (!group->meth->field_mul(group, tmp, tmp, p->Z, ctx)
| 0-15756 | ||||||||||||||||||
1426 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1427 | if (!group->meth->field_mul(group, p->Y, p->Y, tmp, ctx)
| 0-15756 | ||||||||||||||||||
1428 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1429 | - | |||||||||||||||||||
1430 | if (group->meth->field_set_to_one != 0
| 0-15756 | ||||||||||||||||||
1431 | if (!group->meth->field_set_to_one(group, p->Z, ctx)
| 0-15756 | ||||||||||||||||||
1432 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1433 | } executed 15756 times by 2 tests: else {end of block Executed by:
| 15756 | ||||||||||||||||||
1434 | if (!(BN_set_word((p->Z),1))
| 0 | ||||||||||||||||||
1435 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1436 | } never executed: end of block | 0 | ||||||||||||||||||
1437 | p->Z_is_one = 1; | - | ||||||||||||||||||
1438 | } executed 15756 times by 2 tests: end of block Executed by:
| 15756 | ||||||||||||||||||
1439 | } executed 18108 times by 2 tests: end of block Executed by:
| 18108 | ||||||||||||||||||
1440 | - | |||||||||||||||||||
1441 | ret = 1; | - | ||||||||||||||||||
1442 | - | |||||||||||||||||||
1443 | err: code before this statement executed 563 times by 2 tests: err: Executed by:
| 563 | ||||||||||||||||||
1444 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1445 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||
1446 | if (prod_Z !=
| 0-563 | ||||||||||||||||||
1447 | ((void *)0)
| 0-563 | ||||||||||||||||||
1448 | ) { | - | ||||||||||||||||||
1449 | for (i = 0; i < num
| 563-18108 | ||||||||||||||||||
1450 | if (prod_Z[i] ==
| 0-18108 | ||||||||||||||||||
1451 | ((void *)0)
| 0-18108 | ||||||||||||||||||
1452 | ) | - | ||||||||||||||||||
1453 | break; never executed: break; | 0 | ||||||||||||||||||
1454 | BN_clear_free(prod_Z[i]); | - | ||||||||||||||||||
1455 | } executed 18108 times by 2 tests: end of block Executed by:
| 18108 | ||||||||||||||||||
1456 | CRYPTO_free(prod_Z, __FILE__, 1355); | - | ||||||||||||||||||
1457 | } executed 563 times by 2 tests: end of block Executed by:
| 563 | ||||||||||||||||||
1458 | return executed 563 times by 2 tests: ret;return ret; Executed by:
executed 563 times by 2 tests: return ret; Executed by:
| 563 | ||||||||||||||||||
1459 | } | - | ||||||||||||||||||
1460 | - | |||||||||||||||||||
1461 | int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | - | ||||||||||||||||||
1462 | const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||
1463 | { | - | ||||||||||||||||||
1464 | return never executed: BN_mod_mul(r, a, b, group->field, ctx);return BN_mod_mul(r, a, b, group->field, ctx); never executed: return BN_mod_mul(r, a, b, group->field, ctx); | 0 | ||||||||||||||||||
1465 | } | - | ||||||||||||||||||
1466 | - | |||||||||||||||||||
1467 | int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | - | ||||||||||||||||||
1468 | BN_CTX *ctx) | - | ||||||||||||||||||
1469 | { | - | ||||||||||||||||||
1470 | return never executed: BN_mod_sqr(r, a, group->field, ctx);return BN_mod_sqr(r, a, group->field, ctx); never executed: return BN_mod_sqr(r, a, group->field, ctx); | 0 | ||||||||||||||||||
1471 | } | - | ||||||||||||||||||
1472 | int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, | - | ||||||||||||||||||
1473 | BN_CTX *ctx) | - | ||||||||||||||||||
1474 | { | - | ||||||||||||||||||
1475 | int ret = 0; | - | ||||||||||||||||||
1476 | BIGNUM *lambda = | - | ||||||||||||||||||
1477 | ((void *)0) | - | ||||||||||||||||||
1478 | ; | - | ||||||||||||||||||
1479 | BIGNUM *temp = | - | ||||||||||||||||||
1480 | ((void *)0) | - | ||||||||||||||||||
1481 | ; | - | ||||||||||||||||||
1482 | - | |||||||||||||||||||
1483 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1484 | lambda = BN_CTX_get(ctx); | - | ||||||||||||||||||
1485 | temp = BN_CTX_get(ctx); | - | ||||||||||||||||||
1486 | if (temp ==
| 0-2004 | ||||||||||||||||||
1487 | ((void *)0)
| 0-2004 | ||||||||||||||||||
1488 | ) { | - | ||||||||||||||||||
1489 | ERR_put_error(16,(287),((1|64)),__FILE__,1390); | - | ||||||||||||||||||
1490 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1491 | } | - | ||||||||||||||||||
1492 | - | |||||||||||||||||||
1493 | - | |||||||||||||||||||
1494 | do { | - | ||||||||||||||||||
1495 | if (!BN_priv_rand_range(lambda, group->field)
| 0-2004 | ||||||||||||||||||
1496 | ERR_put_error(16,(287),(3),__FILE__,1397); | - | ||||||||||||||||||
1497 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1498 | } | - | ||||||||||||||||||
1499 | } executed 2004 times by 2 tests: while (BN_is_zero(lambda)end of block Executed by:
| 0-2004 | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | - | |||||||||||||||||||
1502 | if (group->meth->field_encode !=
| 0-2004 | ||||||||||||||||||
1503 | ((void *)0)
| 0-2004 | ||||||||||||||||||
1504 | - | |||||||||||||||||||
1505 | && !group->meth->field_encode(group, lambda, lambda, ctx)
| 0-2004 | ||||||||||||||||||
1506 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1507 | if (!group->meth->field_mul(group, p->Z, p->Z, lambda, ctx)
| 0-2004 | ||||||||||||||||||
1508 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1509 | if (!group->meth->field_sqr(group, temp, lambda, ctx)
| 0-2004 | ||||||||||||||||||
1510 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1511 | if (!group->meth->field_mul(group, p->X, p->X, temp, ctx)
| 0-2004 | ||||||||||||||||||
1512 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1513 | if (!group->meth->field_mul(group, temp, temp, lambda, ctx)
| 0-2004 | ||||||||||||||||||
1514 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1515 | if (!group->meth->field_mul(group, p->Y, p->Y, temp, ctx)
| 0-2004 | ||||||||||||||||||
1516 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1517 | p->Z_is_one = 0; | - | ||||||||||||||||||
1518 | - | |||||||||||||||||||
1519 | ret = 1; | - | ||||||||||||||||||
1520 | - | |||||||||||||||||||
1521 | err: code before this statement executed 2004 times by 2 tests: err: Executed by:
| 2004 | ||||||||||||||||||
1522 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1523 | return executed 2004 times by 2 tests: ret;return ret; Executed by:
executed 2004 times by 2 tests: return ret; Executed by:
| 2004 | ||||||||||||||||||
1524 | } | - | ||||||||||||||||||
1525 | int ec_GFp_simple_ladder_pre(const EC_GROUP *group, | - | ||||||||||||||||||
1526 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||
1527 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||
1528 | { | - | ||||||||||||||||||
1529 | BIGNUM *t1, *t2, *t3, *t4, *t5, *t6 = | - | ||||||||||||||||||
1530 | ((void *)0) | - | ||||||||||||||||||
1531 | ; | - | ||||||||||||||||||
1532 | - | |||||||||||||||||||
1533 | t1 = r->Z; | - | ||||||||||||||||||
1534 | t2 = r->Y; | - | ||||||||||||||||||
1535 | t3 = s->X; | - | ||||||||||||||||||
1536 | t4 = r->X; | - | ||||||||||||||||||
1537 | t5 = s->Y; | - | ||||||||||||||||||
1538 | t6 = s->Z; | - | ||||||||||||||||||
1539 | - | |||||||||||||||||||
1540 | - | |||||||||||||||||||
1541 | if (!group->meth->field_mul(group, p->X, p->X, p->Z, ctx)
| 0-2004 | ||||||||||||||||||
1542 | || !group->meth->field_sqr(group, t1, p->Z, ctx)
| 0-2004 | ||||||||||||||||||
1543 | || !group->meth->field_mul(group, p->Z, p->Z, t1, ctx)
| 0-2004 | ||||||||||||||||||
1544 | - | |||||||||||||||||||
1545 | || !group->meth->field_sqr(group, t2, p->X, ctx)
| 0-2004 | ||||||||||||||||||
1546 | || !group->meth->field_sqr(group, t3, p->Z, ctx)
| 0-2004 | ||||||||||||||||||
1547 | || !group->meth->field_mul(group, t4, t3, group->a, ctx)
| 0-2004 | ||||||||||||||||||
1548 | || !BN_mod_sub_quick(t5, t2, t4, group->field)
| 0-2004 | ||||||||||||||||||
1549 | || !BN_mod_add_quick(t2, t2, t4, group->field)
| 0-2004 | ||||||||||||||||||
1550 | || !group->meth->field_sqr(group, t5, t5, ctx)
| 0-2004 | ||||||||||||||||||
1551 | || !group->meth->field_mul(group, t6, t3, group->b, ctx)
| 0-2004 | ||||||||||||||||||
1552 | || !group->meth->field_mul(group, t1, p->X, p->Z, ctx)
| 0-2004 | ||||||||||||||||||
1553 | || !group->meth->field_mul(group, t4, t1, t6, ctx)
| 0-2004 | ||||||||||||||||||
1554 | || !BN_mod_lshift_quick(t4, t4, 3, group->field)
| 0-2004 | ||||||||||||||||||
1555 | - | |||||||||||||||||||
1556 | || !BN_mod_sub_quick(r->X, t5, t4, group->field)
| 0-2004 | ||||||||||||||||||
1557 | || !group->meth->field_mul(group, t1, t1, t2, ctx)
| 0-2004 | ||||||||||||||||||
1558 | || !group->meth->field_mul(group, t2, t3, t6, ctx)
| 0-2004 | ||||||||||||||||||
1559 | || !BN_mod_add_quick(t1, t1, t2, group->field)
| 0-2004 | ||||||||||||||||||
1560 | - | |||||||||||||||||||
1561 | || !BN_mod_lshift_quick(r->Z, t1, 2, group->field)
| 0-2004 | ||||||||||||||||||
1562 | || !EC_POINT_copy(s, p)
| 0-2004 | ||||||||||||||||||
1563 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1564 | - | |||||||||||||||||||
1565 | r->Z_is_one = 0; | - | ||||||||||||||||||
1566 | s->Z_is_one = 0; | - | ||||||||||||||||||
1567 | p->Z_is_one = 0; | - | ||||||||||||||||||
1568 | - | |||||||||||||||||||
1569 | return executed 2004 times by 2 tests: 1;return 1; Executed by:
executed 2004 times by 2 tests: return 1; Executed by:
| 2004 | ||||||||||||||||||
1570 | } | - | ||||||||||||||||||
1571 | - | |||||||||||||||||||
1572 | - | |||||||||||||||||||
1573 | - | |||||||||||||||||||
1574 | - | |||||||||||||||||||
1575 | - | |||||||||||||||||||
1576 | - | |||||||||||||||||||
1577 | - | |||||||||||||||||||
1578 | int ec_GFp_simple_ladder_step(const EC_GROUP *group, | - | ||||||||||||||||||
1579 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||
1580 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||
1581 | { | - | ||||||||||||||||||
1582 | int ret = 0; | - | ||||||||||||||||||
1583 | BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6, *t7 = | - | ||||||||||||||||||
1584 | ((void *)0) | - | ||||||||||||||||||
1585 | ; | - | ||||||||||||||||||
1586 | - | |||||||||||||||||||
1587 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1588 | t0 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1589 | t1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1590 | t2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1591 | t3 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1592 | t4 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1593 | t5 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1594 | t6 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1595 | t7 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1596 | - | |||||||||||||||||||
1597 | if (t7 ==
| 0-636753 | ||||||||||||||||||
1598 | ((void *)0)
| 0-636753 | ||||||||||||||||||
1599 | - | |||||||||||||||||||
1600 | || !group->meth->field_mul(group, t0, r->X, s->X, ctx)
| 0-636753 | ||||||||||||||||||
1601 | || !group->meth->field_mul(group, t1, r->Z, s->Z, ctx)
| 0-636753 | ||||||||||||||||||
1602 | || !group->meth->field_mul(group, t2, r->X, s->Z, ctx)
| 0-636753 | ||||||||||||||||||
1603 | || !group->meth->field_mul(group, t3, r->Z, s->X, ctx)
| 0-636753 | ||||||||||||||||||
1604 | || !group->meth->field_mul(group, t4, group->a, t1, ctx)
| 0-636753 | ||||||||||||||||||
1605 | || !BN_mod_add_quick(t0, t0, t4, group->field)
| 0-636753 | ||||||||||||||||||
1606 | || !BN_mod_add_quick(t4, t3, t2, group->field)
| 0-636753 | ||||||||||||||||||
1607 | || !group->meth->field_mul(group, t0, t4, t0, ctx)
| 0-636753 | ||||||||||||||||||
1608 | || !group->meth->field_sqr(group, t1, t1, ctx)
| 0-636753 | ||||||||||||||||||
1609 | || !BN_mod_lshift_quick(t7, group->b, 2, group->field)
| 0-636753 | ||||||||||||||||||
1610 | || !group->meth->field_mul(group, t1, t7, t1, ctx)
| 0-636753 | ||||||||||||||||||
1611 | || !BN_mod_lshift1_quick(t0, t0, group->field)
| 0-636753 | ||||||||||||||||||
1612 | || !BN_mod_add_quick(t0, t1, t0, group->field)
| 0-636753 | ||||||||||||||||||
1613 | || !BN_mod_sub_quick(t1, t2, t3, group->field)
| 0-636753 | ||||||||||||||||||
1614 | || !group->meth->field_sqr(group, t1, t1, ctx)
| 0-636753 | ||||||||||||||||||
1615 | || !group->meth->field_mul(group, t3, t1, p->X, ctx)
| 0-636753 | ||||||||||||||||||
1616 | || !group->meth->field_mul(group, t0, p->Z, t0, ctx)
| 0-636753 | ||||||||||||||||||
1617 | - | |||||||||||||||||||
1618 | || !BN_mod_sub_quick(s->X, t0, t3, group->field)
| 0-636753 | ||||||||||||||||||
1619 | - | |||||||||||||||||||
1620 | || !group->meth->field_mul(group, s->Z, p->Z, t1, ctx)
| 0-636753 | ||||||||||||||||||
1621 | || !group->meth->field_sqr(group, t3, r->X, ctx)
| 0-636753 | ||||||||||||||||||
1622 | || !group->meth->field_sqr(group, t2, r->Z, ctx)
| 0-636753 | ||||||||||||||||||
1623 | || !group->meth->field_mul(group, t4, t2, group->a, ctx)
| 0-636753 | ||||||||||||||||||
1624 | || !BN_mod_add_quick(t5, r->X, r->Z, group->field)
| 0-636753 | ||||||||||||||||||
1625 | || !group->meth->field_sqr(group, t5, t5, ctx)
| 0-636753 | ||||||||||||||||||
1626 | || !BN_mod_sub_quick(t5, t5, t3, group->field)
| 0-636753 | ||||||||||||||||||
1627 | || !BN_mod_sub_quick(t5, t5, t2, group->field)
| 0-636753 | ||||||||||||||||||
1628 | || !BN_mod_sub_quick(t6, t3, t4, group->field)
| 0-636753 | ||||||||||||||||||
1629 | || !group->meth->field_sqr(group, t6, t6, ctx)
| 0-636753 | ||||||||||||||||||
1630 | || !group->meth->field_mul(group, t0, t2, t5, ctx)
| 0-636753 | ||||||||||||||||||
1631 | || !group->meth->field_mul(group, t0, t7, t0, ctx)
| 0-636753 | ||||||||||||||||||
1632 | - | |||||||||||||||||||
1633 | || !BN_mod_sub_quick(r->X, t6, t0, group->field)
| 0-636753 | ||||||||||||||||||
1634 | || !BN_mod_add_quick(t6, t3, t4, group->field)
| 0-636753 | ||||||||||||||||||
1635 | || !group->meth->field_sqr(group, t3, t2, ctx)
| 0-636753 | ||||||||||||||||||
1636 | || !group->meth->field_mul(group, t7, t3, t7, ctx)
| 0-636753 | ||||||||||||||||||
1637 | || !group->meth->field_mul(group, t5, t5, t6, ctx)
| 0-636753 | ||||||||||||||||||
1638 | || !BN_mod_lshift1_quick(t5, t5, group->field)
| 0-636753 | ||||||||||||||||||
1639 | - | |||||||||||||||||||
1640 | || !BN_mod_add_quick(r->Z, t7, t5, group->field)
| 0-636753 | ||||||||||||||||||
1641 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1642 | - | |||||||||||||||||||
1643 | ret = 1; | - | ||||||||||||||||||
1644 | - | |||||||||||||||||||
1645 | err: code before this statement executed 636753 times by 2 tests: err: Executed by:
| 636753 | ||||||||||||||||||
1646 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1647 | return executed 636753 times by 2 tests: ret;return ret; Executed by:
executed 636753 times by 2 tests: return ret; Executed by:
| 636753 | ||||||||||||||||||
1648 | } | - | ||||||||||||||||||
1649 | int ec_GFp_simple_ladder_post(const EC_GROUP *group, | - | ||||||||||||||||||
1650 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||
1651 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||
1652 | { | - | ||||||||||||||||||
1653 | int ret = 0; | - | ||||||||||||||||||
1654 | BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = | - | ||||||||||||||||||
1655 | ((void *)0) | - | ||||||||||||||||||
1656 | ; | - | ||||||||||||||||||
1657 | - | |||||||||||||||||||
1658 | if (BN_is_zero(r->Z)
| 225-1779 | ||||||||||||||||||
1659 | return executed 225 times by 1 test: EC_POINT_set_to_infinity(group, r);return EC_POINT_set_to_infinity(group, r); Executed by:
executed 225 times by 1 test: return EC_POINT_set_to_infinity(group, r); Executed by:
| 225 | ||||||||||||||||||
1660 | - | |||||||||||||||||||
1661 | if (BN_is_zero(s->Z)
| 135-1644 | ||||||||||||||||||
1662 | - | |||||||||||||||||||
1663 | if (!group->meth->field_mul(group, r->X, p->X, p->Z, ctx)
| 0-135 | ||||||||||||||||||
1664 | || !group->meth->field_sqr(group, r->Z, p->Z, ctx)
| 0-135 | ||||||||||||||||||
1665 | || !group->meth->field_mul(group, r->Y, p->Y, r->Z, ctx)
| 0-135 | ||||||||||||||||||
1666 | || !BN_copy(r->Z, p->Z)
| 0-135 | ||||||||||||||||||
1667 | || !EC_POINT_invert(group, r, ctx)
| 0-135 | ||||||||||||||||||
1668 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1669 | return executed 135 times by 1 test: 1;return 1; Executed by:
executed 135 times by 1 test: return 1; Executed by:
| 135 | ||||||||||||||||||
1670 | } | - | ||||||||||||||||||
1671 | - | |||||||||||||||||||
1672 | BN_CTX_start(ctx); | - | ||||||||||||||||||
1673 | t0 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1674 | t1 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1675 | t2 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1676 | t3 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1677 | t4 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1678 | t5 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1679 | t6 = BN_CTX_get(ctx); | - | ||||||||||||||||||
1680 | - | |||||||||||||||||||
1681 | if (t6 ==
| 0-1644 | ||||||||||||||||||
1682 | ((void *)0)
| 0-1644 | ||||||||||||||||||
1683 | - | |||||||||||||||||||
1684 | || !BN_mod_lshift1_quick(t0, p->Y, group->field)
| 0-1644 | ||||||||||||||||||
1685 | || !group->meth->field_mul(group, t1, r->X, p->Z, ctx)
| 0-1644 | ||||||||||||||||||
1686 | || !group->meth->field_mul(group, t2, r->Z, s->Z, ctx)
| 0-1644 | ||||||||||||||||||
1687 | || !group->meth->field_mul(group, t2, t1, t2, ctx)
| 0-1644 | ||||||||||||||||||
1688 | || !group->meth->field_mul(group, t3, t2, t0, ctx)
| 0-1644 | ||||||||||||||||||
1689 | || !group->meth->field_mul(group, t2, r->Z, p->Z, ctx)
| 0-1644 | ||||||||||||||||||
1690 | || !group->meth->field_sqr(group, t4, t2, ctx)
| 0-1644 | ||||||||||||||||||
1691 | || !BN_mod_lshift1_quick(t5, group->b, group->field)
| 0-1644 | ||||||||||||||||||
1692 | || !group->meth->field_mul(group, t4, t4, t5, ctx)
| 0-1644 | ||||||||||||||||||
1693 | || !group->meth->field_mul(group, t6, t2, group->a, ctx)
| 0-1644 | ||||||||||||||||||
1694 | || !group->meth->field_mul(group, t5, r->X, p->X, ctx)
| 0-1644 | ||||||||||||||||||
1695 | || !BN_mod_add_quick(t5, t6, t5, group->field)
| 0-1644 | ||||||||||||||||||
1696 | || !group->meth->field_mul(group, t6, r->Z, p->X, ctx)
| 0-1644 | ||||||||||||||||||
1697 | || !BN_mod_add_quick(t2, t6, t1, group->field)
| 0-1644 | ||||||||||||||||||
1698 | || !group->meth->field_mul(group, t5, t5, t2, ctx)
| 0-1644 | ||||||||||||||||||
1699 | || !BN_mod_sub_quick(t6, t6, t1, group->field)
| 0-1644 | ||||||||||||||||||
1700 | || !group->meth->field_sqr(group, t6, t6, ctx)
| 0-1644 | ||||||||||||||||||
1701 | || !group->meth->field_mul(group, t6, t6, s->X, ctx)
| 0-1644 | ||||||||||||||||||
1702 | || !BN_mod_add_quick(t4, t5, t4, group->field)
| 0-1644 | ||||||||||||||||||
1703 | || !group->meth->field_mul(group, t4, t4, s->Z, ctx)
| 0-1644 | ||||||||||||||||||
1704 | || !BN_mod_sub_quick(t4, t4, t6, group->field)
| 0-1644 | ||||||||||||||||||
1705 | || !group->meth->field_sqr(group, t5, r->Z, ctx)
| 0-1644 | ||||||||||||||||||
1706 | || !group->meth->field_mul(group, r->Z, p->Z, s->Z, ctx)
| 0-1644 | ||||||||||||||||||
1707 | || !group->meth->field_mul(group, r->Z, t5, r->Z, ctx)
| 0-1644 | ||||||||||||||||||
1708 | || !group->meth->field_mul(group, r->Z, r->Z, t0, ctx)
| 0-1644 | ||||||||||||||||||
1709 | - | |||||||||||||||||||
1710 | - | |||||||||||||||||||
1711 | || !group->meth->field_mul(group, r->X, t3, r->Z, ctx)
| 0-1644 | ||||||||||||||||||
1712 | || !group->meth->field_sqr(group, t3, r->Z, ctx)
| 0-1644 | ||||||||||||||||||
1713 | || !group->meth->field_mul(group, r->Y, t4, t3, ctx)
| 0-1644 | ||||||||||||||||||
1714 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1715 | - | |||||||||||||||||||
1716 | ret = 1; | - | ||||||||||||||||||
1717 | - | |||||||||||||||||||
1718 | err: code before this statement executed 1644 times by 2 tests: err: Executed by:
| 1644 | ||||||||||||||||||
1719 | BN_CTX_end(ctx); | - | ||||||||||||||||||
1720 | return executed 1644 times by 2 tests: ret;return ret; Executed by:
executed 1644 times by 2 tests: return ret; Executed by:
| 1644 | ||||||||||||||||||
1721 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |