1EC_GROUP_COPY(3) OpenSSL EC_GROUP_COPY(3)
2
3
4
6 EC_GROUP_get0_order, EC_GROUP_order_bits, EC_GROUP_get0_cofactor,
7 EC_GROUP_copy, EC_GROUP_dup, EC_GROUP_method_of,
8 EC_GROUP_set_generator, EC_GROUP_get0_generator, EC_GROUP_get_order,
9 EC_GROUP_get_cofactor, EC_GROUP_set_curve_name,
10 EC_GROUP_get_curve_name, EC_GROUP_set_asn1_flag,
11 EC_GROUP_get_asn1_flag, EC_GROUP_set_point_conversion_form,
12 EC_GROUP_get_point_conversion_form, EC_GROUP_get0_seed,
13 EC_GROUP_get_seed_len, EC_GROUP_set_seed, EC_GROUP_get_degree,
14 EC_GROUP_check, EC_GROUP_check_discriminant, EC_GROUP_cmp,
15 EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis,
16 EC_GROUP_get_pentanomial_basis - Functions for manipulating EC_GROUP
17 objects
18
20 #include <openssl/ec.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,
28 const BIGNUM *order, const BIGNUM *cofactor);
29 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
30
31 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
32 const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);
33 int EC_GROUP_order_bits(const EC_GROUP *group);
34 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
35 const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);
36
37 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
38 int EC_GROUP_get_curve_name(const EC_GROUP *group);
39
40 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
41 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
42
43 void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
44 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
45
46 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
47 size_t EC_GROUP_get_seed_len(const EC_GROUP *);
48 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
49
50 int EC_GROUP_get_degree(const EC_GROUP *group);
51
52 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
53
54 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
55
56 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
57
58 int EC_GROUP_get_basis_type(const EC_GROUP *);
59 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
60 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
61 unsigned int *k2, unsigned int *k3);
62
64 EC_GROUP_copy copies the curve src into dst. Both src and dst must use
65 the same EC_METHOD.
66
67 EC_GROUP_dup creates a new EC_GROUP object and copies the content from
68 src to the newly created EC_GROUP object.
69
70 EC_GROUP_method_of obtains the EC_METHOD of group.
71
72 EC_GROUP_set_generator sets curve parameters that must be agreed by all
73 participants using the curve. These parameters include the generator,
74 the order and the cofactor. The generator is a well defined point on
75 the curve chosen for cryptographic operations. Integers used for point
76 multiplications will be between 0 and n-1 where n is the order. The
77 order multiplied by the cofactor gives the number of points on the
78 curve.
79
80 EC_GROUP_get0_generator returns the generator for the identified group.
81
82 The functions EC_GROUP_get_order and EC_GROUP_get_cofactor populate the
83 provided order and cofactor parameters with the respective order and
84 cofactors for the group.
85
86 The functions EC_GROUP_set_curve_name and EC_GROUP_get_curve_name, set
87 and get the NID for the curve respectively (see EC_GROUP_new(3)). If a
88 curve does not have a NID associated with it, then
89 EC_GROUP_get_curve_name will return 0.
90
91 The asn1_flag value is used to determine whether the curve encoding
92 uses explicit parameters or a named curve using an ASN1 OID: many
93 applications only support the latter form. If asn1_flag is
94 OPENSSL_EC_NAMED_CURVE then the named curve form is used and the
95 parameters must have a corresponding named curve NID set. If asn1_flags
96 is OPENSSL_EC_EXPLICIT_CURVE the parameters are explicitly encoded. The
97 functions EC_GROUP_get_asn1_flag and EC_GROUP_set_asn1_flag get and set
98 the status of the asn1_flag for the curve. Note:
99 OPENSSL_EC_EXPLICIT_CURVE was first added to OpenSSL 1.1.0, for
100 previous versions of OpenSSL the value 0 must be used instead. Before
101 OpenSSL 1.1.0 the default form was to use explicit parameters (meaning
102 that applications would have to explicitly set the named curve form) in
103 OpenSSL 1.1.0 and later the named curve form is the default.
104
105 The point_conversion_form for a curve controls how EC_POINT data is
106 encoded as ASN1 as defined in X9.62 (ECDSA). point_conversion_form_t
107 is an enum defined as follows:
108
109 typedef enum {
110 /** the point is encoded as z||x, where the octet z specifies
111 * which solution of the quadratic equation y is */
112 POINT_CONVERSION_COMPRESSED = 2,
113 /** the point is encoded as z||x||y, where z is the octet 0x04 */
114 POINT_CONVERSION_UNCOMPRESSED = 4,
115 /** the point is encoded as z||x||y, where the octet z specifies
116 * which solution of the quadratic equation y is */
117 POINT_CONVERSION_HYBRID = 6
118 } point_conversion_form_t;
119
120 For POINT_CONVERSION_UNCOMPRESSED the point is encoded as an octet
121 signifying the UNCOMPRESSED form has been used followed by the octets
122 for x, followed by the octets for y.
123
124 For any given x co-ordinate for a point on a curve it is possible to
125 derive two possible y values. For POINT_CONVERSION_COMPRESSED the point
126 is encoded as an octet signifying that the COMPRESSED form has been
127 used AND which of the two possible solutions for y has been used,
128 followed by the octets for x.
129
130 For POINT_CONVERSION_HYBRID the point is encoded as an octet signifying
131 the HYBRID form has been used AND which of the two possible solutions
132 for y has been used, followed by the octets for x, followed by the
133 octets for y.
134
135 The functions EC_GROUP_set_point_conversion_form and
136 EC_GROUP_get_point_conversion_form set and get the
137 point_conversion_form for the curve respectively.
138
139 ANSI X9.62 (ECDSA standard) defines a method of generating the curve
140 parameter b from a random number. This provides advantages in that a
141 parameter obtained in this way is highly unlikely to be susceptible to
142 special purpose attacks, or have any trapdoors in it. If the seed is
143 present for a curve then the b parameter was generated in a verifiable
144 fashion using that seed. The OpenSSL EC library does not use this seed
145 value but does enable you to inspect it using EC_GROUP_get0_seed. This
146 returns a pointer to a memory block containing the seed that was used.
147 The length of the memory block can be obtained using
148 EC_GROUP_get_seed_len. A number of the builtin curves within the
149 library provide seed values that can be obtained. It is also possible
150 to set a custom seed using EC_GROUP_set_seed and passing a pointer to a
151 memory block, along with the length of the seed. Again, the EC library
152 will not use this seed value, although it will be preserved in any ASN1
153 based communications.
154
155 EC_GROUP_get_degree gets the degree of the field. For Fp fields this
156 will be the number of bits in p. For F2^m fields this will be the
157 value m.
158
159 The function EC_GROUP_check_discriminant calculates the discriminant
160 for the curve and verifies that it is valid. For a curve defined over
161 Fp the discriminant is given by the formula 4*a^3 + 27*b^2 whilst for
162 F2^m curves the discriminant is simply b. In either case for the curve
163 to be valid the discriminant must be non zero.
164
165 The function EC_GROUP_check performs a number of checks on a curve to
166 verify that it is valid. Checks performed include verifying that the
167 discriminant is non zero; that a generator has been defined; that the
168 generator is on the curve and has the correct order.
169
170 EC_GROUP_cmp compares a and b to determine whether they represent the
171 same curve or not.
172
173 The functions EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis and
174 EC_GROUP_get_pentanomial_basis should only be called for curves defined
175 over an F2^m field. Addition and multiplication operations within an
176 F2^m field are performed using an irreducible polynomial function f(x).
177 This function is either a trinomial of the form:
178
179 f(x) = x^m + x^k + 1 with m > k >= 1
180
181 or a pentanomial of the form:
182
183 f(x) = x^m + x^k3 + x^k2 + x^k1 + 1 with m > k3 > k2 > k1 >= 1
184
185 The function EC_GROUP_get_basis_type returns a NID identifying whether
186 a trinomial or pentanomial is in use for the field. The function
187 EC_GROUP_get_trinomial_basis must only be called where f(x) is of the
188 trinomial form, and returns the value of k. Similarly the function
189 EC_GROUP_get_pentanomial_basis must only be called where f(x) is of the
190 pentanomial form, and returns the values of k1, k2 and k3 respectively.
191
193 The following functions return 1 on success or 0 on error:
194 EC_GROUP_copy, EC_GROUP_set_generator, EC_GROUP_check,
195 EC_GROUP_check_discriminant, EC_GROUP_get_trinomial_basis and
196 EC_GROUP_get_pentanomial_basis.
197
198 EC_GROUP_dup returns a pointer to the duplicated curve, or NULL on
199 error.
200
201 EC_GROUP_method_of returns the EC_METHOD implementation in use for the
202 given curve or NULL on error.
203
204 EC_GROUP_get0_generator returns the generator for the given curve or
205 NULL on error.
206
207 EC_GROUP_get_order, EC_GROUP_get_cofactor, EC_GROUP_get_curve_name,
208 EC_GROUP_get_asn1_flag, EC_GROUP_get_point_conversion_form and
209 EC_GROUP_get_degree return the order, cofactor, curve name (NID), ASN1
210 flag, point_conversion_form and degree for the specified curve
211 respectively. If there is no curve name associated with a curve then
212 EC_GROUP_get_curve_name will return 0.
213
214 EC_GROUP_get0_order() returns an internal pointer to the group order.
215 EC_GROUP_get_order_bits() returns the number of bits in the group
216 order. EC_GROUP_get0_cofactor() returns an internal pointer to the
217 group cofactor.
218
219 EC_GROUP_get0_seed returns a pointer to the seed that was used to
220 generate the parameter b, or NULL if the seed is not specified.
221 EC_GROUP_get_seed_len returns the length of the seed or 0 if the seed
222 is not specified.
223
224 EC_GROUP_set_seed returns the length of the seed that has been set. If
225 the supplied seed is NULL, or the supplied seed length is 0, the return
226 value will be 1. On error 0 is returned.
227
228 EC_GROUP_cmp returns 0 if the curves are equal, 1 if they are not
229 equal, or -1 on error.
230
231 EC_GROUP_get_basis_type returns the values NID_X9_62_tpBasis or
232 NID_X9_62_ppBasis (as defined in <openssl/obj_mac.h>) for a trinomial
233 or pentanomial respectively. Alternatively in the event of an error a 0
234 is returned.
235
237 crypto(7), EC_GROUP_new(3), EC_POINT_new(3), EC_POINT_add(3),
238 EC_KEY_new(3), EC_GFp_simple_method(3), d2i_ECPKParameters(3)
239
241 Copyright 2013-2017 The OpenSSL Project Authors. All Rights Reserved.
242
243 Licensed under the OpenSSL license (the "License"). You may not use
244 this file except in compliance with the License. You can obtain a copy
245 in the file LICENSE in the source distribution or at
246 <https://www.openssl.org/source/license.html>.
247
248
249
2501.1.1 2018-09-11 EC_GROUP_COPY(3)