10 OSSL_DECODER_properties,
13 OSSL_DECODER_description,
14 OSSL_DECODER_do_all_provided,
15 OSSL_DECODER_names_do_all,
16 OSSL_DECODER_gettable_params,
17 OSSL_DECODER_get_params
18 - Decoder method routines
22 #include <openssl/decoder.h>
24 typedef struct ossl_decoder_st OSSL_DECODER;
26 OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *ctx, const char *name,
27 const char *properties);
28 int OSSL_DECODER_up_ref(OSSL_DECODER *decoder);
29 void OSSL_DECODER_free(OSSL_DECODER *decoder);
30 const OSSL_PROVIDER *OSSL_DECODER_provider(const OSSL_DECODER *decoder);
31 const char *OSSL_DECODER_properties(const OSSL_DECODER *decoder);
32 int OSSL_DECODER_is_a(const OSSL_DECODER *decoder, const char *name);
33 int OSSL_DECODER_number(const OSSL_DECODER *decoder);
34 const char *OSSL_DECODER_description(const OSSL_DECODER *decoder);
35 void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
36 void (*fn)(OSSL_DECODER *decoder, void *arg),
38 int OSSL_DECODER_names_do_all(const OSSL_DECODER *decoder,
39 void (*fn)(const char *name, void *data),
41 const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder);
42 int OSSL_DECODER_get_params(OSSL_DECODER_CTX *ctx, const OSSL_PARAM params[]);
46 B<OSSL_DECODER> is a method for decoders, which know how to
47 decode encoded data into an object of some type that the rest
48 of OpenSSL knows how to handle.
50 OSSL_DECODER_fetch() looks for an algorithm within the provider that
51 has been loaded into the B<OSSL_LIB_CTX> given by I<ctx>, having the
52 name given by I<name> and the properties given by I<properties>.
53 The I<name> determines what type of object the fetched decoder
54 method is expected to be able to decode, and the properties are
55 used to determine the expected output type.
56 For known properties and the values they may have, please have a look
57 in L<provider-encoder(7)/Names and properties>.
59 OSSL_DECODER_up_ref() increments the reference count for the given
62 OSSL_DECODER_free() decrements the reference count for the given
63 I<decoder>, and when the count reaches zero, frees it.
65 OSSL_DECODER_provider() returns the provider of the given
68 OSSL_DECODER_properties() returns the property definition associated
69 with the given I<decoder>.
71 OSSL_DECODER_is_a() checks if I<decoder> is an implementation
72 of an algorithm that's identifiable with I<name>.
74 OSSL_DECODER_number() returns the internal dynamic number assigned
75 to the given I<decoder>.
77 OSSL_DECODER_description() returns a description of the I<decoder>, meant
78 for display and human consumption. The description is at the discretion
79 of the I<decoder> implementation.
81 OSSL_DECODER_names_do_all() traverses all names for the given
82 I<decoder>, and calls I<fn> with each name and I<data> as arguments.
84 OSSL_DECODER_do_all_provided() traverses all decoder
85 implementations by all activated providers in the library context
86 I<libctx>, and for each of the implementations, calls I<fn> with the
87 implementation method and I<arg> as arguments.
89 OSSL_DECODER_gettable_params() returns an L<OSSL_PARAM(3)>
90 array of parameter descriptors.
92 OSSL_DECODER_get_params() attempts to get parameters specified
93 with an L<OSSL_PARAM(3)> array I<params>. Parameters that the
94 implementation doesn't recognise should be ignored.
98 OSSL_DECODER_fetch() returns a pointer to an OSSL_DECODER object,
101 OSSL_DECODER_up_ref() returns 1 on success, or 0 on error.
103 OSSL_DECODER_free() doesn't return any value.
105 OSSL_DECODER_provider() returns a pointer to a provider object, or
108 OSSL_DECODER_properties() returns a pointer to a property
109 definition string, or NULL on error.
111 OSSL_DECODER_is_a() returns 1 if I<decoder> was identifiable,
114 OSSL_DECODER_number() returns an integer.
116 OSSL_DECODER_description() returns a pointer to a decription, or NULL if
119 OSSL_DECODER_names_do_all() returns 1 if the callback was called for all
120 names. A return value of 0 means that the callback was not called for any names.
124 OSSL_DECODER_fetch() may be called implicitly by other fetching
125 functions, using the same library context and properties.
126 Any other API that uses keys will typically do this.
130 To list all decoders in a provider to a bio_out:
132 static void collect_decoders(OSSL_DECODER *decoder, void *stack)
134 STACK_OF(OSSL_DECODER) *decoder_stack = stack;
136 sk_OSSL_DECODER_push(decoder_stack, decoder);
137 OSSL_DECODER_up_ref(decoder);
140 void print_name(const char *name, void *vdata)
144 BIO_printf(bio, "%s ", name);
148 STACK_OF(OSSL_DECODER) *decoders;
151 decoders = sk_OSSL_DECODER_new_null();
153 BIO_printf(bio_out, "DECODERs provided by %s:\n", provider);
154 OSSL_DECODER_do_all_provided(NULL, collect_decoders,
157 for (i = 0; i < sk_OSSL_DECODER_num(decoders); i++) {
158 OSSL_DECODER *decoder = sk_OSSL_DECODER_value(decoders, i);
160 if (strcmp(OSSL_PROVIDER_name(OSSL_DECODER_provider(decoder)),
164 if (OSSL_DECODER_names_do_all(decoder, print_name, bio_out))
165 BIO_printf(bio_out, "\n");
167 sk_OSSL_DECODER_pop_free(decoders, OSSL_DECODER_free);
171 L<provider(7)>, L<OSSL_DECODER_CTX(3)>, L<OSSL_DECODER_from_bio(3)>,
172 L<OSSL_DECODER_CTX_new_for_pkey(3)>, L<OSSL_LIB_CTX(3)>
176 The functions described here were added in OpenSSL 3.0.
180 Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
182 Licensed under the Apache License 2.0 (the "License"). You may not use
183 this file except in compliance with the License. You can obtain a copy
184 in the file LICENSE in the source distribution or at
185 L<https://www.openssl.org/source/license.html>.