OpenCoverage

ec_lcl.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ec_lcl.h
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3struct ec_method_st {-
4-
5 int flags;-
6-
7 int field_type;-
8-
9-
10-
11-
12 int (*group_init) (EC_GROUP *);-
13 void (*group_finish) (EC_GROUP *);-
14 void (*group_clear_finish) (EC_GROUP *);-
15 int (*group_copy) (EC_GROUP *, const EC_GROUP *);-
16-
17 int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,-
18 const BIGNUM *b, BN_CTX *);-
19 int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,-
20 BN_CTX *);-
21-
22 int (*group_get_degree) (const EC_GROUP *);-
23 int (*group_order_bits) (const EC_GROUP *);-
24-
25 int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *);-
26-
27-
28-
29-
30 int (*point_init) (EC_POINT *);-
31 void (*point_finish) (EC_POINT *);-
32 void (*point_clear_finish) (EC_POINT *);-
33 int (*point_copy) (EC_POINT *, const EC_POINT *);-
34 int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);-
35 int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,-
36 EC_POINT *, const BIGNUM *x,-
37 const BIGNUM *y,-
38 const BIGNUM *z, BN_CTX *);-
39 int (*point_get_Jprojective_coordinates_GFp) (const EC_GROUP *,-
40 const EC_POINT *, BIGNUM *x,-
41 BIGNUM *y, BIGNUM *z,-
42 BN_CTX *);-
43 int (*point_set_affine_coordinates) (const EC_GROUP *, EC_POINT *,-
44 const BIGNUM *x, const BIGNUM *y,-
45 BN_CTX *);-
46 int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *,-
47 BIGNUM *x, BIGNUM *y, BN_CTX *);-
48 int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *,-
49 const BIGNUM *x, int y_bit,-
50 BN_CTX *);-
51-
52 size_t (*point2oct) (const EC_GROUP *, const EC_POINT *,-
53 point_conversion_form_t form, unsigned char *buf,-
54 size_t len, BN_CTX *);-
55 int (*oct2point) (const EC_GROUP *, EC_POINT *, const unsigned char *buf,-
56 size_t len, BN_CTX *);-
57-
58 int (*add) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a,-
59 const EC_POINT *b, BN_CTX *);-
60 int (*dbl) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);-
61 int (*invert) (const EC_GROUP *, EC_POINT *, BN_CTX *);-
62-
63-
64-
65 int (*is_at_infinity) (const EC_GROUP *, const EC_POINT *);-
66 int (*is_on_curve) (const EC_GROUP *, const EC_POINT *, BN_CTX *);-
67 int (*point_cmp) (const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,-
68 BN_CTX *);-
69-
70 int (*make_affine) (const EC_GROUP *, EC_POINT *, BN_CTX *);-
71 int (*points_make_affine) (const EC_GROUP *, size_t num, EC_POINT *[],-
72 BN_CTX *);-
73 int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,-
74 size_t num, const EC_POINT *points[], const BIGNUM *scalars[],-
75 BN_CTX *);-
76 int (*precompute_mult) (EC_GROUP *group, BN_CTX *);-
77 int (*have_precompute_mult) (const EC_GROUP *group);-
78-
79-
80-
81-
82-
83-
84-
85 int (*field_mul) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
86 const BIGNUM *b, BN_CTX *);-
87 int (*field_sqr) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);-
88 int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
89 const BIGNUM *b, BN_CTX *);-
90-
91 int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
92 BN_CTX *);-
93-
94 int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
95 BN_CTX *);-
96 int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *);-
97-
98 size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len);-
99 int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len);-
100 int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key);-
101 int (*keygen)(EC_KEY *eckey);-
102 int (*keycheck)(const EC_KEY *eckey);-
103 int (*keygenpub)(EC_KEY *eckey);-
104 int (*keycopy)(EC_KEY *dst, const EC_KEY *src);-
105 void (*keyfinish)(EC_KEY *eckey);-
106-
107 int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,-
108 const EC_POINT *pub_key, const EC_KEY *ecdh);-
109-
110 int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r,-
111 const BIGNUM *x, BN_CTX *);-
112 int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);-
113 int (*ladder_pre)(const EC_GROUP *group,-
114 EC_POINT *r, EC_POINT *s,-
115 EC_POINT *p, BN_CTX *ctx);-
116 int (*ladder_step)(const EC_GROUP *group,-
117 EC_POINT *r, EC_POINT *s,-
118 EC_POINT *p, BN_CTX *ctx);-
119 int (*ladder_post)(const EC_GROUP *group,-
120 EC_POINT *r, EC_POINT *s,-
121 EC_POINT *p, BN_CTX *ctx);-
122};-
123-
124-
125-
126-
127typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP;-
128typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP;-
129typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP;-
130typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP;-
131typedef struct ec_pre_comp_st EC_PRE_COMP;-
132-
133struct ec_group_st {-
134 const EC_METHOD *meth;-
135 EC_POINT *generator;-
136 BIGNUM *order, *cofactor;-
137 int curve_name;-
138 int asn1_flag;-
139 point_conversion_form_t asn1_form;-
140 unsigned char *seed;-
141-
142 size_t seed_len;-
143 BIGNUM *field;-
144-
145-
146-
147-
148-
149-
150-
151 int poly[6];-
152-
153-
154-
155-
156-
157-
158-
159 BIGNUM *a, *b;-
160-
161 int a_is_minus3;-
162-
163 void *field_data1;-
164-
165 void *field_data2;-
166-
167 int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *,-
168 BN_CTX *);-
169-
170 BN_MONT_CTX *mont_data;-
171-
172-
173-
174-
175-
176-
177 enum {-
178 PCT_none,-
179 PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,-
180 PCT_ec-
181 } pre_comp_type;-
182 union {-
183 NISTP224_PRE_COMP *nistp224;-
184 NISTP256_PRE_COMP *nistp256;-
185 NISTP521_PRE_COMP *nistp521;-
186 NISTZ256_PRE_COMP *nistz256;-
187 EC_PRE_COMP *ec;-
188 } pre_comp;-
189};-
190-
191-
192-
193-
194-
195-
196struct ec_key_st {-
197 const EC_KEY_METHOD *meth;-
198 ENGINE *engine;-
199 int version;-
200 EC_GROUP *group;-
201 EC_POINT *pub_key;-
202 BIGNUM *priv_key;-
203 unsigned int enc_flag;-
204 point_conversion_form_t conv_form;-
205 CRYPTO_REF_COUNT references;-
206 int flags;-
207 CRYPTO_EX_DATA ex_data;-
208 CRYPTO_RWLOCK *lock;-
209};-
210-
211struct ec_point_st {-
212 const EC_METHOD *meth;-
213-
214 int curve_name;-
215-
216-
217-
218-
219 BIGNUM *X;-
220 BIGNUM *Y;-
221 BIGNUM *Z;-
222-
223 int Z_is_one;-
224-
225};-
226-
227static inline int ec_point_is_compat(const EC_POINT *point,-
228 const EC_GROUP *group)-
229{-
230 if (group->meth != point->meth
group->meth != point->methDescription
TRUEnever evaluated
FALSEevaluated 1949088 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-1949088
231 || (group->curve_name != 0
group->curve_name != 0Description
TRUEevaluated 1702404 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 246684 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
246684-1702404
232 && point->curve_name != 0
point->curve_name != 0Description
TRUEevaluated 1702402 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-1702402
233 && group->curve_name != point->curve_name
group->curve_n...nt->curve_nameDescription
TRUEnever evaluated
FALSEevaluated 1702402 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
))
0-1702402
234 return
never executed: return 0;
0;
never executed: return 0;
0
235-
236 return
executed 1949088 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 1949088 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1949088
237}-
238-
239NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);-
240NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);-
241NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);-
242NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);-
243NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);-
244EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);-
245-
246void EC_pre_comp_free(EC_GROUP *group);-
247void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);-
248void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);-
249void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);-
250void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *);-
251void EC_ec_pre_comp_free(EC_PRE_COMP *);-
252-
253-
254-
255-
256-
257int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,-
258 size_t num, const EC_POINT *points[], const BIGNUM *scalars[],-
259 BN_CTX *);-
260int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *);-
261int ec_wNAF_have_precompute_mult(const EC_GROUP *group);-
262-
263-
264int ec_GFp_simple_group_init(EC_GROUP *);-
265void ec_GFp_simple_group_finish(EC_GROUP *);-
266void ec_GFp_simple_group_clear_finish(EC_GROUP *);-
267int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *);-
268int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,-
269 const BIGNUM *a, const BIGNUM *b, BN_CTX *);-
270int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,-
271 BIGNUM *b, BN_CTX *);-
272int ec_GFp_simple_group_get_degree(const EC_GROUP *);-
273int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);-
274int ec_GFp_simple_point_init(EC_POINT *);-
275void ec_GFp_simple_point_finish(EC_POINT *);-
276void ec_GFp_simple_point_clear_finish(EC_POINT *);-
277int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);-
278int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);-
279int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *,-
280 EC_POINT *, const BIGNUM *x,-
281 const BIGNUM *y,-
282 const BIGNUM *z, BN_CTX *);-
283int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *,-
284 const EC_POINT *, BIGNUM *x,-
285 BIGNUM *y, BIGNUM *z,-
286 BN_CTX *);-
287int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,-
288 const BIGNUM *x,-
289 const BIGNUM *y, BN_CTX *);-
290int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *,-
291 const EC_POINT *, BIGNUM *x,-
292 BIGNUM *y, BN_CTX *);-
293int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,-
294 const BIGNUM *x, int y_bit,-
295 BN_CTX *);-
296size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *,-
297 point_conversion_form_t form,-
298 unsigned char *buf, size_t len, BN_CTX *);-
299int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,-
300 const unsigned char *buf, size_t len, BN_CTX *);-
301int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,-
302 const EC_POINT *b, BN_CTX *);-
303int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,-
304 BN_CTX *);-
305int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);-
306int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);-
307int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);-
308int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,-
309 BN_CTX *);-
310int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);-
311int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num,-
312 EC_POINT *[], BN_CTX *);-
313int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
314 const BIGNUM *b, BN_CTX *);-
315int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
316 BN_CTX *);-
317int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,-
318 BN_CTX *ctx);-
319int ec_GFp_simple_ladder_pre(const EC_GROUP *group,-
320 EC_POINT *r, EC_POINT *s,-
321 EC_POINT *p, BN_CTX *ctx);-
322int ec_GFp_simple_ladder_step(const EC_GROUP *group,-
323 EC_POINT *r, EC_POINT *s,-
324 EC_POINT *p, BN_CTX *ctx);-
325int ec_GFp_simple_ladder_post(const EC_GROUP *group,-
326 EC_POINT *r, EC_POINT *s,-
327 EC_POINT *p, BN_CTX *ctx);-
328-
329-
330int ec_GFp_mont_group_init(EC_GROUP *);-
331int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,-
332 const BIGNUM *b, BN_CTX *);-
333void ec_GFp_mont_group_finish(EC_GROUP *);-
334void ec_GFp_mont_group_clear_finish(EC_GROUP *);-
335int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);-
336int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
337 const BIGNUM *b, BN_CTX *);-
338int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
339 BN_CTX *);-
340int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
341 BN_CTX *);-
342int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
343 BN_CTX *);-
344int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);-
345-
346-
347int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);-
348int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,-
349 const BIGNUM *b, BN_CTX *);-
350int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
351 const BIGNUM *b, BN_CTX *);-
352int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
353 BN_CTX *);-
354-
355-
356int ec_GF2m_simple_group_init(EC_GROUP *);-
357void ec_GF2m_simple_group_finish(EC_GROUP *);-
358void ec_GF2m_simple_group_clear_finish(EC_GROUP *);-
359int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *);-
360int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,-
361 const BIGNUM *a, const BIGNUM *b,-
362 BN_CTX *);-
363int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,-
364 BIGNUM *b, BN_CTX *);-
365int ec_GF2m_simple_group_get_degree(const EC_GROUP *);-
366int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);-
367int ec_GF2m_simple_point_init(EC_POINT *);-
368void ec_GF2m_simple_point_finish(EC_POINT *);-
369void ec_GF2m_simple_point_clear_finish(EC_POINT *);-
370int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *);-
371int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);-
372int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,-
373 const BIGNUM *x,-
374 const BIGNUM *y, BN_CTX *);-
375int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *,-
376 const EC_POINT *, BIGNUM *x,-
377 BIGNUM *y, BN_CTX *);-
378int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,-
379 const BIGNUM *x, int y_bit,-
380 BN_CTX *);-
381size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *,-
382 point_conversion_form_t form,-
383 unsigned char *buf, size_t len, BN_CTX *);-
384int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *,-
385 const unsigned char *buf, size_t len, BN_CTX *);-
386int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,-
387 const EC_POINT *b, BN_CTX *);-
388int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,-
389 BN_CTX *);-
390int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);-
391int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);-
392int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);-
393int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,-
394 BN_CTX *);-
395int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);-
396int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num,-
397 EC_POINT *[], BN_CTX *);-
398int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
399 const BIGNUM *b, BN_CTX *);-
400int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
401 BN_CTX *);-
402int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,-
403 const BIGNUM *b, BN_CTX *);-
404int ec_group_simple_order_bits(const EC_GROUP *group);-
405-
406-
407-
408-
409-
410-
411const EC_METHOD *EC_GFp_nistz256_method(void);-
412-
413-
414size_t ec_key_simple_priv2oct(const EC_KEY *eckey,-
415 unsigned char *buf, size_t len);-
416int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len);-
417int ec_key_simple_generate_key(EC_KEY *eckey);-
418int ec_key_simple_generate_public_key(EC_KEY *eckey);-
419int ec_key_simple_check_key(const EC_KEY *eckey);-
420-
421-
422-
423struct ec_key_method_st {-
424 const char *name;-
425 int32_t flags;-
426 int (*init)(EC_KEY *key);-
427 void (*finish)(EC_KEY *key);-
428 int (*copy)(EC_KEY *dest, const EC_KEY *src);-
429 int (*set_group)(EC_KEY *key, const EC_GROUP *grp);-
430 int (*set_private)(EC_KEY *key, const BIGNUM *priv_key);-
431 int (*set_public)(EC_KEY *key, const EC_POINT *pub_key);-
432 int (*keygen)(EC_KEY *key);-
433 int (*compute_key)(unsigned char **pout, size_t *poutlen,-
434 const EC_POINT *pub_key, const EC_KEY *ecdh);-
435 int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char-
436 *sig, unsigned int *siglen, const BIGNUM *kinv,-
437 const BIGNUM *r, EC_KEY *eckey);-
438 int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,-
439 BIGNUM **rp);-
440 ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len,-
441 const BIGNUM *in_kinv, const BIGNUM *in_r,-
442 EC_KEY *eckey);-
443-
444 int (*verify)(int type, const unsigned char *dgst, int dgst_len,-
445 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);-
446 int (*verify_sig)(const unsigned char *dgst, int dgst_len,-
447 const ECDSA_SIG *sig, EC_KEY *eckey);-
448};-
449-
450-
451-
452int ossl_ec_key_gen(EC_KEY *eckey);-
453int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen,-
454 const EC_POINT *pub_key, const EC_KEY *ecdh);-
455int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,-
456 const EC_POINT *pub_key, const EC_KEY *ecdh);-
457-
458struct ECDSA_SIG_st {-
459 BIGNUM *r;-
460 BIGNUM *s;-
461};-
462-
463int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,-
464 BIGNUM **rp);-
465int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,-
466 unsigned char *sig, unsigned int *siglen,-
467 const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey);-
468ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,-
469 const BIGNUM *in_kinv, const BIGNUM *in_r,-
470 EC_KEY *eckey);-
471int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,-
472 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);-
473int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,-
474 const ECDSA_SIG *sig, EC_KEY *eckey);-
475-
476int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,-
477 const uint8_t public_key[32], const uint8_t private_key[32]);-
478int ED25519_verify(const uint8_t *message, size_t message_len,-
479 const uint8_t signature[64], const uint8_t public_key[32]);-
480void ED25519_public_from_private(uint8_t out_public_key[32],-
481 const uint8_t private_key[32]);-
482-
483int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],-
484 const uint8_t peer_public_value[32]);-
485void X25519_public_from_private(uint8_t out_public_value[32],-
486 const uint8_t private_key[32]);-
487int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,-
488 const BIGNUM *scalar, const EC_POINT *point,-
489 BN_CTX *ctx);-
490-
491int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);-
492-
493static inline int ec_point_ladder_pre(const EC_GROUP *group,-
494 EC_POINT *r, EC_POINT *s,-
495 EC_POINT *p, BN_CTX *ctx)-
496{-
497 if (group->meth->ladder_pre !=
group->meth->l...!= ((void *)0)Description
TRUEevaluated 4130 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4130
498 ((void *)0)
group->meth->l...!= ((void *)0)Description
TRUEevaluated 4130 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4130
499 )-
500 return
executed 4130 times by 2 tests: return group->meth->ladder_pre(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
group->meth->ladder_pre(group, r, s, p, ctx);
executed 4130 times by 2 tests: return group->meth->ladder_pre(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4130
501-
502 if (!EC_POINT_copy(s, p)
!EC_POINT_copy(s, p)Description
TRUEnever evaluated
FALSEnever evaluated
0
503 || !EC_POINT_dbl(group, r, s, ctx)
!EC_POINT_dbl(...up, r, s, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
504 return
never executed: return 0;
0;
never executed: return 0;
0
505-
506 return
never executed: return 1;
1;
never executed: return 1;
0
507}-
508-
509static inline int ec_point_ladder_step(const EC_GROUP *group,-
510 EC_POINT *r, EC_POINT *s,-
511 EC_POINT *p, BN_CTX *ctx)-
512{-
513 if (group->meth->ladder_step !=
group->meth->l...!= ((void *)0)Description
TRUEevaluated 1193659 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-1193659
514 ((void *)0)
group->meth->l...!= ((void *)0)Description
TRUEevaluated 1193659 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-1193659
515 )-
516 return
executed 1193659 times by 2 tests: return group->meth->ladder_step(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
group->meth->ladder_step(group, r, s, p, ctx);
executed 1193659 times by 2 tests: return group->meth->ladder_step(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1193659
517-
518 if (!EC_POINT_add(group, s, r, s, ctx)
!EC_POINT_add(... s, r, s, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
519 || !EC_POINT_dbl(group, r, r, ctx)
!EC_POINT_dbl(...up, r, r, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
520 return
never executed: return 0;
0;
never executed: return 0;
0
521-
522 return
never executed: return 1;
1;
never executed: return 1;
0
523-
524}-
525-
526static inline int ec_point_ladder_post(const EC_GROUP *group,-
527 EC_POINT *r, EC_POINT *s,-
528 EC_POINT *p, BN_CTX *ctx)-
529{-
530 if (group->meth->ladder_post !=
group->meth->l...!= ((void *)0)Description
TRUEevaluated 4130 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4130
531 ((void *)0)
group->meth->l...!= ((void *)0)Description
TRUEevaluated 4130 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4130
532 )-
533 return
executed 4130 times by 2 tests: return group->meth->ladder_post(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
group->meth->ladder_post(group, r, s, p, ctx);
executed 4130 times by 2 tests: return group->meth->ladder_post(group, r, s, p, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4130
534-
535 return
never executed: return 1;
1;
never executed: return 1;
0
536}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2