Debian Codegraph @

upstream/debian-unstable/man3/OSSL_ENCODER_CTX.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "OSSL_ENCODER_CTX 3SSL"
58 .TH OSSL_ENCODER_CTX 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 OSSL_ENCODER_CTX,
65 OSSL_ENCODER_CTX_new,
66 OSSL_ENCODER_settable_ctx_params,
67 OSSL_ENCODER_CTX_set_params,
68 OSSL_ENCODER_CTX_free,
69 OSSL_ENCODER_CTX_set_selection,
70 OSSL_ENCODER_CTX_set_output_type,
71 OSSL_ENCODER_CTX_set_output_structure,
72 OSSL_ENCODER_CTX_add_encoder,
73 OSSL_ENCODER_CTX_add_extra,
74 OSSL_ENCODER_CTX_get_num_encoders,
75 OSSL_ENCODER_INSTANCE,
76 OSSL_ENCODER_INSTANCE_get_encoder,
77 OSSL_ENCODER_INSTANCE_get_encoder_ctx,
78 OSSL_ENCODER_INSTANCE_get_output_type,
79 OSSL_ENCODER_INSTANCE_get_output_structure,
80 OSSL_ENCODER_CONSTRUCT,
81 OSSL_ENCODER_CLEANUP,
82 OSSL_ENCODER_CTX_set_construct,
83 OSSL_ENCODER_CTX_set_construct_data,
84 OSSL_ENCODER_CTX_set_cleanup
85 \&\- Encoder context routines
86 .SH SYNOPSIS
87 .IX Header "SYNOPSIS"
88 .Vb 1
89 \& #include <openssl/encoder.h>
90 \&
91 \& typedef struct ossl_encoder_ctx_st OSSL_ENCODER_CTX;
92 \&
93 \& OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new();
94 \& const OSSL_PARAM *OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER *encoder);
95 \& int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx,
96 \& const OSSL_PARAM params[]);
97 \& void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx);
98 \&
99 \& int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection);
100 \& int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx,
101 \& const char *output_type);
102 \& int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx,
103 \& const char *output_structure);
104 \&
105 \& int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder);
106 \& int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx,
107 \& OSSL_LIB_CTX *libctx, const char *propq);
108 \& int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx);
109 \&
110 \& typedef struct ossl_encoder_instance_st OSSL_ENCODER_INSTANCE;
111 \& OSSL_ENCODER *
112 \& OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst);
113 \& void *
114 \& OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst);
115 \& const char *
116 \& OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst);
117 \& const char *
118 \& OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst);
119 \&
120 \& typedef const void *OSSL_ENCODER_CONSTRUCT(OSSL_ENCODER_INSTANCE *encoder_inst,
121 \& void *construct_data);
122 \& typedef void OSSL_ENCODER_CLEANUP(void *construct_data);
123 \&
124 \& int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx,
125 \& OSSL_ENCODER_CONSTRUCT *construct);
126 \& int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx,
127 \& void *construct_data);
128 \& int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx,
129 \& OSSL_ENCODER_CLEANUP *cleanup);
130 .Ve
131 .SH DESCRIPTION
132 .IX Header "DESCRIPTION"
133 Encoding an input object to the desired encoding may be done with a chain of
134 encoder implementations, which means that the output from one encoder may be
135 the input for the next in the chain. The \fBOSSL_ENCODER_CTX\fR holds all the
136 data about these encoders. This allows having generic format encoders such
137 as DER to PEM, as well as more specialized encoders like RSA to DER.
138 .PP
139 The final output type must be given, and a chain of encoders must end with
140 an implementation that produces that output type.
141 .PP
142 At the beginning of the encoding process, a constructor provided by the
143 caller is called to ensure that there is an appropriate provider-side object
144 to start with.
145 The constructor is set with \fBOSSL_ENCODER_CTX_set_construct()\fR.
146 .PP
147 \&\fBOSSL_ENCODER_INSTANCE\fR is an opaque structure that contains data about the
148 encoder that is going to be used, and that may be useful for the
149 constructor. There are some functions to extract data from this type,
150 described in "Constructor" below.
151 .SS Functions
152 .IX Subsection "Functions"
153 \&\fBOSSL_ENCODER_CTX_new()\fR creates a \fBOSSL_ENCODER_CTX\fR.
154 .PP
155 \&\fBOSSL_ENCODER_settable_ctx_params()\fR returns an \fBOSSL_PARAM\fR\|(3)
156 array of parameter descriptors.
157 .PP
158 \&\fBOSSL_ENCODER_CTX_set_params()\fR attempts to set parameters specified
159 with an \fBOSSL_PARAM\fR\|(3) array \fIparams\fR. Parameters that the
160 implementation doesn't recognise should be ignored.
161 .PP
162 \&\fBOSSL_ENCODER_CTX_free()\fR frees the given context \fIctx\fR.
163 If the argument is NULL, nothing is done.
164 .PP
165 \&\fBOSSL_ENCODER_CTX_add_encoder()\fR populates the \fBOSSL_ENCODER_CTX\fR
166 \&\fIctx\fR with a encoder, to be used to encode an input object.
167 .PP
168 \&\fBOSSL_ENCODER_CTX_add_extra()\fR finds encoders that further encodes output
169 from already added encoders, and adds them as well. This is used to build
170 encoder chains.
171 .PP
172 \&\fBOSSL_ENCODER_CTX_set_output_type()\fR sets the ending output type. This must
173 be specified, and determines if a complete encoder chain is available.
174 .PP
175 \&\fBOSSL_ENCODER_CTX_set_output_structure()\fR sets the desired output structure.
176 This may be used to determines what encoder implementations may be used.
177 Depending on the type of object being encoded, the output structure may
178 not be relevant.
179 .PP
180 \&\fBOSSL_ENCODER_CTX_get_num_encoders()\fR gets the number of encoders currently
181 added to the context \fIctx\fR.
182 .PP
183 \&\fBOSSL_ENCODER_CTX_set_construct()\fR sets the constructor \fIconstruct\fR.
184 .PP
185 \&\fBOSSL_ENCODER_CTX_set_construct_data()\fR sets the constructor data that is
186 passed to the constructor every time it's called.
187 .PP
188 \&\fBOSSL_ENCODER_CTX_set_cleanup()\fR sets the constructor data \fIcleanup\fR
189 function. This is called by \fBOSSL_ENCODER_CTX_free\fR\|(3).
190 .PP
191 Note that functions \fBOSSL_ENCODER_CTX_set_selection()\fR,
192 \&\fBOSSL_ENCODER_CTX_set_output_type()\fR, \fBOSSL_ENCODER_CTX_set_output_structure()\fR,
193 \&\fBOSSL_ENCODER_CTX_add_encoder()\fR, \fBOSSL_ENCODER_CTX_add_extra()\fR,
194 \&\fBOSSL_ENCODER_CTX_set_construct()\fR, \fBOSSL_ENCODER_CTX_set_construct_data()\fR, and
195 \&\fBOSSL_ENCODER_CTX_set_cleanup()\fR shouldn't be used after the context is finalised,
196 in particular after calling the function \fBOSSL_ENCODER_CTX_new_for_pkey()\fR.
197 .SS Constructor
198 .IX Subsection "Constructor"
199 A \fBOSSL_ENCODER_CONSTRUCT\fR gets the following arguments:
200 .IP \fIencoder_inst\fR 4
201 .IX Item "encoder_inst"
202 The \fBOSSL_ENCODER_INSTANCE\fR for the encoder from which the constructor gets
203 its data.
204 .IP \fIconstruct_data\fR 4
205 .IX Item "construct_data"
206 The pointer that was set with \fBOSSL_ENCODE_CTX_set_construct_data()\fR.
207 .PP
208 The constructor is expected to return a valid (non-NULL) pointer to a
209 provider-native object that can be used as first input of an encoding chain,
210 or NULL to indicate that an error has occurred.
211 .PP
212 These utility functions may be used by a constructor:
213 .PP
214 \&\fBOSSL_ENCODER_INSTANCE_get_encoder()\fR can be used to get the encoder
215 implementation of the encoder instance \fIencoder_inst\fR.
216 .PP
217 \&\fBOSSL_ENCODER_INSTANCE_get_encoder_ctx()\fR can be used to get the encoder
218 implementation's provider context of the encoder instance \fIencoder_inst\fR.
219 .PP
220 \&\fBOSSL_ENCODER_INSTANCE_get_output_type()\fR can be used to get the output type
221 for the encoder implementation of the encoder instance \fIencoder_inst\fR.
222 This will never be NULL.
223 .PP
224 \&\fBOSSL_ENCODER_INSTANCE_get_output_structure()\fR can be used to get the output
225 structure for the encoder implementation of the encoder instance
226 \&\fIencoder_inst\fR.
227 This may be NULL.
228 .SH "RETURN VALUES"
229 .IX Header "RETURN VALUES"
230 \&\fBOSSL_ENCODER_CTX_new()\fR returns a pointer to a \fBOSSL_ENCODER_CTX\fR, or NULL
231 if the context structure couldn't be allocated.
232 .PP
233 \&\fBOSSL_ENCODER_settable_ctx_params()\fR returns an \fBOSSL_PARAM\fR\|(3) array, or
234 NULL if none is available.
235 .PP
236 \&\fBOSSL_ENCODER_CTX_set_params()\fR returns 1 if all recognised parameters were
237 valid, or 0 if one of them was invalid or caused some other failure in the
238 implementation.
239 .PP
240 \&\fBOSSL_ENCODER_CTX_add_encoder()\fR, \fBOSSL_ENCODER_CTX_add_extra()\fR,
241 \&\fBOSSL_ENCODER_CTX_set_construct()\fR, \fBOSSL_ENCODER_CTX_set_construct_data()\fR and
242 \&\fBOSSL_ENCODER_CTX_set_cleanup()\fR return 1 on success, or 0 on failure.
243 .PP
244 \&\fBOSSL_ENCODER_CTX_get_num_encoders()\fR returns the current number of encoders.
245 It returns 0 if \fIctx\fR is NULL.
246 .PP
247 \&\fBOSSL_ENCODER_INSTANCE_get_encoder()\fR returns an \fBOSSL_ENCODER\fR pointer on
248 success, or NULL on failure.
249 .PP
250 \&\fBOSSL_ENCODER_INSTANCE_get_encoder_ctx()\fR returns a provider context pointer on
251 success, or NULL on failure.
252 .PP
253 \&\fBOSSL_ENCODER_INSTANCE_get_output_type()\fR returns a string with the name of the
254 input type, if relevant. NULL is a valid returned value.
255 .PP
256 \&\fBOSSL_ENCODER_INSTANCE_get_output_type()\fR returns a string with the name of the
257 output type.
258 .PP
259 \&\fBOSSL_ENCODER_INSTANCE_get_output_structure()\fR returns a string with the name
260 of the output structure.
261 .SH "NOTES AND BUGS"
262 .IX Header "NOTES AND BUGS"
263 The chain mechanism in ENCODE is not yet completely implemented.
264 It affects functions such as OSSL_ENCODER_CTX_add_extra and the
265 inner processing loop.
266 .SH "SEE ALSO"
267 .IX Header "SEE ALSO"
268 \&\fBprovider\fR\|(7), \fBOSSL_ENCODER\fR\|(3)
269 .SH HISTORY
270 .IX Header "HISTORY"
271 The functions described here were added in OpenSSL 3.0.
272 .SH COPYRIGHT
273 .IX Header "COPYRIGHT"
274 Copyright 2019\-2024 The OpenSSL Project Authors. All Rights Reserved.
275 .PP
276 Licensed under the Apache License 2.0 (the "License"). You may not use
277 this file except in compliance with the License. You can obtain a copy
278 in the file LICENSE in the source distribution or at
279 <https://www.openssl.org/source/license.html>.