1EC_GROUP_copy(3)                    OpenSSL                   EC_GROUP_copy(3)
2
3
4

NAME

6       EC_GROUP_copy, EC_GROUP_dup, EC_GROUP_method_of,
7       EC_GROUP_set_generator, EC_GROUP_get0_generator, EC_GROUP_get_order,
8       EC_GROUP_get_cofactor, EC_GROUP_set_curve_name,
9       EC_GROUP_get_curve_name, EC_GROUP_set_asn1_flag,
10       EC_GROUP_get_asn1_flag, EC_GROUP_set_point_conversion_form,
11       EC_GROUP_get_point_conversion_form, EC_GROUP_get0_seed,
12       EC_GROUP_get_seed_len, EC_GROUP_set_seed, EC_GROUP_get_degree,
13       EC_GROUP_check, EC_GROUP_check_discriminant, EC_GROUP_cmp,
14       EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis,
15       EC_GROUP_get_pentanomial_basis - Functions for manipulating EC_GROUP
16       objects.
17

SYNOPSIS

19        #include <openssl/ec.h>
20        #include <openssl/bn.h>
21
22        int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
23        EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
24
25        const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
26
27        int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
28        const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
29
30        int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
31        int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
32
33        void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
34        int EC_GROUP_get_curve_name(const EC_GROUP *group);
35
36        void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
37        int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
38
39        void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
40        point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
41
42        unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
43        size_t EC_GROUP_get_seed_len(const EC_GROUP *);
44        size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
45
46        int EC_GROUP_get_degree(const EC_GROUP *group);
47
48        int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
49
50        int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
51
52        int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
53
54        int EC_GROUP_get_basis_type(const EC_GROUP *);
55        int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
56        int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
57               unsigned int *k2, unsigned int *k3);
58

DESCRIPTION

60       EC_GROUP_copy copies the curve src into dst. Both src and dst must use
61       the same EC_METHOD.
62
63       EC_GROUP_dup creates a new EC_GROUP object and copies the content from
64       src to the newly created EC_GROUP object.
65
66       EC_GROUP_method_of obtains the EC_METHOD of group.
67
68       EC_GROUP_set_generator sets curve paramaters that must be agreed by all
69       participants using the curve. These paramaters include the generator,
70       the order and the cofactor. The generator is a well defined point on
71       the curve chosen for cryptographic operations. Integers used for point
72       multiplications will be between 0 and n-1 where n is the order. The
73       order multipied by the cofactor gives the number of points on the
74       curve.
75
76       EC_GROUP_get0_generator returns the generator for the identified group.
77
78       The functions EC_GROUP_get_order and EC_GROUP_get_cofactor populate the
79       provided order and cofactor parameters with the respective order and
80       cofactors for the group.
81
82       The functions EC_GROUP_set_curve_name and EC_GROUP_get_curve_name, set
83       and get the NID for the curve respectively (see EC_GROUP_new(3)). If a
84       curve does not have a NID associated with it, then
85       EC_GROUP_get_curve_name will return 0.
86
87       The asn1_flag value on a curve is used to determine whether there is a
88       specific ASN1 OID to describe the curve or not.  If the asn1_flag is 1
89       then this is a named curve with an associated ASN1 OID. If not then
90       asn1_flag is 0. The functions EC_GROUP_get_asn1_flag and
91       EC_GROUP_set_asn1_flag get and set the status of the asn1_flag for the
92       curve. If set then the curve_name must also be set.
93
94       The point_coversion_form for a curve controls how EC_POINT data is
95       encoded as ASN1 as defined in X9.62 (ECDSA).  point_conversion_form_t
96       is an enum defined as follows:
97
98        typedef enum {
99               /** the point is encoded as z||x, where the octet z specifies
100                *   which solution of the quadratic equation y is  */
101               POINT_CONVERSION_COMPRESSED = 2,
102               /** the point is encoded as z||x||y, where z is the octet 0x02  */
103               POINT_CONVERSION_UNCOMPRESSED = 4,
104               /** the point is encoded as z||x||y, where the octet z specifies
105                *  which solution of the quadratic equation y is  */
106               POINT_CONVERSION_HYBRID = 6
107        } point_conversion_form_t;
108
109       For POINT_CONVERSION_UNCOMPRESSED the point is encoded as an octet
110       signifying the UNCOMPRESSED form has been used followed by the octets
111       for x, followed by the octets for y.
112
113       For any given x co-ordinate for a point on a curve it is possible to
114       derive two possible y values. For POINT_CONVERSION_COMPRESSED the point
115       is encoded as an octet signifying that the COMPRESSED form has been
116       used AND which of the two possible solutions for y has been used,
117       followed by the octets for x.
118
119       For POINT_CONVERSION_HYBRID the point is encoded as an octet signifying
120       the HYBRID form has been used AND which of the two possible solutions
121       for y has been used, followed by the octets for x, followed by the
122       octets for y.
123
124       The functions EC_GROUP_set_point_conversion_form and
125       EC_GROUP_get_point_conversion_form set and get the
126       point_conversion_form for the curve respectively.
127
128       ANSI X9.62 (ECDSA standard) defines a method of generating the curve
129       parameter b from a random number. This provides advantages in that a
130       parameter obtained in this way is highly unlikely to be susceptible to
131       special purpose attacks, or have any trapdoors in it.  If the seed is
132       present for a curve then the b parameter was generated in a verifiable
133       fashion using that seed. The OpenSSL EC library does not use this seed
134       value but does enable you to inspect it using EC_GROUP_get0_seed. This
135       returns a pointer to a memory block containing the seed that was used.
136       The length of the memory block can be obtained using
137       EC_GROUP_get_seed_len. A number of the builtin curves within the
138       library provide seed values that can be obtained. It is also possible
139       to set a custom seed using EC_GROUP_set_seed and passing a pointer to a
140       memory block, along with the length of the seed. Again, the EC library
141       will not use this seed value, although it will be preserved in any ASN1
142       based communications.
143
144       EC_GROUP_get_degree gets the degree of the field. For Fp fields this
145       will be the number of bits in p.  For F2^m fields this will be the
146       value m.
147
148       The function EC_GROUP_check_discriminant calculates the discriminant
149       for the curve and verifies that it is valid.  For a curve defined over
150       Fp the discriminant is given by the formula 4*a^3 + 27*b^2 whilst for
151       F2^m curves the discriminant is simply b. In either case for the curve
152       to be valid the discriminant must be non zero.
153
154       The function EC_GROUP_check performs a number of checks on a curve to
155       verify that it is valid. Checks performed include verifying that the
156       discriminant is non zero; that a generator has been defined; that the
157       generator is on the curve and has the correct order.
158
159       EC_GROUP_cmp compares a and b to determine whether they represent the
160       same curve or not.
161
162       The functions EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis and
163       EC_GROUP_get_pentanomial_basis should only be called for curves defined
164       over an F2^m field. Addition and multiplication operations within an
165       F2^m field are performed using an irreducible polynomial function f(x).
166       This function is either a trinomial of the form:
167
168       f(x) = x^m + x^k + 1 with m > k >= 1
169
170       or a pentanomial of the form:
171
172       f(x) = x^m + x^k3 + x^k2 + x^k1 + 1 with m > k3 > k2 > k1 >= 1
173
174       The function EC_GROUP_get_basis_type returns a NID identifying whether
175       a trinomial or pentanomial is in use for the field. The function
176       EC_GROUP_get_trinomial_basis must only be called where f(x) is of the
177       trinomial form, and returns the value of k. Similary the function
178       EC_GROUP_get_pentanomial_basis must only be called where f(x) is of the
179       pentanomial form, and returns the values of k1, k2 and k3 respectively.
180

RETURN VALUES

182       The following functions return 1 on success or 0 on error:
183       EC_GROUP_copy, EC_GROUP_set_generator, EC_GROUP_check,
184       EC_GROUP_check_discriminant, EC_GROUP_get_trinomial_basis and
185       EC_GROUP_get_pentanomial_basis.
186
187       EC_GROUP_dup returns a pointer to the duplicated curve, or NULL on
188       error.
189
190       EC_GROUP_method_of returns the EC_METHOD implementation in use for the
191       given curve or NULL on error.
192
193       EC_GROUP_get0_generator returns the generator for the given curve or
194       NULL on error.
195
196       EC_GROUP_get_order, EC_GROUP_get_cofactor, EC_GROUP_get_curve_name,
197       EC_GROUP_get_asn1_flag, EC_GROUP_get_point_conversion_form and
198       EC_GROUP_get_degree return the order, cofactor, curve name (NID), ASN1
199       flag, point_conversion_form and degree for the specified curve
200       respectively. If there is no curve name associated with a curve then
201       EC_GROUP_get_curve_name will return 0.
202
203       EC_GROUP_get0_seed returns a pointer to the seed that was used to
204       generate the parameter b, or NULL if the seed is not specified.
205       EC_GROUP_get_seed_len returns the length of the seed or 0 if the seed
206       is not specified.
207
208       EC_GROUP_set_seed returns the length of the seed that has been set. If
209       the supplied seed is NULL, or the supplied seed length is 0, the return
210       value will be 1. On error 0 is returned.
211
212       EC_GROUP_cmp returns 0 if the curves are equal, 1 if they are not
213       equal, or -1 on error.
214
215       EC_GROUP_get_basis_type returns the values NID_X9_62_tpBasis or
216       NID_X9_62_ppBasis (as defined in <openssl/obj_mac.h>) for a trinomial
217       or pentanomial respectively. Alternatively in the event of an error a 0
218       is returned.
219

SEE ALSO

221       crypto(3), ec(3), EC_GROUP_new(3), EC_POINT_new(3), EC_POINT_add(3),
222       EC_KEY_new(3), EC_GFp_simple_method(3), d2i_ECPKParameters(3)
223
224
225
2261.0.2o                            2020-08-01                  EC_GROUP_copy(3)
Impressum