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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
.\" $OpenBSD: EC_GROUP_get_curve_name.3,v 1.2 2025/04/26 05:31:27 tb Exp $
.\"
.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: April 26 2025 $
.Dt EC_GROUP_GET_CURVE_NAME 3
.Os
.Sh NAME
.Nm EC_GROUP_get_curve_name ,
.Nm EC_GROUP_set_curve_name ,
.Nm EC_GROUP_get_asn1_flag ,
.Nm EC_GROUP_set_asn1_flag ,
.Nm EC_GROUP_get0_seed ,
.Nm EC_GROUP_get_seed_len ,
.Nm EC_GROUP_set_seed ,
.Nm EC_GROUP_get_point_conversion_form ,
.Nm EC_GROUP_set_point_conversion_form ,
.Nm EC_GROUP_get_basis_type
.Nd configure and inspect details of the ASN.1 encoding of
.Vt EC_GROUP
and related objects
.Sh SYNOPSIS
.In openssl/ec.h
.Ft int
.Fo EC_GROUP_get_curve_name
.Fa "const EC_GROUP *group"
.Fc
.Ft void
.Fo EC_GROUP_set_curve_name
.Fa "EC_GROUP *group"
.Fa "int nid"
.Fc
.Ft int
.Fo EC_GROUP_get_asn1_flag
.Fa "const EC_GROUP *group"
.Fc
.Ft void
.Fo EC_GROUP_set_asn1_flag
.Fa "EC_GROUP *group"
.Fa "int flag"
.Fc
.Ft "unsigned char *"
.Fo EC_GROUP_get0_seed
.Fa "const EC_GROUP *group"
.Fc
.Ft size_t
.Fo EC_GROUP_get_seed_len
.Fa "const EC_GROUP *group"
.Fc
.Ft size_t
.Fo EC_GROUP_set_seed
.Fa "EC_GROUP *group"
.Fa "const unsigned char *seed"
.Fa "size_t len"
.Fc
.Bd -literal
typedef enum {
POINT_CONVERSION_COMPRESSED = 2,
POINT_CONVERSION_UNCOMPRESSED = 4,
POINT_CONVERSION_HYBRID = 6
} point_conversion_form_t;
.Ed
.Ft point_conversion_form_t
.Fo EC_GROUP_get_point_conversion_form
.Fa "const EC_GROUP *group"
.Fc
.Ft void
.Fo EC_GROUP_set_point_conversion_form
.Fa "EC_GROUP *group"
.Fa "point_conversion_form_t form"
.Fc
.Pp
Deprecated:
.Pp
.Ft int
.Fo EC_GROUP_get_basis_type
.Fa "const EC_GROUP *group"
.Fc
.Sh DESCRIPTION
The functions in this manual affect or allow the inspection of
the details of the ASN.1 encoding produced by the
.Xr i2d_ECPKParameters 3
family of functions.
Modern applications use named curves and uncompressed point encoding,
which are the default for
.Xr EC_GROUP_new_by_curve_name 3 .
.Pp
In this library, Elliptic curve parameters are either encoded as a
.Em named curve ,
using an ASN.1 Object Identifier (OID) to refer to
standardized parameters that need to be built into the library,
or using
.Em explicit curve parameters
where the field, the curve equation, the base point's coordinates
and other data are encoded explicitly.
The
.Em implicitly CA
variant is not supported.
.Pp
.Fn EC_GROUP_get_curve_name
gets the Numerical Identifier (NID) representation of the
ASN.1 Object Identifier used for the named curve encoding of
.Fa group .
.Fn EC_GROUP_set_curve_name
sets it to
.Fa nid .
.Pp
.Fn EC_GROUP_get_asn1_flag
retrieves the value of the
.Fa asn1_flag
member of
.Fa group .
If the bit corresponding to
.Dv OPENSSL_EC_NAMED_CURVE
is set, named curve encoding is used for
.Fa group ,
otherwise explicit encoding is used.
.Fn EC_GROUP_set_asn1_flag
sets the
.Fa asn1_flag
member of group to
.Fa flag ,
which should be either
.Dv OPENSSL_EC_NAMED_CURVE
to use named curve encoding or
.Dv OPENSSL_EC_EXPLICIT_CURVE
to use explicit encoding.
.Pp
The ASN.1 encoding of explicit curve parameters includes
an optional seed value for parameters generated verifiably at random.
If a seed value is set on
.Fa group ,
.Fn EC_GROUP_get0_seed
returns a pointer to the internal byte string whose length is returned by
.Fn EC_GROUP_get_seed_len .
.Pp
.Fn EC_GROUP_set_seed
first clears any seed and length already stored in
.Fa group .
If
.Fa seed
is not
.Dv NULL
and
.Fa len
is not zero, it stores a copy of them in
.Fa group .
The
.Fa seed
should be a random byte string of
.Fa len
at least 20 bytes.
The seed can be unset by passing
.Dv NULL
as a
.Fa seed
and a
.Fa len
of zero.
The library does not perform any computation or validation with this seed,
it only includes it in its ASN.1 encoded parameters,
whether it contains a sensible value or not.
.Pp
Points on an elliptic curve, such as the generator or a public key,
can be encoded in compressed form, uncompressed form,
or in a hybrid form encompassing both, see
.Xr EC_POINT_point2oct 3 .
.Fn EC_GROUP_get_point_conversion_form
retrieves the encoding used for points on
.Fa group
and
.Fn EC_GROUP_set_point_conversion_form
sets it to
.Fa form .
.Pp
The deprecated
.Fn EC_GROUP_get_basis_type
only makes sense for curves over binary fields.
It is provided for compatibility only.
.Sh RETURN VALUES
.Fn EC_GROUP_get_curve_name
returns the NID to be used for named curve encoding of
.Fa group
or
.Dv NID_undef
if no NID is set.
.Pp
.Fn EC_GROUP_get_asn1_flag
returns the value most recently set by
.Fn EC_GROUP_set_asn1_flag
on
.Fa group .
.Pp
.Fn EC_GROUP_get0_seed
returns an internal pointer to the
.Fa seed
on
.Fa group
or
.Dv NULL
if none is set.
.Pp
.Fn EC_GROUP_get_seed_len
returns the byte length of the seed set on
.Fa group
or zero if none is set.
.Pp
.Fn EC_GROUP_set_seed
returns 0 on memory allocation failure.
It returns
.Fa len
on success unless
.Fa seed
is
.Dv NULL
or
.Fa len
is zero, in which case it returns 1.
.Pp
.Fn EC_GROUP_get_point_conversion_form
returns the point conversion form last set by
.Fn EC_GROUP_set_point_conversion_form
on
.Fa group .
.Pp
.Fn EC_GROUP_get_basis_type
always returns
.Dv NID_undef .
.Sh SEE ALSO
.Xr crypto 3 ,
.Xr d2i_ECPKParameters 3 ,
.Xr EC_GROUP_check 3 ,
.Xr EC_GROUP_new_by_curve_name 3 ,
.Xr EC_GROUP_new_curve_GFp 3 ,
.Xr EC_KEY_METHOD_new 3 ,
.Xr EC_KEY_new 3 ,
.Xr EC_POINT_add 3 ,
.Xr EC_POINT_get_affine_coordinates 3 ,
.Xr EC_POINT_new 3 ,
.Xr EC_POINT_point2oct 3 ,
.Xr ECDH_compute_key 3 ,
.Xr ECDSA_SIG_new 3 ,
.Xr OBJ_obj2nid 3
.Sh HISTORY
These functions first appeared in OpenSSL 0.9.8 and have been available since
.Ox 4.5 .
.Sh BUGS
Most of the setters cannot report errors and none of them perform proper
input validation and accept most of the values passed in.
This can result in invalid or nonsensical ASN.1 encoding produced by
.Xr i2d_ECPKParameters 3
and related functions.
|