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