This repository was archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathec_params.h
91 lines (78 loc) · 2.24 KB
/
ec_params.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Copyright (C) 2017 - This file is part of libecc project
*
* Authors:
* Ryad BENADJILA <[email protected]>
* Arnaud EBALARD <[email protected]>
* Jean-Pierre FLORI <[email protected]>
*
* Contributors:
* Nicolas VIVET <[email protected]>
* Karim KHALFALLAH <[email protected]>
*
* This software is licensed under a dual BSD and GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __EC_PARAMS_H__
#define __EC_PARAMS_H__
#include "../fp/fp.h"
#include "prj_pt.h"
#include "known/ec_params_external.h"
/* Info: this include is here because an update on
* MAX_CURVE_OID_LEN and MAX_CURVE_NAME_LEN can be done
* through preprocessing of the curves at compile time.
*/
#include "curves_list.h"
/* These default sizes should be enough for the known curves */
#ifdef MAX_CURVE_NAME_LEN
#if (MAX_CURVE_OID_LEN < 32)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 32 /* including trailing 0 */
#endif
#else
#define MAX_CURVE_OID_LEN 32 /* including trailing 0 */
#endif
#ifdef MAX_CURVE_NAME_LEN
#if (MAX_CURVE_NAME_LEN < 32)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 32 /* including trailing 0 */
#endif
#else
#define MAX_CURVE_NAME_LEN 32
#endif
/*
* Elliptic curves parameters. We only support
* curves defined on prime fields (i.e. Fp,
* with p prime).
*/
typedef struct {
/* Fp */
fp_ctx ec_fp;
/* Curve */
ec_shortw_crv ec_curve;
/*
* Generator G defining our group, in projective
* coordinates.
*/
prj_pt ec_gen;
/* Number of points on group generated by G */
nn ec_gen_order;
bitcnt_t ec_gen_order_bitlen;
/* Curve cofactor */
nn ec_gen_cofactor;
#if !defined(USE_SMALL_STACK)
/* Optional transfer coefficients with Montgomery curves */
fp ec_alpha_montgomery;
fp ec_gamma_montgomery;
/* Optional transfer coefficient with Edwards curves */
fp ec_alpha_edwards;
#endif
/* Object Identifier for the curve */
u8 curve_oid[MAX_CURVE_OID_LEN];
/* Short name for the curve */
u8 curve_name[MAX_CURVE_NAME_LEN];
/* Type of the curve */
ec_curve_type curve_type;
} ec_params;
ATTRIBUTE_WARN_UNUSED_RET int import_params(ec_params *out_params, const ec_str_params *in_str_params);
#endif /* __EC_PARAMS_H__ */