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