Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos OSSL_ENCODER_CTX,
      6      1.1  christos OSSL_ENCODER_CTX_new,
      7      1.1  christos OSSL_ENCODER_settable_ctx_params,
      8      1.1  christos OSSL_ENCODER_CTX_set_params,
      9      1.1  christos OSSL_ENCODER_CTX_free,
     10      1.1  christos OSSL_ENCODER_CTX_set_selection,
     11      1.1  christos OSSL_ENCODER_CTX_set_output_type,
     12      1.1  christos OSSL_ENCODER_CTX_set_output_structure,
     13      1.1  christos OSSL_ENCODER_CTX_add_encoder,
     14      1.1  christos OSSL_ENCODER_CTX_add_extra,
     15      1.1  christos OSSL_ENCODER_CTX_get_num_encoders,
     16      1.1  christos OSSL_ENCODER_INSTANCE,
     17      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder,
     18      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder_ctx,
     19      1.1  christos OSSL_ENCODER_INSTANCE_get_output_type,
     20      1.1  christos OSSL_ENCODER_INSTANCE_get_output_structure,
     21      1.1  christos OSSL_ENCODER_CONSTRUCT,
     22      1.1  christos OSSL_ENCODER_CLEANUP,
     23      1.1  christos OSSL_ENCODER_CTX_set_construct,
     24      1.1  christos OSSL_ENCODER_CTX_set_construct_data,
     25      1.1  christos OSSL_ENCODER_CTX_set_cleanup
     26      1.1  christos - Encoder context routines
     27      1.1  christos 
     28      1.1  christos =head1 SYNOPSIS
     29      1.1  christos 
     30      1.1  christos  #include <openssl/encoder.h>
     31      1.1  christos 
     32      1.1  christos  typedef struct ossl_encoder_ctx_st OSSL_ENCODER_CTX;
     33      1.1  christos 
     34      1.1  christos  OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new();
     35      1.1  christos  const OSSL_PARAM *OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER *encoder);
     36      1.1  christos  int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx,
     37      1.1  christos                                  const OSSL_PARAM params[]);
     38      1.1  christos  void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx);
     39      1.1  christos 
     40      1.1  christos  int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection);
     41      1.1  christos  int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx,
     42      1.1  christos                                       const char *output_type);
     43      1.1  christos  int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx,
     44      1.1  christos                                            const char *output_structure);
     45      1.1  christos 
     46      1.1  christos  int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder);
     47      1.1  christos  int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx,
     48      1.1  christos                                 OSSL_LIB_CTX *libctx, const char *propq);
     49      1.1  christos  int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx);
     50      1.1  christos 
     51      1.1  christos  typedef struct ossl_encoder_instance_st OSSL_ENCODER_INSTANCE;
     52      1.1  christos  OSSL_ENCODER *
     53      1.1  christos  OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst);
     54      1.1  christos  void *
     55      1.1  christos  OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst);
     56      1.1  christos  const char *
     57      1.1  christos  OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst);
     58      1.1  christos  const char *
     59      1.1  christos  OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst);
     60      1.1  christos 
     61      1.1  christos  typedef const void *OSSL_ENCODER_CONSTRUCT(OSSL_ENCODER_INSTANCE *encoder_inst,
     62      1.1  christos                                             void *construct_data);
     63      1.1  christos  typedef void OSSL_ENCODER_CLEANUP(void *construct_data);
     64      1.1  christos 
     65      1.1  christos  int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx,
     66      1.1  christos                                     OSSL_ENCODER_CONSTRUCT *construct);
     67      1.1  christos  int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx,
     68      1.1  christos                                          void *construct_data);
     69      1.1  christos  int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx,
     70      1.1  christos                                   OSSL_ENCODER_CLEANUP *cleanup);
     71      1.1  christos 
     72      1.1  christos =head1 DESCRIPTION
     73      1.1  christos 
     74      1.1  christos Encoding an input object to the desired encoding may be done with a chain of
     75      1.1  christos encoder implementations, which means that the output from one encoder may be
     76      1.1  christos the input for the next in the chain.  The B<OSSL_ENCODER_CTX> holds all the
     77      1.1  christos data about these encoders.  This allows having generic format encoders such
     78      1.1  christos as DER to PEM, as well as more specialized encoders like RSA to DER.
     79      1.1  christos 
     80      1.1  christos The final output type must be given, and a chain of encoders must end with
     81      1.1  christos an implementation that produces that output type.
     82      1.1  christos 
     83  1.1.1.2  christos At the beginning of the encoding process, a constructor provided by the
     84      1.1  christos caller is called to ensure that there is an appropriate provider-side object
     85      1.1  christos to start with.
     86      1.1  christos The constructor is set with OSSL_ENCODER_CTX_set_construct().
     87      1.1  christos 
     88      1.1  christos B<OSSL_ENCODER_INSTANCE> is an opaque structure that contains data about the
     89      1.1  christos encoder that is going to be used, and that may be useful for the
     90      1.1  christos constructor.  There are some functions to extract data from this type,
     91      1.1  christos described in L</Constructor> below.
     92      1.1  christos 
     93      1.1  christos =head2 Functions
     94      1.1  christos 
     95      1.1  christos OSSL_ENCODER_CTX_new() creates a B<OSSL_ENCODER_CTX>.
     96      1.1  christos 
     97      1.1  christos OSSL_ENCODER_settable_ctx_params() returns an L<OSSL_PARAM(3)>
     98      1.1  christos array of parameter descriptors.
     99      1.1  christos 
    100      1.1  christos OSSL_ENCODER_CTX_set_params() attempts to set parameters specified
    101      1.1  christos with an L<OSSL_PARAM(3)> array I<params>.  Parameters that the
    102      1.1  christos implementation doesn't recognise should be ignored.
    103      1.1  christos 
    104      1.1  christos OSSL_ENCODER_CTX_free() frees the given context I<ctx>.
    105  1.1.1.3  christos If the argument is NULL, nothing is done.
    106      1.1  christos 
    107      1.1  christos OSSL_ENCODER_CTX_add_encoder() populates the B<OSSL_ENCODER_CTX>
    108      1.1  christos I<ctx> with a encoder, to be used to encode an input object.
    109      1.1  christos 
    110      1.1  christos OSSL_ENCODER_CTX_add_extra() finds encoders that further encodes output
    111      1.1  christos from already added encoders, and adds them as well.  This is used to build
    112      1.1  christos encoder chains.
    113      1.1  christos 
    114      1.1  christos OSSL_ENCODER_CTX_set_output_type() sets the ending output type.  This must
    115      1.1  christos be specified, and determines if a complete encoder chain is available.
    116      1.1  christos 
    117      1.1  christos OSSL_ENCODER_CTX_set_output_structure() sets the desired output structure.
    118      1.1  christos This may be used to determines what encoder implementations may be used.
    119      1.1  christos Depending on the type of object being encoded, the output structure may
    120      1.1  christos not be relevant.
    121      1.1  christos 
    122      1.1  christos OSSL_ENCODER_CTX_get_num_encoders() gets the number of encoders currently
    123      1.1  christos added to the context I<ctx>.
    124      1.1  christos 
    125      1.1  christos OSSL_ENCODER_CTX_set_construct() sets the constructor I<construct>.
    126      1.1  christos 
    127      1.1  christos OSSL_ENCODER_CTX_set_construct_data() sets the constructor data that is
    128      1.1  christos passed to the constructor every time it's called.
    129      1.1  christos 
    130      1.1  christos OSSL_ENCODER_CTX_set_cleanup() sets the constructor data I<cleanup>
    131      1.1  christos function.  This is called by L<OSSL_ENCODER_CTX_free(3)>.
    132      1.1  christos 
    133      1.1  christos =head2 Constructor
    134      1.1  christos 
    135      1.1  christos A B<OSSL_ENCODER_CONSTRUCT> gets the following arguments:
    136      1.1  christos 
    137      1.1  christos =over 4
    138      1.1  christos 
    139      1.1  christos =item I<encoder_inst>
    140      1.1  christos 
    141      1.1  christos The B<OSSL_ENCODER_INSTANCE> for the encoder from which the constructor gets
    142      1.1  christos its data.
    143      1.1  christos 
    144      1.1  christos =item I<construct_data>
    145      1.1  christos 
    146      1.1  christos The pointer that was set with OSSL_ENCODE_CTX_set_construct_data().
    147      1.1  christos 
    148      1.1  christos =back
    149      1.1  christos 
    150      1.1  christos The constructor is expected to return a valid (non-NULL) pointer to a
    151      1.1  christos provider-native object that can be used as first input of an encoding chain,
    152  1.1.1.2  christos or NULL to indicate that an error has occurred.
    153      1.1  christos 
    154      1.1  christos These utility functions may be used by a constructor:
    155      1.1  christos 
    156      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder() can be used to get the encoder
    157      1.1  christos implementation of the encoder instance I<encoder_inst>.
    158      1.1  christos 
    159      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder_ctx() can be used to get the encoder
    160      1.1  christos implementation's provider context of the encoder instance I<encoder_inst>.
    161      1.1  christos 
    162      1.1  christos OSSL_ENCODER_INSTANCE_get_output_type() can be used to get the output type
    163      1.1  christos for the encoder implementation of the encoder instance I<encoder_inst>.
    164      1.1  christos This will never be NULL.
    165      1.1  christos 
    166      1.1  christos OSSL_ENCODER_INSTANCE_get_output_structure() can be used to get the output
    167      1.1  christos structure for the encoder implementation of the encoder instance
    168      1.1  christos I<encoder_inst>.
    169      1.1  christos This may be NULL.
    170      1.1  christos 
    171      1.1  christos =head1 RETURN VALUES
    172      1.1  christos 
    173      1.1  christos OSSL_ENCODER_CTX_new() returns a pointer to a B<OSSL_ENCODER_CTX>, or NULL
    174      1.1  christos if the context structure couldn't be allocated.
    175      1.1  christos 
    176      1.1  christos OSSL_ENCODER_settable_ctx_params() returns an L<OSSL_PARAM(3)> array, or
    177      1.1  christos NULL if none is available.
    178      1.1  christos 
    179      1.1  christos OSSL_ENCODER_CTX_set_params() returns 1 if all recognised parameters were
    180      1.1  christos valid, or 0 if one of them was invalid or caused some other failure in the
    181      1.1  christos implementation.
    182      1.1  christos 
    183      1.1  christos OSSL_ENCODER_CTX_add_encoder(), OSSL_ENCODER_CTX_add_extra(),
    184      1.1  christos OSSL_ENCODER_CTX_set_construct(), OSSL_ENCODER_CTX_set_construct_data() and
    185      1.1  christos OSSL_ENCODER_CTX_set_cleanup() return 1 on success, or 0 on failure.
    186      1.1  christos 
    187      1.1  christos OSSL_ENCODER_CTX_get_num_encoders() returns the current number of encoders.
    188      1.1  christos It returns 0 if I<ctx> is NULL.
    189      1.1  christos 
    190      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder() returns an B<OSSL_ENCODER> pointer on
    191      1.1  christos success, or NULL on failure.
    192      1.1  christos 
    193      1.1  christos OSSL_ENCODER_INSTANCE_get_encoder_ctx() returns a provider context pointer on
    194      1.1  christos success, or NULL on failure.
    195      1.1  christos 
    196      1.1  christos OSSL_ENCODER_INSTANCE_get_output_type() returns a string with the name of the
    197      1.1  christos input type, if relevant.  NULL is a valid returned value.
    198      1.1  christos 
    199      1.1  christos OSSL_ENCODER_INSTANCE_get_output_type() returns a string with the name of the
    200      1.1  christos output type.
    201      1.1  christos 
    202      1.1  christos OSSL_ENCODER_INSTANCE_get_output_structure() returns a string with the name
    203      1.1  christos of the output structure.
    204      1.1  christos 
    205      1.1  christos =head1 SEE ALSO
    206      1.1  christos 
    207      1.1  christos L<provider(7)>, L<OSSL_ENCODER(3)>
    208      1.1  christos 
    209      1.1  christos =head1 HISTORY
    210      1.1  christos 
    211      1.1  christos The functions described here were added in OpenSSL 3.0.
    212      1.1  christos 
    213      1.1  christos =head1 COPYRIGHT
    214      1.1  christos 
    215  1.1.1.3  christos Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
    216      1.1  christos 
    217      1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    218      1.1  christos this file except in compliance with the License.  You can obtain a copy
    219      1.1  christos in the file LICENSE in the source distribution or at
    220      1.1  christos L<https://www.openssl.org/source/license.html>.
    221      1.1  christos 
    222      1.1  christos =cut
    223