xref: /freebsd/crypto/openssl/doc/man3/OSSL_ENCODER.pod (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery
3b077aed3SPierre Pronchery=head1 NAME
4b077aed3SPierre Pronchery
5b077aed3SPierre ProncheryOSSL_ENCODER,
6b077aed3SPierre ProncheryOSSL_ENCODER_fetch,
7b077aed3SPierre ProncheryOSSL_ENCODER_up_ref,
8b077aed3SPierre ProncheryOSSL_ENCODER_free,
9b077aed3SPierre ProncheryOSSL_ENCODER_get0_provider,
10b077aed3SPierre ProncheryOSSL_ENCODER_get0_properties,
11b077aed3SPierre ProncheryOSSL_ENCODER_is_a,
12b077aed3SPierre ProncheryOSSL_ENCODER_get0_name,
13b077aed3SPierre ProncheryOSSL_ENCODER_get0_description,
14b077aed3SPierre ProncheryOSSL_ENCODER_do_all_provided,
15b077aed3SPierre ProncheryOSSL_ENCODER_names_do_all,
16b077aed3SPierre ProncheryOSSL_ENCODER_gettable_params,
17b077aed3SPierre ProncheryOSSL_ENCODER_get_params
18b077aed3SPierre Pronchery- Encoder method routines
19b077aed3SPierre Pronchery
20b077aed3SPierre Pronchery=head1 SYNOPSIS
21b077aed3SPierre Pronchery
22b077aed3SPierre Pronchery #include <openssl/encoder.h>
23b077aed3SPierre Pronchery
24b077aed3SPierre Pronchery typedef struct ossl_encoder_st OSSL_ENCODER;
25b077aed3SPierre Pronchery
26b077aed3SPierre Pronchery OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *ctx, const char *name,
27b077aed3SPierre Pronchery                                  const char *properties);
28b077aed3SPierre Pronchery int OSSL_ENCODER_up_ref(OSSL_ENCODER *encoder);
29b077aed3SPierre Pronchery void OSSL_ENCODER_free(OSSL_ENCODER *encoder);
30b077aed3SPierre Pronchery const OSSL_PROVIDER *OSSL_ENCODER_get0_provider(const OSSL_ENCODER *encoder);
31b077aed3SPierre Pronchery const char *OSSL_ENCODER_get0_properties(const OSSL_ENCODER *encoder);
32b077aed3SPierre Pronchery int OSSL_ENCODER_is_a(const OSSL_ENCODER *encoder, const char *name);
33b077aed3SPierre Pronchery const char *OSSL_ENCODER_get0_name(const OSSL_ENCODER *encoder);
34b077aed3SPierre Pronchery const char *OSSL_ENCODER_get0_description(const OSSL_ENCODER *encoder);
35b077aed3SPierre Pronchery void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx,
36b077aed3SPierre Pronchery                                   void (*fn)(OSSL_ENCODER *encoder, void *arg),
37b077aed3SPierre Pronchery                                   void *arg);
38b077aed3SPierre Pronchery int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder,
39b077aed3SPierre Pronchery                               void (*fn)(const char *name, void *data),
40b077aed3SPierre Pronchery                               void *data);
41b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_ENCODER_gettable_params(OSSL_ENCODER *encoder);
42b077aed3SPierre Pronchery int OSSL_ENCODER_get_params(OSSL_ENCODER_CTX *ctx, const OSSL_PARAM params[]);
43b077aed3SPierre Pronchery
44b077aed3SPierre Pronchery=head1 DESCRIPTION
45b077aed3SPierre Pronchery
46b077aed3SPierre ProncheryB<OSSL_ENCODER> is a method for encoders, which know how to
47b077aed3SPierre Proncheryencode an object of some kind to a encoded form, such as PEM,
48b077aed3SPierre ProncheryDER, or even human readable text.
49b077aed3SPierre Pronchery
50b077aed3SPierre ProncheryOSSL_ENCODER_fetch() looks for an algorithm within the provider that
51b077aed3SPierre Proncheryhas been loaded into the B<OSSL_LIB_CTX> given by I<ctx>, having the
52b077aed3SPierre Proncheryname given by I<name> and the properties given by I<properties>.
53b077aed3SPierre ProncheryThe I<name> determines what type of object the fetched encoder
54b077aed3SPierre Proncherymethod is expected to be able to encode, and the properties are
55b077aed3SPierre Proncheryused to determine the expected output type.
56b077aed3SPierre ProncheryFor known properties and the values they may have, please have a look
57b077aed3SPierre Proncheryin L<provider-encoder(7)/Names and properties>.
58b077aed3SPierre Pronchery
59b077aed3SPierre ProncheryOSSL_ENCODER_up_ref() increments the reference count for the given
60b077aed3SPierre ProncheryI<encoder>.
61b077aed3SPierre Pronchery
62b077aed3SPierre ProncheryOSSL_ENCODER_free() decrements the reference count for the given
63b077aed3SPierre ProncheryI<encoder>, and when the count reaches zero, frees it.
64*a7148ab3SEnji CooperIf the argument is NULL, nothing is done.
65b077aed3SPierre Pronchery
66b077aed3SPierre ProncheryOSSL_ENCODER_get0_provider() returns the provider of the given
67b077aed3SPierre ProncheryI<encoder>.
68b077aed3SPierre Pronchery
69b077aed3SPierre ProncheryOSSL_ENCODER_get0_properties() returns the property definition associated
70b077aed3SPierre Proncherywith the given I<encoder>.
71b077aed3SPierre Pronchery
72b077aed3SPierre ProncheryOSSL_ENCODER_is_a() checks if I<encoder> is an implementation of an
73b077aed3SPierre Proncheryalgorithm that's identifiable with I<name>.
74b077aed3SPierre Pronchery
75b077aed3SPierre ProncheryOSSL_ENCODER_get0_name() returns the name used to fetch the given I<encoder>.
76b077aed3SPierre Pronchery
77b077aed3SPierre ProncheryOSSL_ENCODER_get0_description() returns a description of the I<loader>, meant
78b077aed3SPierre Proncheryfor display and human consumption.  The description is at the discretion of the
79b077aed3SPierre ProncheryI<loader> implementation.
80b077aed3SPierre Pronchery
81b077aed3SPierre ProncheryOSSL_ENCODER_names_do_all() traverses all names for the given
82b077aed3SPierre ProncheryI<encoder>, and calls I<fn> with each name and I<data> as arguments.
83b077aed3SPierre Pronchery
84b077aed3SPierre ProncheryOSSL_ENCODER_do_all_provided() traverses all encoder
85b077aed3SPierre Proncheryimplementations by all activated providers in the library context
86b077aed3SPierre ProncheryI<libctx>, and for each of the implementations, calls I<fn> with the
87b077aed3SPierre Proncheryimplementation method and I<arg> as arguments.
88b077aed3SPierre Pronchery
89b077aed3SPierre ProncheryOSSL_ENCODER_gettable_params() returns an L<OSSL_PARAM(3)>
90b077aed3SPierre Proncheryarray of parameter descriptors.
91b077aed3SPierre Pronchery
92b077aed3SPierre ProncheryOSSL_ENCODER_get_params() attempts to get parameters specified
93b077aed3SPierre Proncherywith an L<OSSL_PARAM(3)> array I<params>.  Parameters that the
94b077aed3SPierre Proncheryimplementation doesn't recognise should be ignored.
95b077aed3SPierre Pronchery
96b077aed3SPierre Pronchery=head1 RETURN VALUES
97b077aed3SPierre Pronchery
98b077aed3SPierre ProncheryOSSL_ENCODER_fetch() returns a pointer to the key management
99b077aed3SPierre Proncheryimplementation represented by an OSSL_ENCODER object, or NULL on
100b077aed3SPierre Proncheryerror.
101b077aed3SPierre Pronchery
102b077aed3SPierre ProncheryOSSL_ENCODER_up_ref() returns 1 on success, or 0 on error.
103b077aed3SPierre Pronchery
104b077aed3SPierre ProncheryOSSL_ENCODER_free() doesn't return any value.
105b077aed3SPierre Pronchery
106b077aed3SPierre ProncheryOSSL_ENCODER_get0_provider() returns a pointer to a provider object, or
107b077aed3SPierre ProncheryNULL on error.
108b077aed3SPierre Pronchery
109b077aed3SPierre ProncheryOSSL_ENCODER_get0_properties() returns a pointer to a property
110b077aed3SPierre Proncherydefinition string, or NULL on error.
111b077aed3SPierre Pronchery
112b077aed3SPierre ProncheryOSSL_ENCODER_is_a() returns 1 of I<encoder> was identifiable,
113b077aed3SPierre Proncheryotherwise 0.
114b077aed3SPierre Pronchery
115b077aed3SPierre ProncheryOSSL_ENCODER_get0_name() returns the algorithm name from the provided
116b077aed3SPierre Proncheryimplementation for the given I<encoder>. Note that the I<encoder> may have
117b077aed3SPierre Proncherymultiple synonyms associated with it. In this case the first name from the
118b077aed3SPierre Proncheryalgorithm definition is returned. Ownership of the returned string is retained
119b077aed3SPierre Proncheryby the I<encoder> object and should not be freed by the caller.
120b077aed3SPierre Pronchery
121aa795734SPierre ProncheryOSSL_ENCODER_get0_description() returns a pointer to a description, or NULL if
122b077aed3SPierre Proncherythere isn't one.
123b077aed3SPierre Pronchery
124b077aed3SPierre ProncheryOSSL_ENCODER_names_do_all() returns 1 if the callback was called for all
125b077aed3SPierre Proncherynames. A return value of 0 means that the callback was not called for any names.
126b077aed3SPierre Pronchery
127b077aed3SPierre Pronchery=head1 SEE ALSO
128b077aed3SPierre Pronchery
129b077aed3SPierre ProncheryL<provider(7)>, L<OSSL_ENCODER_CTX(3)>, L<OSSL_ENCODER_to_bio(3)>,
130b077aed3SPierre ProncheryL<OSSL_ENCODER_CTX_new_for_pkey(3)>, L<OSSL_LIB_CTX(3)>
131b077aed3SPierre Pronchery
132b077aed3SPierre Pronchery=head1 HISTORY
133b077aed3SPierre Pronchery
134b077aed3SPierre ProncheryThe functions described here were added in OpenSSL 3.0.
135b077aed3SPierre Pronchery
136b077aed3SPierre Pronchery=head1 COPYRIGHT
137b077aed3SPierre Pronchery
138*a7148ab3SEnji CooperCopyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
139b077aed3SPierre Pronchery
140b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
141b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
142b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
143b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
144b077aed3SPierre Pronchery
145b077aed3SPierre Pronchery=cut
146