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_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64,
      6      1.1  christos OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_time_t, OSSL_PARAM_uint,
      7      1.1  christos OSSL_PARAM_uint32, OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN,
      8      1.1  christos OSSL_PARAM_utf8_string, OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr,
      9      1.1  christos OSSL_PARAM_octet_ptr,
     10      1.1  christos OSSL_PARAM_END, OSSL_PARAM_DEFN,
     11      1.1  christos OSSL_PARAM_construct_double, OSSL_PARAM_construct_int,
     12      1.1  christos OSSL_PARAM_construct_int32, OSSL_PARAM_construct_int64,
     13      1.1  christos OSSL_PARAM_construct_long, OSSL_PARAM_construct_size_t,
     14      1.1  christos OSSL_PARAM_construct_time_t, OSSL_PARAM_construct_uint,
     15      1.1  christos OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64,
     16      1.1  christos OSSL_PARAM_construct_ulong, OSSL_PARAM_construct_BN,
     17      1.1  christos OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr,
     18      1.1  christos OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr,
     19      1.1  christos OSSL_PARAM_construct_end,
     20      1.1  christos OSSL_PARAM_locate, OSSL_PARAM_locate_const,
     21      1.1  christos OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32,
     22      1.1  christos OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t,
     23      1.1  christos OSSL_PARAM_get_time_t, OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32,
     24      1.1  christos OSSL_PARAM_get_uint64, OSSL_PARAM_get_ulong, OSSL_PARAM_get_BN,
     25      1.1  christos OSSL_PARAM_get_utf8_string, OSSL_PARAM_get_octet_string,
     26      1.1  christos OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_get_octet_ptr,
     27      1.1  christos OSSL_PARAM_get_utf8_string_ptr, OSSL_PARAM_get_octet_string_ptr,
     28      1.1  christos OSSL_PARAM_set_double, OSSL_PARAM_set_int, OSSL_PARAM_set_int32,
     29      1.1  christos OSSL_PARAM_set_int64, OSSL_PARAM_set_long, OSSL_PARAM_set_size_t,
     30      1.1  christos OSSL_PARAM_set_time_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32,
     31      1.1  christos OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_set_BN,
     32      1.1  christos OSSL_PARAM_set_utf8_string, OSSL_PARAM_set_octet_string,
     33      1.1  christos OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_set_octet_ptr,
     34      1.1  christos OSSL_PARAM_UNMODIFIED, OSSL_PARAM_modified, OSSL_PARAM_set_all_unmodified
     35      1.1  christos - OSSL_PARAM helpers
     36      1.1  christos 
     37      1.1  christos =head1 SYNOPSIS
     38      1.1  christos 
     39      1.1  christos =for openssl generic
     40      1.1  christos 
     41      1.1  christos  #include <openssl/params.h>
     42      1.1  christos 
     43      1.1  christos  /*
     44      1.1  christos   * TYPE in function names is one of:
     45      1.1  christos   * double, int, int32, int64, long, size_t, time_t, uint, uint32, uint64, ulong
     46      1.1  christos   * Corresponding TYPE in function arguments is one of:
     47      1.1  christos   * double, int, int32_t, int64_t, long, size_t, time_t, unsigned int, uint32_t,
     48      1.1  christos   * uint64_t, unsigned long
     49      1.1  christos   */
     50      1.1  christos 
     51      1.1  christos  #define OSSL_PARAM_TYPE(key, address)
     52      1.1  christos  #define OSSL_PARAM_BN(key, address, size)
     53      1.1  christos  #define OSSL_PARAM_utf8_string(key, address, size)
     54      1.1  christos  #define OSSL_PARAM_octet_string(key, address, size)
     55      1.1  christos  #define OSSL_PARAM_utf8_ptr(key, address, size)
     56      1.1  christos  #define OSSL_PARAM_octet_ptr(key, address, size)
     57      1.1  christos  #define OSSL_PARAM_END
     58      1.1  christos 
     59      1.1  christos  #define OSSL_PARAM_UNMODIFIED
     60      1.1  christos 
     61      1.1  christos  #define OSSL_PARAM_DEFN(key, type, addr, sz)    \
     62      1.1  christos     { (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED }
     63      1.1  christos 
     64      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf);
     65      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
     66      1.1  christos                                     size_t bsize);
     67      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
     68      1.1  christos                                              size_t bsize);
     69      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
     70      1.1  christos                                               size_t bsize);
     71      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
     72      1.1  christos                                           size_t bsize);
     73      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
     74      1.1  christos                                            size_t bsize);
     75      1.1  christos  OSSL_PARAM OSSL_PARAM_construct_end(void);
     76      1.1  christos 
     77      1.1  christos  OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key);
     78      1.1  christos  const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array,
     79      1.1  christos                                            const char *key);
     80      1.1  christos 
     81      1.1  christos  int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, TYPE *val);
     82      1.1  christos  int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, TYPE val);
     83      1.1  christos 
     84      1.1  christos  int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val);
     85      1.1  christos  int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val);
     86      1.1  christos 
     87      1.1  christos  int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val,
     88      1.1  christos                                 size_t max_len);
     89      1.1  christos  int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val);
     90      1.1  christos 
     91      1.1  christos  int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val,
     92      1.1  christos                                  size_t max_len, size_t *used_len);
     93      1.1  christos  int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len);
     94      1.1  christos 
     95      1.1  christos  int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val);
     96      1.1  christos  int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val);
     97      1.1  christos 
     98      1.1  christos  int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
     99      1.1  christos                               size_t *used_len);
    100      1.1  christos  int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val,
    101      1.1  christos                               size_t used_len);
    102      1.1  christos 
    103      1.1  christos  int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val);
    104      1.1  christos  int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val,
    105      1.1  christos                                      size_t *used_len);
    106      1.1  christos 
    107      1.1  christos  int OSSL_PARAM_modified(const OSSL_PARAM *param);
    108      1.1  christos  void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *params);
    109      1.1  christos 
    110      1.1  christos =head1 DESCRIPTION
    111      1.1  christos 
    112      1.1  christos A collection of utility functions that simplify and add type safety to the
    113      1.1  christos L<OSSL_PARAM(3)> arrays.  The following B<I<TYPE>> names are supported:
    114      1.1  christos 
    115  1.1.1.4  christos =over 2
    116      1.1  christos 
    117      1.1  christos =item *
    118      1.1  christos 
    119      1.1  christos double
    120      1.1  christos 
    121      1.1  christos =item *
    122      1.1  christos 
    123      1.1  christos int
    124      1.1  christos 
    125      1.1  christos =item *
    126      1.1  christos 
    127      1.1  christos int32 (int32_t)
    128      1.1  christos 
    129      1.1  christos =item *
    130      1.1  christos 
    131      1.1  christos int64 (int64_t)
    132      1.1  christos 
    133      1.1  christos =item *
    134      1.1  christos 
    135      1.1  christos long int (long)
    136      1.1  christos 
    137      1.1  christos =item *
    138      1.1  christos 
    139      1.1  christos time_t
    140      1.1  christos 
    141      1.1  christos =item *
    142      1.1  christos 
    143      1.1  christos size_t
    144      1.1  christos 
    145      1.1  christos =item *
    146      1.1  christos 
    147      1.1  christos uint32 (uint32_t)
    148      1.1  christos 
    149      1.1  christos =item *
    150      1.1  christos 
    151      1.1  christos uint64 (uint64_t)
    152      1.1  christos 
    153      1.1  christos =item *
    154      1.1  christos 
    155      1.1  christos unsigned int (uint)
    156      1.1  christos 
    157      1.1  christos =item *
    158      1.1  christos 
    159      1.1  christos unsigned long int (ulong)
    160      1.1  christos 
    161      1.1  christos =back
    162      1.1  christos 
    163      1.1  christos OSSL_PARAM_TYPE() are a series of macros designed to assist initialising an
    164      1.1  christos array of L<OSSL_PARAM(3)> structures.
    165      1.1  christos Each of these macros defines a parameter of the specified B<I<TYPE>> with the
    166      1.1  christos provided I<key> and parameter variable I<address>.
    167      1.1  christos 
    168      1.1  christos OSSL_PARAM_utf8_string(), OSSL_PARAM_octet_string(), OSSL_PARAM_utf8_ptr(),
    169      1.1  christos OSSL_PARAM_octet_ptr(), OSSL_PARAM_BN() are macros that provide support
    170      1.1  christos for defining UTF8 strings, OCTET strings and big numbers.
    171      1.1  christos A parameter with name I<key> is defined.
    172      1.1  christos The storage for this parameter is at I<address> and is of I<size> bytes.
    173      1.1  christos 
    174      1.1  christos OSSL_PARAM_END provides an end of parameter list marker.
    175      1.1  christos This should terminate all L<OSSL_PARAM(3)> arrays.
    176      1.1  christos 
    177      1.1  christos The OSSL_PARAM_DEFN() macro provides the ability to construct a single
    178      1.1  christos L<OSSL_PARAM(3)> (typically used in the construction of B<OSSL_PARAM> arrays). The
    179      1.1  christos I<key>, I<type>, I<addr> and I<sz> arguments correspond to the I<key>,
    180      1.1  christos I<data_type>, I<data> and I<data_size> fields of the L<OSSL_PARAM(3)> structure as
    181      1.1  christos described on the L<OSSL_PARAM(3)> page.
    182      1.1  christos 
    183      1.1  christos OSSL_PARAM_construct_TYPE() are a series of functions that create L<OSSL_PARAM(3)>
    184      1.1  christos records dynamically.
    185      1.1  christos A parameter with name I<key> is created.
    186      1.1  christos The parameter will use storage pointed to by I<buf> and return size of I<ret>.
    187      1.1  christos 
    188      1.1  christos OSSL_PARAM_construct_BN() is a function that constructs a large integer
    189      1.1  christos L<OSSL_PARAM(3)> structure.
    190      1.1  christos A parameter with name I<key>, storage I<buf>, size I<bsize> and return
    191      1.1  christos size I<rsize> is created.
    192      1.1  christos 
    193      1.1  christos OSSL_PARAM_construct_utf8_string() is a function that constructs a UTF8
    194      1.1  christos string L<OSSL_PARAM(3)> structure.
    195      1.1  christos A parameter with name I<key>, storage I<buf> and size I<bsize> is created.
    196      1.1  christos If I<bsize> is zero, the string length is determined using strlen(3).
    197      1.1  christos Generally pass zero for I<bsize> instead of calling strlen(3) yourself.
    198      1.1  christos 
    199      1.1  christos OSSL_PARAM_construct_octet_string() is a function that constructs an OCTET
    200      1.1  christos string L<OSSL_PARAM(3)> structure.
    201      1.1  christos A parameter with name I<key>, storage I<buf> and size I<bsize> is created.
    202      1.1  christos 
    203      1.1  christos OSSL_PARAM_construct_utf8_ptr() is a function that constructs a UTF8 string
    204      1.1  christos pointer L<OSSL_PARAM(3)> structure.
    205      1.1  christos A parameter with name I<key>, storage pointer I<*buf> and size I<bsize>
    206      1.1  christos is created.
    207      1.1  christos 
    208      1.1  christos OSSL_PARAM_construct_octet_ptr() is a function that constructs an OCTET string
    209      1.1  christos pointer L<OSSL_PARAM(3)> structure.
    210      1.1  christos A parameter with name I<key>, storage pointer I<*buf> and size I<bsize>
    211      1.1  christos is created.
    212      1.1  christos 
    213      1.1  christos OSSL_PARAM_construct_end() is a function that constructs the terminating
    214      1.1  christos L<OSSL_PARAM(3)> structure.
    215      1.1  christos 
    216      1.1  christos OSSL_PARAM_locate() is a function that searches an I<array> of parameters for
    217      1.1  christos the one matching the I<key> name.
    218      1.1  christos 
    219      1.1  christos OSSL_PARAM_locate_const() behaves exactly like OSSL_PARAM_locate() except for
    220      1.1  christos the presence of I<const> for the I<array> argument and its return value.
    221      1.1  christos 
    222      1.1  christos OSSL_PARAM_get_TYPE() retrieves a value of type B<I<TYPE>> from the parameter
    223      1.1  christos I<p>.
    224      1.1  christos The value is copied to the address I<val>.
    225      1.1  christos Type coercion takes place as discussed in the NOTES section.
    226      1.1  christos 
    227      1.1  christos OSSL_PARAM_set_TYPE() stores a value I<val> of type B<I<TYPE>> into the
    228      1.1  christos parameter I<p>.
    229      1.1  christos If the parameter's I<data> field is NULL, then only its I<return_size> field
    230      1.1  christos will be assigned the size the parameter's I<data> buffer should have.
    231      1.1  christos Type coercion takes place as discussed in the NOTES section.
    232      1.1  christos 
    233      1.1  christos OSSL_PARAM_get_BN() retrieves a BIGNUM from the parameter pointed to by I<p>.
    234      1.1  christos The BIGNUM referenced by I<val> is updated and is allocated if I<*val> is
    235      1.1  christos NULL.
    236      1.1  christos 
    237      1.1  christos OSSL_PARAM_set_BN() stores the BIGNUM I<val> into the parameter I<p>.
    238      1.1  christos If the parameter's I<data> field is NULL, then only its I<return_size> field
    239      1.1  christos will be assigned the size the parameter's I<data> buffer should have.
    240      1.1  christos 
    241      1.1  christos OSSL_PARAM_get_utf8_string() retrieves a UTF8 string from the parameter
    242      1.1  christos pointed to by I<p>.
    243      1.1  christos The string is stored into I<*val> with a size limit of I<max_len>,
    244  1.1.1.3  christos which must be large enough to accommodate a terminating NUL byte,
    245      1.1  christos otherwise this function will fail.
    246      1.1  christos If I<*val> is NULL, memory is allocated for the string (including the
    247      1.1  christos terminating  NUL byte) and I<max_len> is ignored.
    248      1.1  christos If memory is allocated by this function, it must be freed by the caller.
    249      1.1  christos 
    250      1.1  christos OSSL_PARAM_set_utf8_string() sets a UTF8 string from the parameter pointed to
    251      1.1  christos by I<p> to the value referenced by I<val>.
    252      1.1  christos If the parameter's I<data> field isn't NULL, its I<data_size> must indicate
    253  1.1.1.3  christos that the buffer is large enough to accommodate the string that I<val> points at,
    254      1.1  christos not including the terminating NUL byte, or this function will fail.
    255      1.1  christos A terminating NUL byte is added only if the parameter's I<data_size> indicates
    256      1.1  christos the buffer is longer than the string length, otherwise the string will not be
    257      1.1  christos NUL terminated.
    258      1.1  christos If the parameter's I<data> field is NULL, then only its I<return_size> field
    259      1.1  christos will be assigned the minimum size the parameter's I<data> buffer should have
    260  1.1.1.3  christos to accommodate the string, not including a terminating NUL byte.
    261      1.1  christos 
    262      1.1  christos OSSL_PARAM_get_octet_string() retrieves an OCTET string from the parameter
    263      1.1  christos pointed to by I<p>.
    264      1.1  christos The OCTETs are either stored into I<*val> with a length limit of I<max_len> or,
    265      1.1  christos in the case when I<*val> is NULL, memory is allocated and
    266      1.1  christos I<max_len> is ignored. I<*used_len> is populated with the number of OCTETs
    267      1.1  christos stored. If I<val> is NULL then the OCTETS are not stored, but I<*used_len> is
    268      1.1  christos still populated.
    269      1.1  christos If memory is allocated by this function, it must be freed by the caller.
    270      1.1  christos 
    271      1.1  christos OSSL_PARAM_set_octet_string() sets an OCTET string from the parameter
    272      1.1  christos pointed to by I<p> to the value referenced by I<val>.
    273      1.1  christos If the parameter's I<data> field is NULL, then only its I<return_size> field
    274      1.1  christos will be assigned the size the parameter's I<data> buffer should have.
    275      1.1  christos 
    276      1.1  christos OSSL_PARAM_get_utf8_ptr() retrieves the UTF8 string pointer from the parameter
    277      1.1  christos referenced by I<p> and stores it in I<*val>.
    278      1.1  christos 
    279      1.1  christos OSSL_PARAM_set_utf8_ptr() sets the UTF8 string pointer in the parameter
    280      1.1  christos referenced by I<p> to the values I<val>.
    281      1.1  christos 
    282      1.1  christos OSSL_PARAM_get_octet_ptr() retrieves the OCTET string pointer from the parameter
    283      1.1  christos referenced by I<p> and stores it in I<*val>.
    284      1.1  christos The length of the OCTET string is stored in I<*used_len>.
    285      1.1  christos 
    286      1.1  christos OSSL_PARAM_set_octet_ptr() sets the OCTET string pointer in the parameter
    287      1.1  christos referenced by I<p> to the values I<val>.
    288      1.1  christos The length of the OCTET string is provided by I<used_len>.
    289      1.1  christos 
    290      1.1  christos OSSL_PARAM_get_utf8_string_ptr() retrieves the pointer to a UTF8 string from
    291      1.1  christos the parameter pointed to by I<p>, and stores that pointer in I<*val>.
    292      1.1  christos This is different from OSSL_PARAM_get_utf8_string(), which copies the
    293      1.1  christos string.
    294      1.1  christos 
    295      1.1  christos OSSL_PARAM_get_octet_string_ptr() retrieves the pointer to a octet string
    296      1.1  christos from the parameter pointed to by I<p>, and stores that pointer in I<*val>,
    297      1.1  christos along with the string's length in I<*used_len>.
    298      1.1  christos This is different from OSSL_PARAM_get_octet_string(), which copies the
    299      1.1  christos string.
    300      1.1  christos 
    301      1.1  christos The OSSL_PARAM_UNMODIFIED macro is used to detect if a parameter was set.  On
    302      1.1  christos creation, via either the macros or construct calls, the I<return_size> field
    303      1.1  christos is set to this.  If the parameter is set using the calls defined herein, the
    304      1.1  christos I<return_size> field is changed.
    305      1.1  christos 
    306      1.1  christos OSSL_PARAM_modified() queries if the parameter I<param> has been set or not
    307      1.1  christos using the calls defined herein.
    308      1.1  christos 
    309      1.1  christos OSSL_PARAM_set_all_unmodified() resets the unused indicator for all parameters
    310      1.1  christos in the array I<params>.
    311      1.1  christos 
    312      1.1  christos =head1 RETURN VALUES
    313      1.1  christos 
    314      1.1  christos OSSL_PARAM_construct_TYPE(), OSSL_PARAM_construct_BN(),
    315      1.1  christos OSSL_PARAM_construct_utf8_string(), OSSL_PARAM_construct_octet_string(),
    316      1.1  christos OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_construct_octet_ptr()
    317      1.1  christos return a populated L<OSSL_PARAM(3)> structure.
    318      1.1  christos 
    319      1.1  christos OSSL_PARAM_locate() and OSSL_PARAM_locate_const() return a pointer to
    320      1.1  christos the matching L<OSSL_PARAM(3)> object.  They return NULL on error or when
    321      1.1  christos no object matching I<key> exists in the I<array>.
    322      1.1  christos 
    323      1.1  christos OSSL_PARAM_modified() returns 1 if the parameter was set and 0 otherwise.
    324      1.1  christos 
    325      1.1  christos All other functions return 1 on success and 0 on failure.
    326      1.1  christos 
    327      1.1  christos =head1 NOTES
    328      1.1  christos 
    329      1.1  christos Native types will be converted as required only if the value is exactly
    330      1.1  christos representable by the target type or parameter.
    331      1.1  christos Apart from that, the functions must be used appropriately for the
    332      1.1  christos expected type of the parameter.
    333      1.1  christos 
    334      1.1  christos OSSL_PARAM_get_BN() and OSSL_PARAM_set_BN() currently only support
    335      1.1  christos nonnegative B<BIGNUM>s, and by consequence, only
    336      1.1  christos B<OSSL_PARAM_UNSIGNED_INTEGER>.  OSSL_PARAM_construct_BN() currently
    337      1.1  christos constructs an L<OSSL_PARAM(3)> structure with the data type
    338      1.1  christos B<OSSL_PARAM_UNSIGNED_INTEGER>.
    339      1.1  christos 
    340      1.1  christos For OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_consstruct_octet_ptr(),
    341      1.1  christos I<bsize> is not relevant if the purpose is to send the L<OSSL_PARAM(3)> array
    342      1.1  christos to a I<responder>, i.e. to get parameter data back.
    343      1.1  christos In that case, I<bsize> can safely be given zero.
    344      1.1  christos See L<OSSL_PARAM(3)/DESCRIPTION> for further information on the
    345      1.1  christos possible purposes.
    346      1.1  christos 
    347      1.1  christos =head1 EXAMPLES
    348      1.1  christos 
    349      1.1  christos Reusing the examples from L<OSSL_PARAM(3)> to just show how
    350      1.1  christos L<OSSL_PARAM(3)> arrays can be handled using the macros and functions
    351      1.1  christos defined herein.
    352      1.1  christos 
    353      1.1  christos =head2 Example 1
    354      1.1  christos 
    355      1.1  christos This example is for setting parameters on some object:
    356      1.1  christos 
    357      1.1  christos     #include <openssl/core.h>
    358      1.1  christos 
    359      1.1  christos     const char *foo = "some string";
    360      1.1  christos     size_t foo_l = strlen(foo);
    361      1.1  christos     const char bar[] = "some other string";
    362      1.1  christos     const OSSL_PARAM set[] = {
    363      1.1  christos         OSSL_PARAM_utf8_ptr("foo", &foo, foo_l),
    364      1.1  christos         OSSL_PARAM_utf8_string("bar", bar, sizeof(bar) - 1),
    365      1.1  christos         OSSL_PARAM_END
    366      1.1  christos     };
    367      1.1  christos 
    368      1.1  christos =head2 Example 2
    369      1.1  christos 
    370      1.1  christos This example is for requesting parameters on some object, and also
    371  1.1.1.2  christos demonstrates that the requester isn't obligated to request all
    372      1.1  christos available parameters:
    373      1.1  christos 
    374      1.1  christos     const char *foo = NULL;
    375      1.1  christos     char bar[1024];
    376      1.1  christos     OSSL_PARAM request[] = {
    377      1.1  christos         OSSL_PARAM_utf8_ptr("foo", &foo, 0),
    378      1.1  christos         OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)),
    379      1.1  christos         OSSL_PARAM_END
    380      1.1  christos     };
    381      1.1  christos 
    382      1.1  christos A I<responder> that receives this array (as C<params> in this example)
    383      1.1  christos could fill in the parameters like this:
    384      1.1  christos 
    385      1.1  christos     /* OSSL_PARAM *params */
    386      1.1  christos 
    387      1.1  christos     OSSL_PARAM *p;
    388      1.1  christos 
    389      1.1  christos     if ((p = OSSL_PARAM_locate(params, "foo")) != NULL)
    390      1.1  christos         OSSL_PARAM_set_utf8_ptr(p, "foo value");
    391      1.1  christos     if ((p = OSSL_PARAM_locate(params, "bar")) != NULL)
    392      1.1  christos         OSSL_PARAM_set_utf8_string(p, "bar value");
    393      1.1  christos     if ((p = OSSL_PARAM_locate(params, "cookie")) != NULL)
    394      1.1  christos         OSSL_PARAM_set_utf8_ptr(p, "cookie value");
    395      1.1  christos 
    396      1.1  christos =head1 SEE ALSO
    397      1.1  christos 
    398      1.1  christos L<openssl-core.h(7)>, L<OSSL_PARAM(3)>
    399      1.1  christos 
    400      1.1  christos =head1 HISTORY
    401      1.1  christos 
    402      1.1  christos These APIs were introduced in OpenSSL 3.0.
    403      1.1  christos 
    404      1.1  christos =head1 COPYRIGHT
    405      1.1  christos 
    406  1.1.1.2  christos Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
    407      1.1  christos 
    408      1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    409      1.1  christos this file except in compliance with the License.  You can obtain a copy
    410      1.1  christos in the file LICENSE in the source distribution or at
    411      1.1  christos L<https://www.openssl.org/source/license.html>.
    412      1.1  christos 
    413      1.1  christos =cut
    414