summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/d2i_ECPKParameters.3
blob: 71d84b95c9eb55d0e4cc3b91e4fdd88af88fc491 (plain)
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
.Dd $Mdocdate: November 5 2016 $
.Dt D2I_ECPKPARAMETERS 3
.Os
.Sh NAME
.Nm d2i_ECPKParameters ,
.Nm i2d_ECPKParameters ,
.Nm d2i_ECPKParameters_bio ,
.Nm i2d_ECPKParameters_bio ,
.Nm d2i_ECPKParameters_fp ,
.Nm i2d_ECPKParameters_fp ,
.Nm ECPKParameters_print ,
.Nm ECPKParameters_print_fp
.Nd decode and encode ASN.1 representations of elliptic curve entities
.Sh SYNOPSIS
.In openssl/ec.h
.Ft EC_GROUP *
.Fo d2i_ECPKParameters
.Fa "EC_GROUP **px"
.Fa "const unsigned char **in"
.Fa "long len"
.Fc
.Ft int
.Fo i2d_ECPKParameters
.Fa "const EC_GROUP *x"
.Fa "unsigned char **out"
.Fc
.Fd #define d2i_ECPKParameters_bio(bp,x)\
 ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
.Fd #define i2d_ECPKParameters_bio(bp,x)\
 ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
.Fd #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL,\
 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
.Fd #define i2d_ECPKParameters_fp(fp,x)\
 ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x))
.Ft int
.Fo ECPKParameters_print
.Fa "BIO *bp"
.Fa "const EC_GROUP *x"
.Fa "int off"
.Fc
.Ft int
.Fo ECPKParameters_print_fp
.Fa "FILE *fp"
.Fa "const EC_GROUP *x"
.Fa "int off"
.Fc
.Sh DESCRIPTION
The ECPKParameters encode and decode routines encode and parse the
public parameters for an
.Vt EC_GROUP
structure, which represents a curve.
.Pp
.Fn d2i_ECPKParameters
attempts to decode
.Fa len
bytes at
.Pf * Fa in .
If successful, a pointer to the
.Vt EC_GROUP
structure is returned.
If an error occurred, then
.Dv NULL
is returned.
If
.Fa px
is not
.Dv NULL ,
then the returned structure is written to
.Pf * Fa px .
If
.Pf * Fa px
is not
.Dv NULL ,
then it is assumed that
.Pf * Fa px
contains a valid
.Vt EC_GROUP
structure and an attempt is made to reuse it.
If the call is successful,
.Pf * Fa in
is incremented to the byte following the parsed data.
.Pp
.Fn i2d_ECPKParameters
encodes the structure pointed to by
.Fa x
into DER format.
If
.Fa out
is not
.Dv NULL ,
is writes the DER encoded data to the buffer at
.Pf * Fa out
and increments it to point after the data just written.
If the return value is negative, an error occurred, otherwise it returns
the length of the encoded data.
.Pp
If
.Pf * Fa out
is
.Dv NULL ,
memory will be allocated for a buffer and the encoded data written to it.
In this case
.Pf * Fa out
is not incremented, and it points to the start of the data just written.
.Pp
.Fn d2i_ECPKParameters_bio
is similar to
.Fn d2i_ECPKParameters
except it attempts to parse data from
.Vt BIO
.Fa bp .
.Pp
.Fn d2i_ECPKParameters_fp
is similar to
.Fn d2i_ECPKParameters
except it attempts to parse data from the
.Vt FILE
pointer
.Fa fp .
.Pp
.Fn i2d_ECPKParameters_bio
is similar to
.Fn i2d_ECPKParameters
except it writes the encoding of the structure
.Fa x
to
.Vt BIO
.Fa bp
and it returns 1 for success or 0 for failure.
.Pp
.Fn i2d_ECPKParameters_fp
is similar to
.Fn i2d_ECPKParameters
except it writes the encoding of the structure
.Fa x
to
.Vt BIO
.Sy bp
and it returns 1 for success or 0 for failure.
.Pp
These functions are very similar to the X.509 functions described in
.Xr d2i_X509 3 ,
where further notes and examples are available.
.Pp
The
.Fn ECPKParameters_print
and
.Fn ECPKParameters_print_fp
functions print human-readable output of the public parameters of the
.Vt EC_GROUP
to
.Fa bp
or
.Fa fp .
The output lines are indented by
.Fa off
spaces.
.Sh RETURN VALUES
.Fn d2i_ECPKParameters ,
.Fn d2i_ECPKParameters_bio ,
and
.Fn d2i_ECPKParameters_fp
return a valid
.Vt EC_GROUP
structure or
.Dv NULL
if an error occurs.
.Pp
.Fn i2d_ECPKParameters
returns the number of bytes successfully encoded or a negative value if
an error occurs.
.Pp
.Fn i2d_ECPKParameters_bio ,
.Fn i2d_ECPKParameters_fp ,
.Fn ECPKParameters_print ,
and
.Fn ECPKParameters_print_fp
return 1 for success or 0 if an error occurs.
.Sh SEE ALSO
.Xr crypto 3 ,
.Xr d2i_X509 3 ,
.Xr ec 3 ,
.Xr EC_GFp_simple_method 3 ,
.Xr EC_GROUP_copy 3 ,
.Xr EC_GROUP_new 3 ,
.Xr EC_KEY_new 3 ,
.Xr EC_POINT_add 3 ,
.Xr EC_POINT_new 3