OpenCoverage

ec_lib.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/ec/ec_lib.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: ec_lib.c,v 1.29 2018/07/16 17:32:39 tb Exp $ */-
2/*-
3 * Originally written by Bodo Moeller for the OpenSSL project.-
4 */-
5/* ====================================================================-
6 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.-
7 *-
8 * Redistribution and use in source and binary forms, with or without-
9 * modification, are permitted provided that the following conditions-
10 * are met:-
11 *-
12 * 1. Redistributions of source code must retain the above copyright-
13 * notice, this list of conditions and the following disclaimer.-
14 *-
15 * 2. Redistributions in binary form must reproduce the above copyright-
16 * notice, this list of conditions and the following disclaimer in-
17 * the documentation and/or other materials provided with the-
18 * distribution.-
19 *-
20 * 3. All advertising materials mentioning features or use of this-
21 * software must display the following acknowledgment:-
22 * "This product includes software developed by the OpenSSL Project-
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"-
24 *-
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to-
26 * endorse or promote products derived from this software without-
27 * prior written permission. For written permission, please contact-
28 * openssl-core@openssl.org.-
29 *-
30 * 5. Products derived from this software may not be called "OpenSSL"-
31 * nor may "OpenSSL" appear in their names without prior written-
32 * permission of the OpenSSL Project.-
33 *-
34 * 6. Redistributions of any form whatsoever must retain the following-
35 * acknowledgment:-
36 * "This product includes software developed by the OpenSSL Project-
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"-
38 *-
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY-
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR-
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,-
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)-
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED-
50 * OF THE POSSIBILITY OF SUCH DAMAGE.-
51 * ====================================================================-
52 *-
53 * This product includes cryptographic software written by Eric Young-
54 * (eay@cryptsoft.com). This product includes software written by Tim-
55 * Hudson (tjh@cryptsoft.com).-
56 *-
57 */-
58/* ====================================================================-
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.-
60 * Binary polynomial ECC support in OpenSSL originally developed by-
61 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.-
62 */-
63-
64#include <string.h>-
65-
66#include <openssl/opensslconf.h>-
67-
68#include <openssl/err.h>-
69#include <openssl/opensslv.h>-
70-
71#include "ec_lcl.h"-
72-
73/* functions for EC_GROUP objects */-
74-
75EC_GROUP *-
76EC_GROUP_new(const EC_METHOD * meth)-
77{-
78 EC_GROUP *ret;-
79-
80 if (meth == NULL) {
meth == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-617
81 ECerror(EC_R_SLOT_FULL);-
82 return NULL;
never executed: return ((void *)0) ;
0
83 }-
84 if (meth->group_init == 0) {
meth->group_init == 0Description
TRUEnever evaluated
FALSEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-617
85 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
86 return NULL;
never executed: return ((void *)0) ;
0
87 }-
88 ret = malloc(sizeof *ret);-
89 if (ret == NULL) {
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-617
90 ECerror(ERR_R_MALLOC_FAILURE);-
91 return NULL;
never executed: return ((void *)0) ;
0
92 }-
93 ret->meth = meth;-
94-
95 ret->extra_data = NULL;-
96-
97 ret->generator = NULL;-
98 BN_init(&ret->order);-
99 BN_init(&ret->cofactor);-
100-
101 ret->curve_name = 0;-
102 ret->asn1_flag = 0;-
103 ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED;-
104-
105 ret->seed = NULL;-
106 ret->seed_len = 0;-
107-
108 if (!meth->group_init(ret)) {
!meth->group_init(ret)Description
TRUEnever evaluated
FALSEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-617
109 free(ret);-
110 return NULL;
never executed: return ((void *)0) ;
0
111 }-
112 return ret;
executed 617 times by 4 tests: return ret;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
617
113}-
114-
115-
116void -
117EC_GROUP_free(EC_GROUP * group)-
118{-
119 if (!group)
!groupDescription
TRUEevaluated 212 times by 3 tests
Evaluated by:
  • ecdsatest
  • freenull
  • ssltest
FALSEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
212-617
120 return;
executed 212 times by 3 tests: return;
Executed by:
  • ecdsatest
  • freenull
  • ssltest
212
121-
122 if (group->meth->group_finish != 0)
group->meth->group_finish != 0Description
TRUEevaluated 617 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-617
123 group->meth->group_finish(group);
executed 617 times by 4 tests: group->meth->group_finish(group);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
617
124-
125 EC_EX_DATA_free_all_data(&group->extra_data);-
126-
127 EC_POINT_free(group->generator);-
128 BN_free(&group->order);-
129 BN_free(&group->cofactor);-
130-
131 free(group->seed);-
132-
133 free(group);-
134}
executed 617 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
617
135-
136-
137void -
138EC_GROUP_clear_free(EC_GROUP * group)-
139{-
140 if (!group)
!groupDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • freenull
FALSEnever evaluated
0-1
141 return;
executed 1 time by 1 test: return;
Executed by:
  • freenull
1
142-
143 if (group->meth->group_clear_finish != 0)
group->meth->g...ar_finish != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
144 group->meth->group_clear_finish(group);
never executed: group->meth->group_clear_finish(group);
0
145 else if (group->meth->group_finish != 0)
group->meth->group_finish != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
146 group->meth->group_finish(group);
never executed: group->meth->group_finish(group);
0
147-
148 EC_EX_DATA_clear_free_all_data(&group->extra_data);-
149-
150 EC_POINT_clear_free(group->generator);-
151 BN_clear_free(&group->order);-
152 BN_clear_free(&group->cofactor);-
153-
154 freezero(group->seed, group->seed_len);-
155 freezero(group, sizeof *group);-
156}
never executed: end of block
0
157-
158-
159int -
160EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src)-
161{-
162 EC_EXTRA_DATA *d;-
163-
164 if (dest->meth->group_copy == 0) {
dest->meth->group_copy == 0Description
TRUEnever evaluated
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-229
165 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
166 return 0;
never executed: return 0;
0
167 }-
168 if (dest->meth != src->meth) {
dest->meth != src->methDescription
TRUEnever evaluated
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-229
169 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
170 return 0;
never executed: return 0;
0
171 }-
172 if (dest == src)
dest == srcDescription
TRUEnever evaluated
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-229
173 return 1;
never executed: return 1;
0
174-
175 EC_EX_DATA_free_all_data(&dest->extra_data);-
176-
177 for (d = src->extra_data; d != NULL; d = d->next) {
d != ((void *)0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • ectest
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
10-229
178 void *t = d->dup_func(d->data);-
179-
180 if (t == NULL)
t == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • ectest
0-10
181 return 0;
never executed: return 0;
0
182 if (!EC_EX_DATA_set_data(&dest->extra_data, t, d->dup_func,
!EC_EX_DATA_se...ear_free_func)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • ectest
0-10
183 d->free_func, d->clear_free_func))
!EC_EX_DATA_se...ear_free_func)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • ectest
0-10
184 return 0;
never executed: return 0;
0
185 }
executed 10 times by 1 test: end of block
Executed by:
  • ectest
10
186-
187 if (src->generator != NULL) {
src->generator != ((void *)0)Description
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 2 times by 1 test
Evaluated by:
  • ectest
2-227
188 if (dest->generator == NULL) {
dest->generator == ((void *)0)Description
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-227
189 dest->generator = EC_POINT_new(dest);-
190 if (dest->generator == NULL)
dest->generator == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 227 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-227
191 return 0;
never executed: return 0;
0
192 }
executed 227 times by 3 tests: end of block
Executed by:
  • ecdsatest
  • ectest
  • ssltest
227
193 if (!EC_POINT_copy(dest->generator, src->generator))
!EC_POINT_copy...rc->generator)Description
TRUEnever evaluated
FALSEevaluated 227 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-227
194 return 0;
never executed: return 0;
0
195 } else {
executed 227 times by 3 tests: end of block
Executed by:
  • ecdsatest
  • ectest
  • ssltest
227
196 /* src->generator == NULL */-
197 EC_POINT_clear_free(dest->generator);-
198 dest->generator = NULL;-
199 }
executed 2 times by 1 test: end of block
Executed by:
  • ectest
2
200-
201 if (!BN_copy(&dest->order, &src->order))
!BN_copy(&dest..., &src->order)Description
TRUEnever evaluated
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-229
202 return 0;
never executed: return 0;
0
203 if (!BN_copy(&dest->cofactor, &src->cofactor))
!BN_copy(&dest...src->cofactor)Description
TRUEnever evaluated
FALSEevaluated 229 times by 3 tests
Evaluated by:
  • ecdsatest
  • ectest
  • ssltest
0-229
204 return 0;
never executed: return 0;
0
205-
206 dest->curve_name = src->curve_name;-
207 dest->asn1_flag = src->asn1_flag;-
208 dest->asn1_form = src->asn1_form;-
209-
210 if (src->seed) {
src->seedDescription
TRUEevaluated 118 times by 2 tests
Evaluated by:
  • ecdsatest
  • ssltest
FALSEevaluated 111 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
111-118
211 free(dest->seed);-
212 dest->seed = malloc(src->seed_len);-
213 if (dest->seed == NULL)
dest->seed == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 118 times by 2 tests
Evaluated by:
  • ecdsatest
  • ssltest
0-118
214 return 0;
never executed: return 0;
0
215 memcpy(dest->seed, src->seed, src->seed_len);-
216 dest->seed_len = src->seed_len;-
217 } else {
executed 118 times by 2 tests: end of block
Executed by:
  • ecdsatest
  • ssltest
118
218 free(dest->seed);-
219 dest->seed = NULL;-
220 dest->seed_len = 0;-
221 }
executed 111 times by 2 tests: end of block
Executed by:
  • ecdsatest
  • ectest
111
222-
223-
224 return dest->meth->group_copy(dest, src);
executed 229 times by 3 tests: return dest->meth->group_copy(dest, src);
Executed by:
  • ecdsatest
  • ectest
  • ssltest
229
225}-
226-
227-
228EC_GROUP *-
229EC_GROUP_dup(const EC_GROUP * a)-
230{-
231 EC_GROUP *t = NULL;-
232-
233 if ((a != NULL) && ((t = EC_GROUP_new(a->meth)) != NULL) &&
(a != ((void *)0) )Description
TRUEevaluated 211 times by 2 tests
Evaluated by:
  • ecdsatest
  • ssltest
FALSEnever evaluated
((t = EC_GROUP... ((void *)0) )Description
TRUEevaluated 211 times by 2 tests
Evaluated by:
  • ecdsatest
  • ssltest
FALSEnever evaluated
0-211
234 (!EC_GROUP_copy(t, a))) {
(!EC_GROUP_copy(t, a))Description
TRUEnever evaluated
FALSEevaluated 211 times by 2 tests
Evaluated by:
  • ecdsatest
  • ssltest
0-211
235 EC_GROUP_free(t);-
236 t = NULL;-
237 }
never executed: end of block
0
238 return t;
executed 211 times by 2 tests: return t;
Executed by:
  • ecdsatest
  • ssltest
211
239}-
240-
241-
242const EC_METHOD *-
243EC_GROUP_method_of(const EC_GROUP *group)-
244{-
245 return group->meth;
executed 585 times by 4 tests: return group->meth;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
585
246}-
247-
248-
249int -
250EC_METHOD_get_field_type(const EC_METHOD *meth)-
251{-
252 return meth->field_type;
executed 567 times by 3 tests: return meth->field_type;
Executed by:
  • ecdhtest
  • ecdsatest
  • ssltest
567
253}-
254-
255-
256int -
257EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,-
258 const BIGNUM *order, const BIGNUM *cofactor)-
259{-
260 if (generator == NULL) {
generator == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-402
261 ECerror(ERR_R_PASSED_NULL_PARAMETER);-
262 return 0;
never executed: return 0;
0
263 }-
264 if (group->generator == NULL) {
group->generat...== ((void *)0)Description
TRUEevaluated 388 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 14 times by 1 test
Evaluated by:
  • ectest
14-388
265 group->generator = EC_POINT_new(group);-
266 if (group->generator == NULL)
group->generat...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 388 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-388
267 return 0;
never executed: return 0;
0
268 }
executed 388 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
388
269 if (!EC_POINT_copy(group->generator, generator))
!EC_POINT_copy...or, generator)Description
TRUEnever evaluated
FALSEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-402
270 return 0;
never executed: return 0;
0
271-
272 if (order != NULL) {
order != ((void *)0)Description
TRUEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-402
273 if (!BN_copy(&group->order, order))
!BN_copy(&group->order, order)Description
TRUEnever evaluated
FALSEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-402
274 return 0;
never executed: return 0;
0
275 } else
executed 402 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
402
276 BN_zero(&group->order);
never executed: (BN_set_word((&group->order),0));
0
277-
278 if (cofactor != NULL) {
cofactor != ((void *)0)Description
TRUEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-402
279 if (!BN_copy(&group->cofactor, cofactor))
!BN_copy(&grou...tor, cofactor)Description
TRUEnever evaluated
FALSEevaluated 402 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-402
280 return 0;
never executed: return 0;
0
281 } else
executed 402 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
402
282 BN_zero(&group->cofactor);
never executed: (BN_set_word((&group->cofactor),0));
0
283-
284 return 1;
executed 402 times by 4 tests: return 1;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
402
285}-
286-
287-
288const EC_POINT *-
289EC_GROUP_get0_generator(const EC_GROUP *group)-
290{-
291 return group->generator;
executed 389 times by 2 tests: return group->generator;
Executed by:
  • ecdsatest
  • ectest
389
292}-
293-
294-
295int -
296EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)-
297{-
298 if (!BN_copy(order, &group->order))
!BN_copy(order, &group->order)Description
TRUEnever evaluated
FALSEevaluated 952 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-952
299 return 0;
never executed: return 0;
0
300-
301 return !BN_is_zero(order);
executed 952 times by 4 tests: return !((order)->top == 0);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
952
302}-
303-
304-
305int -
306EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)-
307{-
308 if (!BN_copy(cofactor, &group->cofactor))
!BN_copy(cofac...oup->cofactor)Description
TRUEnever evaluated
FALSEnever evaluated
0
309 return 0;
never executed: return 0;
0
310-
311 return !BN_is_zero(&group->cofactor);
never executed: return !((&group->cofactor)->top == 0);
0
312}-
313-
314-
315void -
316EC_GROUP_set_curve_name(EC_GROUP * group, int nid)-
317{-
318 group->curve_name = nid;-
319}
executed 386 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
386
320-
321-
322int -
323EC_GROUP_get_curve_name(const EC_GROUP * group)-
324{-
325 return group->curve_name;
executed 49 times by 1 test: return group->curve_name;
Executed by:
  • ssltest
49
326}-
327-
328-
329void -
330EC_GROUP_set_asn1_flag(EC_GROUP * group, int flag)-
331{-
332 group->asn1_flag = flag;-
333}
never executed: end of block
0
334-
335-
336int -
337EC_GROUP_get_asn1_flag(const EC_GROUP * group)-
338{-
339 return group->asn1_flag;
never executed: return group->asn1_flag;
0
340}-
341-
342-
343void -
344EC_GROUP_set_point_conversion_form(EC_GROUP * group,-
345 point_conversion_form_t form)-
346{-
347 group->asn1_form = form;-
348}
never executed: end of block
0
349-
350-
351point_conversion_form_t -
352EC_GROUP_get_point_conversion_form(const EC_GROUP * group)-
353{-
354 return group->asn1_form;
never executed: return group->asn1_form;
0
355}-
356-
357-
358size_t -
359EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len)-
360{-
361 if (group->seed) {
group->seedDescription
TRUEnever evaluated
FALSEevaluated 226 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-226
362 free(group->seed);-
363 group->seed = NULL;-
364 group->seed_len = 0;-
365 }
never executed: end of block
0
366 if (!len || !p)
!lenDescription
TRUEnever evaluated
FALSEevaluated 226 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
!pDescription
TRUEnever evaluated
FALSEevaluated 226 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-226
367 return 1;
never executed: return 1;
0
368-
369 if ((group->seed = malloc(len)) == NULL)
(group->seed =...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 226 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-226
370 return 0;
never executed: return 0;
0
371 memcpy(group->seed, p, len);-
372 group->seed_len = len;-
373-
374 return len;
executed 226 times by 4 tests: return len;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
226
375}-
376-
377-
378unsigned char *-
379EC_GROUP_get0_seed(const EC_GROUP * group)-
380{-
381 return group->seed;
never executed: return group->seed;
0
382}-
383-
384-
385size_t -
386EC_GROUP_get_seed_len(const EC_GROUP * group)-
387{-
388 return group->seed_len;
never executed: return group->seed_len;
0
389}-
390-
391-
392int -
393EC_GROUP_set_curve_GFp(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a,-
394 const BIGNUM * b, BN_CTX * ctx)-
395{-
396 if (group->meth->group_set_curve == 0) {
group->meth->g...set_curve == 0Description
TRUEnever evaluated
FALSEevaluated 256 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-256
397 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
398 return 0;
never executed: return 0;
0
399 }-
400 return group->meth->group_set_curve(group, p, a, b, ctx);
executed 256 times by 4 tests: return group->meth->group_set_curve(group, p, a, b, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
256
401}-
402-
403-
404int -
405EC_GROUP_get_curve_GFp(const EC_GROUP * group, BIGNUM * p, BIGNUM * a,-
406 BIGNUM * b, BN_CTX * ctx)-
407{-
408 if (group->meth->group_get_curve == 0) {
group->meth->g...get_curve == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ectest
0-1
409 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
410 return 0;
never executed: return 0;
0
411 }-
412 return group->meth->group_get_curve(group, p, a, b, ctx);
executed 1 time by 1 test: return group->meth->group_get_curve(group, p, a, b, ctx);
Executed by:
  • ectest
1
413}-
414-
415#ifndef OPENSSL_NO_EC2M-
416int -
417EC_GROUP_set_curve_GF2m(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a,-
418 const BIGNUM * b, BN_CTX * ctx)-
419{-
420 if (group->meth->group_set_curve == 0) {
group->meth->g...set_curve == 0Description
TRUEnever evaluated
FALSEevaluated 148 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
0-148
421 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
422 return 0;
never executed: return 0;
0
423 }-
424 return group->meth->group_set_curve(group, p, a, b, ctx);
executed 148 times by 3 tests: return group->meth->group_set_curve(group, p, a, b, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
148
425}-
426-
427-
428int -
429EC_GROUP_get_curve_GF2m(const EC_GROUP * group, BIGNUM * p, BIGNUM * a,-
430 BIGNUM * b, BN_CTX * ctx)-
431{-
432 if (group->meth->group_get_curve == 0) {
group->meth->g...get_curve == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ectest
0-1
433 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
434 return 0;
never executed: return 0;
0
435 }-
436 return group->meth->group_get_curve(group, p, a, b, ctx);
executed 1 time by 1 test: return group->meth->group_get_curve(group, p, a, b, ctx);
Executed by:
  • ectest
1
437}-
438#endif-
439-
440int -
441EC_GROUP_get_degree(const EC_GROUP * group)-
442{-
443 if (group->meth->group_get_degree == 0) {
group->meth->g...et_degree == 0Description
TRUEnever evaluated
FALSEevaluated 238 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-238
444 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
445 return 0;
never executed: return 0;
0
446 }-
447 return group->meth->group_get_degree(group);
executed 238 times by 4 tests: return group->meth->group_get_degree(group);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
238
448}-
449-
450-
451int -
452EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)-
453{-
454 if (group->meth->group_check_discriminant == 0) {
group->meth->g...criminant == 0Description
TRUEnever evaluated
FALSEevaluated 90 times by 1 test
Evaluated by:
  • ectest
0-90
455 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
456 return 0;
never executed: return 0;
0
457 }-
458 return group->meth->group_check_discriminant(group, ctx);
executed 90 times by 1 test: return group->meth->group_check_discriminant(group, ctx);
Executed by:
  • ectest
90
459}-
460-
461-
462int -
463EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx)-
464{-
465 int r = 0;-
466 BIGNUM *a1, *a2, *a3, *b1, *b2, *b3;-
467 BN_CTX *ctx_new = NULL;-
468-
469 /* compare the field types */-
470 if (EC_METHOD_get_field_type(EC_GROUP_method_of(a)) !=
EC_METHOD_get_..._method_of(b))Description
TRUEnever evaluated
FALSEnever evaluated
0
471 EC_METHOD_get_field_type(EC_GROUP_method_of(b)))
EC_METHOD_get_..._method_of(b))Description
TRUEnever evaluated
FALSEnever evaluated
0
472 return 1;
never executed: return 1;
0
473 /* compare the curve name (if present in both) */-
474 if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) &&
EC_GROUP_get_curve_name(a)Description
TRUEnever evaluated
FALSEnever evaluated
EC_GROUP_get_curve_name(b)Description
TRUEnever evaluated
FALSEnever evaluated
0
475 EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b))
EC_GROUP_get_c..._curve_name(b)Description
TRUEnever evaluated
FALSEnever evaluated
0
476 return 1;
never executed: return 1;
0
477-
478 if (!ctx)
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
479 ctx_new = ctx = BN_CTX_new();
never executed: ctx_new = ctx = BN_CTX_new();
0
480 if (!ctx)
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
481 return -1;
never executed: return -1;
0
482-
483 BN_CTX_start(ctx);-
484 if ((a1 = BN_CTX_get(ctx)) == NULL)
(a1 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
485 goto err;
never executed: goto err;
0
486 if ((a2 = BN_CTX_get(ctx)) == NULL)
(a2 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
487 goto err;
never executed: goto err;
0
488 if ((a3 = BN_CTX_get(ctx)) == NULL)
(a3 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
489 goto err;
never executed: goto err;
0
490 if ((b1 = BN_CTX_get(ctx)) == NULL)
(b1 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
491 goto err;
never executed: goto err;
0
492 if ((b2 = BN_CTX_get(ctx)) == NULL)
(b2 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
493 goto err;
never executed: goto err;
0
494 if ((b3 = BN_CTX_get(ctx)) == NULL)
(b3 = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
495 goto err;
never executed: goto err;
0
496-
497 /*-
498 * XXX This approach assumes that the external representation of-
499 * curves over the same field type is the same.-
500 */-
501 if (!a->meth->group_get_curve(a, a1, a2, a3, ctx) ||
!a->meth->grou..., a2, a3, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
502 !b->meth->group_get_curve(b, b1, b2, b3, ctx))
!b->meth->grou..., b2, b3, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
503 r = 1;
never executed: r = 1;
0
504-
505 if (r || BN_cmp(a1, b1) || BN_cmp(a2, b2) || BN_cmp(a3, b3))
rDescription
TRUEnever evaluated
FALSEnever evaluated
BN_cmp(a1, b1)Description
TRUEnever evaluated
FALSEnever evaluated
BN_cmp(a2, b2)Description
TRUEnever evaluated
FALSEnever evaluated
BN_cmp(a3, b3)Description
TRUEnever evaluated
FALSEnever evaluated
0
506 r = 1;
never executed: r = 1;
0
507-
508 /* XXX EC_POINT_cmp() assumes that the methods are equal */-
509 if (r || EC_POINT_cmp(a, EC_GROUP_get0_generator(a),
rDescription
TRUEnever evaluated
FALSEnever evaluated
EC_POINT_cmp(a...rator(b), ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
510 EC_GROUP_get0_generator(b), ctx))
EC_POINT_cmp(a...rator(b), ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
511 r = 1;
never executed: r = 1;
0
512-
513 if (!r) {
!rDescription
TRUEnever evaluated
FALSEnever evaluated
0
514 /* compare the order and cofactor */-
515 if (!EC_GROUP_get_order(a, a1, ctx) ||
!EC_GROUP_get_...er(a, a1, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
516 !EC_GROUP_get_order(b, b1, ctx) ||
!EC_GROUP_get_...er(b, b1, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
517 !EC_GROUP_get_cofactor(a, a2, ctx) ||
!EC_GROUP_get_...or(a, a2, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
518 !EC_GROUP_get_cofactor(b, b2, ctx))
!EC_GROUP_get_...or(b, b2, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
519 goto err;
never executed: goto err;
0
520 if (BN_cmp(a1, b1) || BN_cmp(a2, b2))
BN_cmp(a1, b1)Description
TRUEnever evaluated
FALSEnever evaluated
BN_cmp(a2, b2)Description
TRUEnever evaluated
FALSEnever evaluated
0
521 r = 1;
never executed: r = 1;
0
522 }
never executed: end of block
0
523 BN_CTX_end(ctx);-
524 if (ctx_new)
ctx_newDescription
TRUEnever evaluated
FALSEnever evaluated
0
525 BN_CTX_free(ctx);
never executed: BN_CTX_free(ctx);
0
526-
527 return r;
never executed: return r;
0
528-
529 err:-
530 BN_CTX_end(ctx);-
531 if (ctx_new)
ctx_newDescription
TRUEnever evaluated
FALSEnever evaluated
0
532 BN_CTX_free(ctx);
never executed: BN_CTX_free(ctx);
0
533 return -1;
never executed: return -1;
0
534}-
535-
536-
537/* this has 'package' visibility */-
538int -
539EC_EX_DATA_set_data(EC_EXTRA_DATA ** ex_data, void *data,-
540 void *(*dup_func) (void *),-
541 void (*free_func) (void *),-
542 void (*clear_free_func) (void *))-
543{-
544 EC_EXTRA_DATA *d;-
545-
546 if (ex_data == NULL)
ex_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-254
547 return 0;
never executed: return 0;
0
548-
549 for (d = *ex_data; d != NULL; d = d->next) {
d != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-254
550 if (d->dup_func == dup_func && d->free_func == free_func &&
d->dup_func == dup_funcDescription
TRUEnever evaluated
FALSEnever evaluated
d->free_func == free_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
551 d->clear_free_func == clear_free_func) {
d->clear_free_...lear_free_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
552 ECerror(EC_R_SLOT_FULL);-
553 return 0;
never executed: return 0;
0
554 }-
555 }
never executed: end of block
0
556-
557 if (data == NULL)
data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-254
558 /* no explicit entry needed */-
559 return 1;
never executed: return 1;
0
560-
561 d = malloc(sizeof *d);-
562 if (d == NULL)
d == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-254
563 return 0;
never executed: return 0;
0
564-
565 d->data = data;-
566 d->dup_func = dup_func;-
567 d->free_func = free_func;-
568 d->clear_free_func = clear_free_func;-
569-
570 d->next = *ex_data;-
571 *ex_data = d;-
572-
573 return 1;
executed 254 times by 4 tests: return 1;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
254
574}-
575-
576/* this has 'package' visibility */-
577void *-
578EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data,-
579 void *(*dup_func) (void *),-
580 void (*free_func) (void *),-
581 void (*clear_free_func) (void *))-
582{-
583 const EC_EXTRA_DATA *d;-
584-
585 for (d = ex_data; d != NULL; d = d->next) {
d != ((void *)0)Description
TRUEevaluated 456 times by 1 test
Evaluated by:
  • ecdsatest
FALSEevaluated 847 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ssltest
456-847
586 if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func)
d->dup_func == dup_funcDescription
TRUEevaluated 456 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
d->free_func == free_funcDescription
TRUEevaluated 456 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
d->clear_free_...lear_free_funcDescription
TRUEevaluated 456 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
0-456
587 return d->data;
executed 456 times by 1 test: return d->data;
Executed by:
  • ecdsatest
456
588 }
never executed: end of block
0
589-
590 return NULL;
executed 847 times by 3 tests: return ((void *)0) ;
Executed by:
  • ecdhtest
  • ecdsatest
  • ssltest
847
591}-
592-
593/* this has 'package' visibility */-
594void -
595EC_EX_DATA_free_data(EC_EXTRA_DATA ** ex_data,-
596 void *(*dup_func) (void *),-
597 void (*free_func) (void *),-
598 void (*clear_free_func) (void *))-
599{-
600 EC_EXTRA_DATA **p;-
601-
602 if (ex_data == NULL)
ex_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • ectest
0-10
603 return;
never executed: return;
0
604-
605 for (p = ex_data; *p != NULL; p = &((*p)->next)) {
*p != ((void *)0)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • ectest
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ectest
1-9
606 if ((*p)->dup_func == dup_func &&
(*p)->dup_func == dup_funcDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • ectest
FALSEnever evaluated
0-9
607 (*p)->free_func == free_func &&
(*p)->free_func == free_funcDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • ectest
FALSEnever evaluated
0-9
608 (*p)->clear_free_func == clear_free_func) {
(*p)->clear_fr...lear_free_funcDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • ectest
FALSEnever evaluated
0-9
609 EC_EXTRA_DATA *next = (*p)->next;-
610-
611 (*p)->free_func((*p)->data);-
612 free(*p);-
613-
614 *p = next;-
615 return;
executed 9 times by 1 test: return;
Executed by:
  • ectest
9
616 }-
617 }
never executed: end of block
0
618}
executed 1 time by 1 test: end of block
Executed by:
  • ectest
1
619-
620/* this has 'package' visibility */-
621void -
622EC_EX_DATA_clear_free_data(EC_EXTRA_DATA ** ex_data,-
623 void *(*dup_func) (void *),-
624 void (*free_func) (void *),-
625 void (*clear_free_func) (void *))-
626{-
627 EC_EXTRA_DATA **p;-
628-
629 if (ex_data == NULL)
ex_data == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
630 return;
never executed: return;
0
631-
632 for (p = ex_data; *p != NULL; p = &((*p)->next)) {
*p != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
633 if ((*p)->dup_func == dup_func &&
(*p)->dup_func == dup_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
634 (*p)->free_func == free_func &&
(*p)->free_func == free_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
635 (*p)->clear_free_func == clear_free_func) {
(*p)->clear_fr...lear_free_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
636 EC_EXTRA_DATA *next = (*p)->next;-
637-
638 (*p)->clear_free_func((*p)->data);-
639 free(*p);-
640-
641 *p = next;-
642 return;
never executed: return;
0
643 }-
644 }
never executed: end of block
0
645}
never executed: end of block
0
646-
647/* this has 'package' visibility */-
648void -
649EC_EX_DATA_free_all_data(EC_EXTRA_DATA ** ex_data)-
650{-
651 EC_EXTRA_DATA *d;-
652-
653 if (ex_data == NULL)
ex_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1165 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-1165
654 return;
never executed: return;
0
655-
656 d = *ex_data;-
657 while (d) {
dDescription
TRUEevaluated 245 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 1165 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
245-1165
658 EC_EXTRA_DATA *next = d->next;-
659-
660 d->free_func(d->data);-
661 free(d);-
662-
663 d = next;-
664 }
executed 245 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
245
665 *ex_data = NULL;-
666}
executed 1165 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
1165
667-
668/* this has 'package' visibility */-
669void -
670EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA ** ex_data)-
671{-
672 EC_EXTRA_DATA *d;-
673-
674 if (ex_data == NULL)
ex_data == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
675 return;
never executed: return;
0
676-
677 d = *ex_data;-
678 while (d) {
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
679 EC_EXTRA_DATA *next = d->next;-
680-
681 d->clear_free_func(d->data);-
682 free(d);-
683-
684 d = next;-
685 }
never executed: end of block
0
686 *ex_data = NULL;-
687}
never executed: end of block
0
688-
689-
690/* functions for EC_POINT objects */-
691-
692EC_POINT *-
693EC_POINT_new(const EC_GROUP * group)-
694{-
695 EC_POINT *ret;-
696-
697 if (group == NULL) {
group == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10236 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-10236
698 ECerror(ERR_R_PASSED_NULL_PARAMETER);-
699 return NULL;
never executed: return ((void *)0) ;
0
700 }-
701 if (group->meth->point_init == 0) {
group->meth->point_init == 0Description
TRUEnever evaluated
FALSEevaluated 10236 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-10236
702 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
703 return NULL;
never executed: return ((void *)0) ;
0
704 }-
705 ret = malloc(sizeof *ret);-
706 if (ret == NULL) {
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10236 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-10236
707 ECerror(ERR_R_MALLOC_FAILURE);-
708 return NULL;
never executed: return ((void *)0) ;
0
709 }-
710 ret->meth = group->meth;-
711-
712 if (!ret->meth->point_init(ret)) {
!ret->meth->point_init(ret)Description
TRUEnever evaluated
FALSEevaluated 10236 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-10236
713 free(ret);-
714 return NULL;
never executed: return ((void *)0) ;
0
715 }-
716 return ret;
executed 10236 times by 4 tests: return ret;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
10236
717}-
718-
719-
720void -
721EC_POINT_free(EC_POINT * point)-
722{-
723 if (!point)
!pointDescription
TRUEevaluated 95 times by 5 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • freenull
  • ssltest
FALSEevaluated 6524 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
95-6524
724 return;
executed 95 times by 5 tests: return;
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • freenull
  • ssltest
95
725-
726 if (point->meth->point_finish != 0)
point->meth->point_finish != 0Description
TRUEevaluated 6524 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-6524
727 point->meth->point_finish(point);
executed 6524 times by 4 tests: point->meth->point_finish(point);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
6524
728 free(point);-
729}
executed 6524 times by 4 tests: end of block
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
6524
730-
731-
732void -
733EC_POINT_clear_free(EC_POINT * point)-
734{-
735 if (!point)
!pointDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ectest
  • freenull
FALSEevaluated 3712 times by 1 test
Evaluated by:
  • ecdsatest
3-3712
736 return;
executed 3 times by 2 tests: return;
Executed by:
  • ectest
  • freenull
3
737-
738 if (point->meth->point_clear_finish != 0)
point->meth->p...ar_finish != 0Description
TRUEevaluated 3712 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
0-3712
739 point->meth->point_clear_finish(point);
executed 3712 times by 1 test: point->meth->point_clear_finish(point);
Executed by:
  • ecdsatest
3712
740 else if (point->meth->point_finish != 0)
point->meth->point_finish != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
741 point->meth->point_finish(point);
never executed: point->meth->point_finish(point);
0
742 freezero(point, sizeof *point);-
743}
executed 3712 times by 1 test: end of block
Executed by:
  • ecdsatest
3712
744-
745-
746int -
747EC_POINT_copy(EC_POINT * dest, const EC_POINT * src)-
748{-
749 if (dest->meth->point_copy == 0) {
dest->meth->point_copy == 0Description
TRUEnever evaluated
FALSEevaluated 28962 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-28962
750 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
751 return 0;
never executed: return 0;
0
752 }-
753 if (dest->meth != src->meth) {
dest->meth != src->methDescription
TRUEnever evaluated
FALSEevaluated 28962 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-28962
754 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
755 return 0;
never executed: return 0;
0
756 }-
757 if (dest == src)
dest == srcDescription
TRUEevaluated 25288 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
FALSEevaluated 3674 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
3674-25288
758 return 1;
executed 25288 times by 2 tests: return 1;
Executed by:
  • ecdsatest
  • ectest
25288
759 return dest->meth->point_copy(dest, src);
executed 3674 times by 4 tests: return dest->meth->point_copy(dest, src);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
3674
760}-
761-
762-
763EC_POINT *-
764EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group)-
765{-
766 EC_POINT *t;-
767 int r;-
768-
769 if (a == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • ecdhtest
  • ssltest
0-29
770 return NULL;
never executed: return ((void *)0) ;
0
771-
772 t = EC_POINT_new(group);-
773 if (t == NULL)
t == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • ecdhtest
  • ssltest
0-29
774 return (NULL);
never executed: return ( ((void *)0) );
0
775 r = EC_POINT_copy(t, a);-
776 if (!r) {
!rDescription
TRUEnever evaluated
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • ecdhtest
  • ssltest
0-29
777 EC_POINT_free(t);-
778 return NULL;
never executed: return ((void *)0) ;
0
779 } else-
780 return t;
executed 29 times by 2 tests: return t;
Executed by:
  • ecdhtest
  • ssltest
29
781}-
782-
783-
784const EC_METHOD *-
785EC_POINT_method_of(const EC_POINT * point)-
786{-
787 return point->meth;
never executed: return point->meth;
0
788}-
789-
790-
791int -
792EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point)-
793{-
794 if (group->meth->point_set_to_infinity == 0) {
group->meth->p..._infinity == 0Description
TRUEnever evaluated
FALSEevaluated 103 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-103
795 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
796 return 0;
never executed: return 0;
0
797 }-
798 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 103 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-103
799 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
800 return 0;
never executed: return 0;
0
801 }-
802 return group->meth->point_set_to_infinity(group, point);
executed 103 times by 2 tests: return group->meth->point_set_to_infinity(group, point);
Executed by:
  • ecdsatest
  • ectest
103
803}-
804-
805-
806int -
807EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,-
808 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)-
809{-
810 if (group->meth->point_set_Jprojective_coordinates_GFp == 0) {
group->meth->p...nates_GFp == 0Description
TRUEnever evaluated
FALSEevaluated 305 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-305
811 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
812 return 0;
never executed: return 0;
0
813 }-
814 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 305 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-305
815 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
816 return 0;
never executed: return 0;
0
817 }-
818 return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
executed 305 times by 4 tests: return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
305
819}-
820-
821-
822int -
823EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,-
824 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx)-
825{-
826 if (group->meth->point_get_Jprojective_coordinates_GFp == 0) {
group->meth->p...nates_GFp == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ectest
0-1
827 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
828 return 0;
never executed: return 0;
0
829 }-
830 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ectest
0-1
831 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
832 return 0;
never executed: return 0;
0
833 }-
834 return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
executed 1 time by 1 test: return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
Executed by:
  • ectest
1
835}-
836-
837-
838int -
839EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,-
840 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)-
841{-
842 if (group->meth->point_set_affine_coordinates == 0) {
group->meth->p...ordinates == 0Description
TRUEnever evaluated
FALSEevaluated 442 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-442
843 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
844 return 0;
never executed: return 0;
0
845 }-
846 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 442 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-442
847 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
848 return 0;
never executed: return 0;
0
849 }-
850 return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
executed 442 times by 4 tests: return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
442
851}-
852-
853#ifndef OPENSSL_NO_EC2M-
854int -
855EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,-
856 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)-
857{-
858 if (group->meth->point_set_affine_coordinates == 0) {
group->meth->p...ordinates == 0Description
TRUEnever evaluated
FALSEevaluated 214889 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
0-214889
859 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
860 return 0;
never executed: return 0;
0
861 }-
862 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 214889 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
0-214889
863 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
864 return 0;
never executed: return 0;
0
865 }-
866 return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
executed 214889 times by 3 tests: return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
214889
867}-
868#endif-
869-
870int -
871EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,-
872 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)-
873{-
874 if (group->meth->point_get_affine_coordinates == 0) {
group->meth->p...ordinates == 0Description
TRUEnever evaluated
FALSEevaluated 385 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-385
875 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
876 return 0;
never executed: return 0;
0
877 }-
878 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 385 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-385
879 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
880 return 0;
never executed: return 0;
0
881 }-
882 return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
executed 385 times by 4 tests: return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
385
883}-
884-
885#ifndef OPENSSL_NO_EC2M-
886int -
887EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,-
888 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)-
889{-
890 if (group->meth->point_get_affine_coordinates == 0) {
group->meth->p...ordinates == 0Description
TRUEnever evaluated
FALSEevaluated 251 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
0-251
891 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
892 return 0;
never executed: return 0;
0
893 }-
894 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 251 times by 3 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
0-251
895 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
896 return 0;
never executed: return 0;
0
897 }-
898 return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
executed 251 times by 3 tests: return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
251
899}-
900#endif-
901-
902int -
903EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,-
904 const EC_POINT *b, BN_CTX *ctx)-
905{-
906 if (group->meth->add == 0) {
group->meth->add == 0Description
TRUEnever evaluated
FALSEevaluated 238801 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-238801
907 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
908 return 0;
never executed: return 0;
0
909 }-
910 if ((group->meth != r->meth) || (r->meth != a->meth) || (a->meth != b->meth)) {
(group->meth != r->meth)Description
TRUEnever evaluated
FALSEevaluated 238801 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
(r->meth != a->meth)Description
TRUEnever evaluated
FALSEevaluated 238801 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
(a->meth != b->meth)Description
TRUEnever evaluated
FALSEevaluated 238801 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-238801
911 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
912 return 0;
never executed: return 0;
0
913 }-
914 return group->meth->add(group, r, a, b, ctx);
executed 238801 times by 4 tests: return group->meth->add(group, r, a, b, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
238801
915}-
916-
917-
918int -
919EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)-
920{-
921 if (group->meth->dbl == 0) {
group->meth->dbl == 0Description
TRUEnever evaluated
FALSEevaluated 299192 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-299192
922 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
923 return 0;
never executed: return 0;
0
924 }-
925 if ((group->meth != r->meth) || (r->meth != a->meth)) {
(group->meth != r->meth)Description
TRUEnever evaluated
FALSEevaluated 299192 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
(r->meth != a->meth)Description
TRUEnever evaluated
FALSEevaluated 299192 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-299192
926 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
927 return 0;
never executed: return 0;
0
928 }-
929 return group->meth->dbl(group, r, a, ctx);
executed 299192 times by 4 tests: return group->meth->dbl(group, r, a, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
299192
930}-
931-
932-
933int -
934EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)-
935{-
936 if (group->meth->invert == 0) {
group->meth->invert == 0Description
TRUEnever evaluated
FALSEevaluated 18568 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-18568
937 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
938 return 0;
never executed: return 0;
0
939 }-
940 if (group->meth != a->meth) {
group->meth != a->methDescription
TRUEnever evaluated
FALSEevaluated 18568 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-18568
941 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
942 return 0;
never executed: return 0;
0
943 }-
944 return group->meth->invert(group, a, ctx);
executed 18568 times by 2 tests: return group->meth->invert(group, a, ctx);
Executed by:
  • ecdsatest
  • ectest
18568
945}-
946-
947-
948int -
949EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)-
950{-
951 if (group->meth->is_at_infinity == 0) {
group->meth->i..._infinity == 0Description
TRUEnever evaluated
FALSEevaluated 902355 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-902355
952 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
953 return 0;
never executed: return 0;
0
954 }-
955 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 902355 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-902355
956 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
957 return 0;
never executed: return 0;
0
958 }-
959 return group->meth->is_at_infinity(group, point);
executed 902355 times by 4 tests: return group->meth->is_at_infinity(group, point);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
902355
960}-
961-
962-
963int -
964EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx)-
965{-
966 if (group->meth->is_on_curve == 0) {
group->meth->is_on_curve == 0Description
TRUEnever evaluated
FALSEevaluated 318 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-318
967 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
968 return 0;
never executed: return 0;
0
969 }-
970 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 318 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-318
971 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
972 return 0;
never executed: return 0;
0
973 }-
974 return group->meth->is_on_curve(group, point, ctx);
executed 318 times by 4 tests: return group->meth->is_on_curve(group, point, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
318
975}-
976-
977-
978int -
979EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,-
980 BN_CTX * ctx)-
981{-
982 if (group->meth->point_cmp == 0) {
group->meth->point_cmp == 0Description
TRUEnever evaluated
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-130
983 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
984 return -1;
never executed: return -1;
0
985 }-
986 if ((group->meth != a->meth) || (a->meth != b->meth)) {
(group->meth != a->meth)Description
TRUEnever evaluated
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
(a->meth != b->meth)Description
TRUEnever evaluated
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-130
987 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
988 return -1;
never executed: return -1;
0
989 }-
990 return group->meth->point_cmp(group, a, b, ctx);
executed 130 times by 2 tests: return group->meth->point_cmp(group, a, b, ctx);
Executed by:
  • ecdsatest
  • ectest
130
991}-
992-
993-
994int -
995EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)-
996{-
997 if (group->meth->make_affine == 0) {
group->meth->make_affine == 0Description
TRUEnever evaluated
FALSEevaluated 8044 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-8044
998 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
999 return 0;
never executed: return 0;
0
1000 }-
1001 if (group->meth != point->meth) {
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 8044 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-8044
1002 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
1003 return 0;
never executed: return 0;
0
1004 }-
1005 return group->meth->make_affine(group, point, ctx);
executed 8044 times by 2 tests: return group->meth->make_affine(group, point, ctx);
Executed by:
  • ecdsatest
  • ectest
8044
1006}-
1007-
1008-
1009int -
1010EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],-
1011 BN_CTX *ctx)-
1012{-
1013 size_t i;-
1014-
1015 if (group->meth->points_make_affine == 0) {
group->meth->p...ke_affine == 0Description
TRUEnever evaluated
FALSEevaluated 389 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-389
1016 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
1017 return 0;
never executed: return 0;
0
1018 }-
1019 for (i = 0; i < num; i++) {
i < numDescription
TRUEevaluated 7072 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
FALSEevaluated 389 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
389-7072
1020 if (group->meth != points[i]->meth) {
group->meth != points[i]->methDescription
TRUEnever evaluated
FALSEevaluated 7072 times by 2 tests
Evaluated by:
  • ecdsatest
  • ectest
0-7072
1021 ECerror(EC_R_INCOMPATIBLE_OBJECTS);-
1022 return 0;
never executed: return 0;
0
1023 }-
1024 }
executed 7072 times by 2 tests: end of block
Executed by:
  • ecdsatest
  • ectest
7072
1025 return group->meth->points_make_affine(group, num, points, ctx);
executed 389 times by 2 tests: return group->meth->points_make_affine(group, num, points, ctx);
Executed by:
  • ecdsatest
  • ectest
389
1026}-
1027-
1028-
1029/* Functions for point multiplication */-
1030int -
1031EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,-
1032 size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)-
1033{-
1034 /*-
1035 * The function pointers must be set, and only support num == 0 and-
1036 * num == 1.-
1037 */-
1038 if (group->meth->mul_generator_ct == NULL ||
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1039 group->meth->mul_single_ct == NULL ||
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1040 group->meth->mul_double_nonct == NULL ||
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1041 num > 1) {
num > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1042 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
1043 return 0;
never executed: return 0;
0
1044 }-
1045 -
1046 /* Either bP or aG + bP, this is sane. */-
1047 if (num == 1 && points != NULL && scalars != NULL)
num == 1Description
TRUEnever evaluated
FALSEnever evaluated
points != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
scalars != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1048 return EC_POINT_mul(group, r, scalar, points[0], scalars[0],
never executed: return EC_POINT_mul(group, r, scalar, points[0], scalars[0], ctx);
0
1049 ctx);
never executed: return EC_POINT_mul(group, r, scalar, points[0], scalars[0], ctx);
0
1050 -
1051 /* aG, this is sane */-
1052 if (scalar != NULL && points == NULL && scalars == NULL)
scalar != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
points == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
scalars == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 return EC_POINT_mul(group, r, scalar, NULL, NULL, ctx);
never executed: return EC_POINT_mul(group, r, scalar, ((void *)0) , ((void *)0) , ctx);
0
1054 -
1055 /* anything else is an error */-
1056 ECerror(ERR_R_EC_LIB);-
1057 return 0;
never executed: return 0;
0
1058}-
1059-
1060int -
1061EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,-
1062 const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)-
1063{-
1064 if (group->meth->mul_generator_ct == NULL ||
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1093 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-1093
1065 group->meth->mul_single_ct == NULL ||
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1093 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-1093
1066 group->meth->mul_double_nonct == NULL) {
group->meth->m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1093 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
0-1093
1067 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
1068 return 0;
never executed: return 0;
0
1069 }-
1070 if (g_scalar != NULL && point == NULL && p_scalar == NULL) {
g_scalar != ((void *)0)Description
TRUEevaluated 887 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 206 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
point == ((void *)0)Description
TRUEevaluated 508 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 379 times by 1 test
Evaluated by:
  • ecdsatest
p_scalar == ((void *)0)Description
TRUEevaluated 508 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-887
1071 /*-
1072 * In this case we want to compute g_scalar * GeneratorPoint:-
1073 * this codepath is reached most prominently by (ephemeral) key-
1074 * generation of EC cryptosystems (i.e. ECDSA keygen and sign-
1075 * setup, ECDH keygen/first half), where the scalar is always-
1076 * secret. This is why we ignore if BN_FLG_CONSTTIME is actually-
1077 * set and we always call the constant time version.-
1078 */-
1079 return group->meth->mul_generator_ct(group, r, g_scalar, ctx);
executed 508 times by 4 tests: return group->meth->mul_generator_ct(group, r, g_scalar, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
508
1080 }-
1081 if (g_scalar == NULL && point != NULL && p_scalar != NULL) {
g_scalar == ((void *)0)Description
TRUEevaluated 206 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEevaluated 379 times by 1 test
Evaluated by:
  • ecdsatest
point != ((void *)0)Description
TRUEevaluated 206 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
p_scalar != ((void *)0)Description
TRUEevaluated 206 times by 4 tests
Evaluated by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
FALSEnever evaluated
0-379
1082 /* In this case we want to compute p_scalar * GenericPoint:-
1083 * this codepath is reached most prominently by the second half-
1084 * of ECDH, where the secret scalar is multiplied by the peer's-
1085 * public point. To protect the secret scalar, we ignore if-
1086 * BN_FLG_CONSTTIME is actually set and we always call the-
1087 * constant time version.-
1088 */-
1089 return group->meth->mul_single_ct(group, r, p_scalar, point,
executed 206 times by 4 tests: return group->meth->mul_single_ct(group, r, p_scalar, point, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
206
1090 ctx);
executed 206 times by 4 tests: return group->meth->mul_single_ct(group, r, p_scalar, point, ctx);
Executed by:
  • ecdhtest
  • ecdsatest
  • ectest
  • ssltest
206
1091 }-
1092 if (g_scalar != NULL && point != NULL && p_scalar != NULL) {
g_scalar != ((void *)0)Description
TRUEevaluated 379 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
point != ((void *)0)Description
TRUEevaluated 379 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
p_scalar != ((void *)0)Description
TRUEevaluated 379 times by 1 test
Evaluated by:
  • ecdsatest
FALSEnever evaluated
0-379
1093 /*-
1094 * In this case we want to compute-
1095 * g_scalar * GeneratorPoint + p_scalar * GenericPoint:-
1096 * this codepath is reached most prominently by ECDSA signature-
1097 * verification. So we call the non-ct version.-
1098 */-
1099 return group->meth->mul_double_nonct(group, r, g_scalar,
executed 379 times by 1 test: return group->meth->mul_double_nonct(group, r, g_scalar, p_scalar, point, ctx);
Executed by:
  • ecdsatest
379
1100 p_scalar, point, ctx);
executed 379 times by 1 test: return group->meth->mul_double_nonct(group, r, g_scalar, p_scalar, point, ctx);
Executed by:
  • ecdsatest
379
1101 }-
1102 -
1103 /* Anything else is an error. */-
1104 ECerror(ERR_R_EC_LIB);-
1105 return 0;
never executed: return 0;
0
1106}-
1107-
1108int -
1109EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx)-
1110{-
1111 if (group->meth->precompute_mult != 0)
group->meth->p...pute_mult != 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • ectest
FALSEevaluated 6 times by 1 test
Evaluated by:
  • ectest
6-10
1112 return group->meth->precompute_mult(group, ctx);
executed 10 times by 1 test: return group->meth->precompute_mult(group, ctx);
Executed by:
  • ectest
10
1113 else-
1114 return 1; /* nothing to do, so report success */
executed 6 times by 1 test: return 1;
Executed by:
  • ectest
6
1115}-
1116-
1117int -
1118EC_GROUP_have_precompute_mult(const EC_GROUP * group)-
1119{-
1120 if (group->meth->have_precompute_mult != 0)
group->meth->h...pute_mult != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1121 return group->meth->have_precompute_mult(group);
never executed: return group->meth->have_precompute_mult(group);
0
1122 else-
1123 return 0; /* cannot tell whether precomputation has
never executed: return 0;
0
1124 * been performed */-
1125}-
1126-
1127EC_KEY *-
1128ECParameters_dup(EC_KEY *key)-
1129{-
1130 unsigned char *p = NULL;-
1131 EC_KEY *k = NULL;-
1132 int len;-
1133-
1134 if (key == NULL)
key == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1135 return (NULL);
never executed: return ( ((void *)0) );
0
1136-
1137 if ((len = i2d_ECParameters(key, &p)) > 0)
(len = i2d_ECP...(key, &p)) > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1138 k = d2i_ECParameters(NULL, (const unsigned char **)&p, len);
never executed: k = d2i_ECParameters( ((void *)0) , (const unsigned char **)&p, len);
0
1139-
1140 return (k);
never executed: return (k);
0
1141}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2