1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncheryOSSL_DECODER, 6*b077aed3SPierre ProncheryOSSL_DECODER_fetch, 7*b077aed3SPierre ProncheryOSSL_DECODER_up_ref, 8*b077aed3SPierre ProncheryOSSL_DECODER_free, 9*b077aed3SPierre ProncheryOSSL_DECODER_get0_provider, 10*b077aed3SPierre ProncheryOSSL_DECODER_get0_properties, 11*b077aed3SPierre ProncheryOSSL_DECODER_is_a, 12*b077aed3SPierre ProncheryOSSL_DECODER_get0_name, 13*b077aed3SPierre ProncheryOSSL_DECODER_get0_description, 14*b077aed3SPierre ProncheryOSSL_DECODER_do_all_provided, 15*b077aed3SPierre ProncheryOSSL_DECODER_names_do_all, 16*b077aed3SPierre ProncheryOSSL_DECODER_gettable_params, 17*b077aed3SPierre ProncheryOSSL_DECODER_get_params 18*b077aed3SPierre Pronchery- Decoder method routines 19*b077aed3SPierre Pronchery 20*b077aed3SPierre Pronchery=head1 SYNOPSIS 21*b077aed3SPierre Pronchery 22*b077aed3SPierre Pronchery #include <openssl/decoder.h> 23*b077aed3SPierre Pronchery 24*b077aed3SPierre Pronchery typedef struct ossl_decoder_st OSSL_DECODER; 25*b077aed3SPierre Pronchery 26*b077aed3SPierre Pronchery OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *ctx, const char *name, 27*b077aed3SPierre Pronchery const char *properties); 28*b077aed3SPierre Pronchery int OSSL_DECODER_up_ref(OSSL_DECODER *decoder); 29*b077aed3SPierre Pronchery void OSSL_DECODER_free(OSSL_DECODER *decoder); 30*b077aed3SPierre Pronchery const OSSL_PROVIDER *OSSL_DECODER_get0_provider(const OSSL_DECODER *decoder); 31*b077aed3SPierre Pronchery const char *OSSL_DECODER_get0_properties(const OSSL_DECODER *decoder); 32*b077aed3SPierre Pronchery int OSSL_DECODER_is_a(const OSSL_DECODER *decoder, const char *name); 33*b077aed3SPierre Pronchery const char *OSSL_DECODER_get0_name(const OSSL_DECODER *decoder); 34*b077aed3SPierre Pronchery const char *OSSL_DECODER_get0_description(const OSSL_DECODER *decoder); 35*b077aed3SPierre Pronchery void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx, 36*b077aed3SPierre Pronchery void (*fn)(OSSL_DECODER *decoder, void *arg), 37*b077aed3SPierre Pronchery void *arg); 38*b077aed3SPierre Pronchery int OSSL_DECODER_names_do_all(const OSSL_DECODER *decoder, 39*b077aed3SPierre Pronchery void (*fn)(const char *name, void *data), 40*b077aed3SPierre Pronchery void *data); 41*b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder); 42*b077aed3SPierre Pronchery int OSSL_DECODER_get_params(OSSL_DECODER_CTX *ctx, const OSSL_PARAM params[]); 43*b077aed3SPierre Pronchery 44*b077aed3SPierre Pronchery=head1 DESCRIPTION 45*b077aed3SPierre Pronchery 46*b077aed3SPierre ProncheryB<OSSL_DECODER> is a method for decoders, which know how to 47*b077aed3SPierre Proncherydecode encoded data into an object of some type that the rest 48*b077aed3SPierre Proncheryof OpenSSL knows how to handle. 49*b077aed3SPierre Pronchery 50*b077aed3SPierre ProncheryOSSL_DECODER_fetch() looks for an algorithm within the provider that 51*b077aed3SPierre Proncheryhas been loaded into the B<OSSL_LIB_CTX> given by I<ctx>, having the 52*b077aed3SPierre Proncheryname given by I<name> and the properties given by I<properties>. 53*b077aed3SPierre ProncheryThe I<name> determines what type of object the fetched decoder 54*b077aed3SPierre Proncherymethod is expected to be able to decode, and the properties are 55*b077aed3SPierre Proncheryused to determine the expected output type. 56*b077aed3SPierre ProncheryFor known properties and the values they may have, please have a look 57*b077aed3SPierre Proncheryin L<provider-encoder(7)/Names and properties>. 58*b077aed3SPierre Pronchery 59*b077aed3SPierre ProncheryOSSL_DECODER_up_ref() increments the reference count for the given 60*b077aed3SPierre ProncheryI<decoder>. 61*b077aed3SPierre Pronchery 62*b077aed3SPierre ProncheryOSSL_DECODER_free() decrements the reference count for the given 63*b077aed3SPierre ProncheryI<decoder>, and when the count reaches zero, frees it. 64*b077aed3SPierre Pronchery 65*b077aed3SPierre ProncheryOSSL_DECODER_get0_provider() returns the provider of the given 66*b077aed3SPierre ProncheryI<decoder>. 67*b077aed3SPierre Pronchery 68*b077aed3SPierre ProncheryOSSL_DECODER_get0_properties() returns the property definition associated 69*b077aed3SPierre Proncherywith the given I<decoder>. 70*b077aed3SPierre Pronchery 71*b077aed3SPierre ProncheryOSSL_DECODER_is_a() checks if I<decoder> is an implementation 72*b077aed3SPierre Proncheryof an algorithm that's identifiable with I<name>. 73*b077aed3SPierre Pronchery 74*b077aed3SPierre ProncheryOSSL_DECODER_get0_name() returns the name used to fetch the given I<decoder>. 75*b077aed3SPierre Pronchery 76*b077aed3SPierre ProncheryOSSL_DECODER_get0_description() returns a description of the I<decoder>, meant 77*b077aed3SPierre Proncheryfor display and human consumption. The description is at the discretion 78*b077aed3SPierre Proncheryof the I<decoder> implementation. 79*b077aed3SPierre Pronchery 80*b077aed3SPierre ProncheryOSSL_DECODER_names_do_all() traverses all names for the given 81*b077aed3SPierre ProncheryI<decoder>, and calls I<fn> with each name and I<data> as arguments. 82*b077aed3SPierre Pronchery 83*b077aed3SPierre ProncheryOSSL_DECODER_do_all_provided() traverses all decoder 84*b077aed3SPierre Proncheryimplementations by all activated providers in the library context 85*b077aed3SPierre ProncheryI<libctx>, and for each of the implementations, calls I<fn> with the 86*b077aed3SPierre Proncheryimplementation method and I<arg> as arguments. 87*b077aed3SPierre Pronchery 88*b077aed3SPierre ProncheryOSSL_DECODER_gettable_params() returns an L<OSSL_PARAM(3)> 89*b077aed3SPierre Proncheryarray of parameter descriptors. 90*b077aed3SPierre Pronchery 91*b077aed3SPierre ProncheryOSSL_DECODER_get_params() attempts to get parameters specified 92*b077aed3SPierre Proncherywith an L<OSSL_PARAM(3)> array I<params>. Parameters that the 93*b077aed3SPierre Proncheryimplementation doesn't recognise should be ignored. 94*b077aed3SPierre Pronchery 95*b077aed3SPierre Pronchery=head1 RETURN VALUES 96*b077aed3SPierre Pronchery 97*b077aed3SPierre ProncheryOSSL_DECODER_fetch() returns a pointer to an OSSL_DECODER object, 98*b077aed3SPierre Proncheryor NULL on error. 99*b077aed3SPierre Pronchery 100*b077aed3SPierre ProncheryOSSL_DECODER_up_ref() returns 1 on success, or 0 on error. 101*b077aed3SPierre Pronchery 102*b077aed3SPierre ProncheryOSSL_DECODER_free() doesn't return any value. 103*b077aed3SPierre Pronchery 104*b077aed3SPierre ProncheryOSSL_DECODER_get0_provider() returns a pointer to a provider object, or 105*b077aed3SPierre ProncheryNULL on error. 106*b077aed3SPierre Pronchery 107*b077aed3SPierre ProncheryOSSL_DECODER_get0_properties() returns a pointer to a property 108*b077aed3SPierre Proncherydefinition string, or NULL on error. 109*b077aed3SPierre Pronchery 110*b077aed3SPierre ProncheryOSSL_DECODER_is_a() returns 1 if I<decoder> was identifiable, 111*b077aed3SPierre Proncheryotherwise 0. 112*b077aed3SPierre Pronchery 113*b077aed3SPierre ProncheryOSSL_DECODER_get0_name() returns the algorithm name from the provided 114*b077aed3SPierre Proncheryimplementation for the given I<decoder>. Note that the I<decoder> may have 115*b077aed3SPierre Proncherymultiple synonyms associated with it. In this case the first name from the 116*b077aed3SPierre Proncheryalgorithm definition is returned. Ownership of the returned string is retained 117*b077aed3SPierre Proncheryby the I<decoder> object and should not be freed by the caller. 118*b077aed3SPierre Pronchery 119*b077aed3SPierre ProncheryOSSL_DECODER_get0_description() returns a pointer to a decription, or NULL if 120*b077aed3SPierre Proncherythere isn't one. 121*b077aed3SPierre Pronchery 122*b077aed3SPierre ProncheryOSSL_DECODER_names_do_all() returns 1 if the callback was called for all 123*b077aed3SPierre Proncherynames. A return value of 0 means that the callback was not called for any names. 124*b077aed3SPierre Pronchery 125*b077aed3SPierre Pronchery=head1 NOTES 126*b077aed3SPierre Pronchery 127*b077aed3SPierre ProncheryOSSL_DECODER_fetch() may be called implicitly by other fetching 128*b077aed3SPierre Proncheryfunctions, using the same library context and properties. 129*b077aed3SPierre ProncheryAny other API that uses keys will typically do this. 130*b077aed3SPierre Pronchery 131*b077aed3SPierre Pronchery=head1 EXAMPLES 132*b077aed3SPierre Pronchery 133*b077aed3SPierre ProncheryTo list all decoders in a provider to a bio_out: 134*b077aed3SPierre Pronchery 135*b077aed3SPierre Pronchery static void collect_decoders(OSSL_DECODER *decoder, void *stack) 136*b077aed3SPierre Pronchery { 137*b077aed3SPierre Pronchery STACK_OF(OSSL_DECODER) *decoder_stack = stack; 138*b077aed3SPierre Pronchery 139*b077aed3SPierre Pronchery sk_OSSL_DECODER_push(decoder_stack, decoder); 140*b077aed3SPierre Pronchery OSSL_DECODER_up_ref(decoder); 141*b077aed3SPierre Pronchery } 142*b077aed3SPierre Pronchery 143*b077aed3SPierre Pronchery void print_name(const char *name, void *vdata) 144*b077aed3SPierre Pronchery { 145*b077aed3SPierre Pronchery BIO *bio = vdata; 146*b077aed3SPierre Pronchery 147*b077aed3SPierre Pronchery BIO_printf(bio, "%s ", name); 148*b077aed3SPierre Pronchery } 149*b077aed3SPierre Pronchery 150*b077aed3SPierre Pronchery 151*b077aed3SPierre Pronchery STACK_OF(OSSL_DECODER) *decoders; 152*b077aed3SPierre Pronchery int i; 153*b077aed3SPierre Pronchery 154*b077aed3SPierre Pronchery decoders = sk_OSSL_DECODER_new_null(); 155*b077aed3SPierre Pronchery 156*b077aed3SPierre Pronchery BIO_printf(bio_out, "DECODERs provided by %s:\n", provider); 157*b077aed3SPierre Pronchery OSSL_DECODER_do_all_provided(NULL, collect_decoders, 158*b077aed3SPierre Pronchery decoders); 159*b077aed3SPierre Pronchery 160*b077aed3SPierre Pronchery for (i = 0; i < sk_OSSL_DECODER_num(decoders); i++) { 161*b077aed3SPierre Pronchery OSSL_DECODER *decoder = sk_OSSL_DECODER_value(decoders, i); 162*b077aed3SPierre Pronchery 163*b077aed3SPierre Pronchery if (strcmp(OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(decoder)), 164*b077aed3SPierre Pronchery provider) != 0) 165*b077aed3SPierre Pronchery continue; 166*b077aed3SPierre Pronchery 167*b077aed3SPierre Pronchery if (OSSL_DECODER_names_do_all(decoder, print_name, bio_out)) 168*b077aed3SPierre Pronchery BIO_printf(bio_out, "\n"); 169*b077aed3SPierre Pronchery } 170*b077aed3SPierre Pronchery sk_OSSL_DECODER_pop_free(decoders, OSSL_DECODER_free); 171*b077aed3SPierre Pronchery 172*b077aed3SPierre Pronchery=head1 SEE ALSO 173*b077aed3SPierre Pronchery 174*b077aed3SPierre ProncheryL<provider(7)>, L<OSSL_DECODER_CTX(3)>, L<OSSL_DECODER_from_bio(3)>, 175*b077aed3SPierre ProncheryL<OSSL_DECODER_CTX_new_for_pkey(3)>, L<OSSL_LIB_CTX(3)> 176*b077aed3SPierre Pronchery 177*b077aed3SPierre Pronchery=head1 HISTORY 178*b077aed3SPierre Pronchery 179*b077aed3SPierre ProncheryThe functions described here were added in OpenSSL 3.0. 180*b077aed3SPierre Pronchery 181*b077aed3SPierre Pronchery=head1 COPYRIGHT 182*b077aed3SPierre Pronchery 183*b077aed3SPierre ProncheryCopyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. 184*b077aed3SPierre Pronchery 185*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 186*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 187*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 188*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 189*b077aed3SPierre Pronchery 190*b077aed3SPierre Pronchery=cut 191