xref: /freebsd/secure/lib/libcrypto/man/man3/OSSL_PARAM_int.3 (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "OSSL_PARAM_INT 3ossl"
OSSL_PARAM_INT 3ossl "2023-09-19" "3.0.11" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
OSSL_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64, OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_time_t, OSSL_PARAM_uint, OSSL_PARAM_uint32, OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN, OSSL_PARAM_utf8_string, OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr, OSSL_PARAM_octet_ptr, OSSL_PARAM_END, OSSL_PARAM_DEFN, OSSL_PARAM_construct_double, OSSL_PARAM_construct_int, OSSL_PARAM_construct_int32, OSSL_PARAM_construct_int64, OSSL_PARAM_construct_long, OSSL_PARAM_construct_size_t, OSSL_PARAM_construct_time_t, OSSL_PARAM_construct_uint, OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64, OSSL_PARAM_construct_ulong, OSSL_PARAM_construct_BN, OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr, OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr, OSSL_PARAM_construct_end, OSSL_PARAM_locate, OSSL_PARAM_locate_const, OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32, OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t, OSSL_PARAM_get_time_t, OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32, OSSL_PARAM_get_uint64, OSSL_PARAM_get_ulong, OSSL_PARAM_get_BN, OSSL_PARAM_get_utf8_string, OSSL_PARAM_get_octet_string, OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_get_octet_ptr, OSSL_PARAM_get_utf8_string_ptr, OSSL_PARAM_get_octet_string_ptr, OSSL_PARAM_set_double, OSSL_PARAM_set_int, OSSL_PARAM_set_int32, OSSL_PARAM_set_int64, OSSL_PARAM_set_long, OSSL_PARAM_set_size_t, OSSL_PARAM_set_time_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32, OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_set_BN, OSSL_PARAM_set_utf8_string, OSSL_PARAM_set_octet_string, OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_set_octet_ptr, OSSL_PARAM_UNMODIFIED, OSSL_PARAM_modified, OSSL_PARAM_set_all_unmodified \- OSSL_PARAM helpers
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/params.h> \& /* * TYPE in function names is one of: * double, int, int32, int64, long, size_t, time_t, uint, uint32, uint64, ulong * Corresponding TYPE in function arguments is one of: * double, int, int32_t, int64_t, long, size_t, time_t, unsigned int, uint32_t, * uint64_t, unsigned long */ \& #define OSSL_PARAM_TYPE(key, address) #define OSSL_PARAM_BN(key, address, size) #define OSSL_PARAM_utf8_string(key, address, size) #define OSSL_PARAM_octet_string(key, address, size) #define OSSL_PARAM_utf8_ptr(key, address, size) #define OSSL_PARAM_octet_ptr(key, address, size) #define OSSL_PARAM_END \& #define OSSL_PARAM_UNMODIFIED \& #define OSSL_PARAM_DEFN(key, type, addr, sz) \e { (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED } \& OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf); OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, size_t bsize); OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, size_t bsize); OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, size_t bsize); OSSL_PARAM OSSL_PARAM_construct_end(void); \& OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key); const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array, const char *key); \& int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, TYPE *val); int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, TYPE val); \& int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val); int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val); \& int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); \& int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, size_t *used_len); int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); \& int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val); \& int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len); int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, size_t used_len); \& int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val); int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len); \& int OSSL_PARAM_modified(const OSSL_PARAM *param); void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *params); .Ve
"DESCRIPTION"
Header "DESCRIPTION" A collection of utility functions that simplify and add type safety to the \s-1OSSL_PARAM\s0\|(3) arrays. The following \f(BI\s-1TYPE\s0 names are supported:
"\(bu" 1
double
"\(bu" 1
int
"\(bu" 1
int32 (int32_t)
"\(bu" 1
int64 (int64_t)
"\(bu" 1
long int (long)
"\(bu" 1
time_t
"\(bu" 1
size_t
"\(bu" 1
uint32 (uint32_t)
"\(bu" 1
uint64 (uint64_t)
"\(bu" 1
unsigned int (uint)
"\(bu" 1
unsigned long int (ulong)

\s-1OSSL_PARAM_TYPE\s0() are a series of macros designed to assist initialising an array of \s-1OSSL_PARAM\s0\|(3) structures. Each of these macros defines a parameter of the specified \f(BI\s-1TYPE\s0 with the provided key and parameter variable address.

\fBOSSL_PARAM_utf8_string(), OSSL_PARAM_octet_string(), OSSL_PARAM_utf8_ptr(), \fBOSSL_PARAM_octet_ptr(), \s-1OSSL_PARAM_BN\s0() are macros that provide support for defining \s-1UTF8\s0 strings, \s-1OCTET\s0 strings and big numbers. A parameter with name key is defined. The storage for this parameter is at address and is of size bytes.

\s-1OSSL_PARAM_END\s0 provides an end of parameter list marker. This should terminate all \s-1OSSL_PARAM\s0\|(3) arrays.

The \s-1OSSL_PARAM_DEFN\s0() macro provides the ability to construct a single \s-1OSSL_PARAM\s0\|(3) (typically used in the construction of \s-1OSSL_PARAM\s0 arrays). The \fIkey, type, addr and sz arguments correspond to the key, \fIdata_type, data and data_size fields of the \s-1OSSL_PARAM\s0\|(3) structure as described on the \s-1OSSL_PARAM\s0\|(3) page.

\fBOSSL_PARAM_construct_TYPE() are a series of functions that create \s-1OSSL_PARAM\s0\|(3) records dynamically. A parameter with name key is created. The parameter will use storage pointed to by buf and return size of ret.

\fBOSSL_PARAM_construct_BN() is a function that constructs a large integer \s-1OSSL_PARAM\s0\|(3) structure. A parameter with name key, storage buf, size bsize and return size rsize is created.

\fBOSSL_PARAM_construct_utf8_string() is a function that constructs a \s-1UTF8\s0 string \s-1OSSL_PARAM\s0\|(3) structure. A parameter with name key, storage buf and size bsize is created. If bsize is zero, the string length is determined using strlen\|(3). Generally pass zero for bsize instead of calling strlen\|(3) yourself.

\fBOSSL_PARAM_construct_octet_string() is a function that constructs an \s-1OCTET\s0 string \s-1OSSL_PARAM\s0\|(3) structure. A parameter with name key, storage buf and size bsize is created.

\fBOSSL_PARAM_construct_utf8_ptr() is a function that constructs a \s-1UTF8\s0 string pointer \s-1OSSL_PARAM\s0\|(3) structure. A parameter with name key, storage pointer *buf and size bsize is created.

\fBOSSL_PARAM_construct_octet_ptr() is a function that constructs an \s-1OCTET\s0 string pointer \s-1OSSL_PARAM\s0\|(3) structure. A parameter with name key, storage pointer *buf and size bsize is created.

\fBOSSL_PARAM_construct_end() is a function that constructs the terminating \s-1OSSL_PARAM\s0\|(3) structure.

\fBOSSL_PARAM_locate() is a function that searches an array of parameters for the one matching the key name.

\fBOSSL_PARAM_locate_const() behaves exactly like OSSL_PARAM_locate() except for the presence of const for the array argument and its return value.

\fBOSSL_PARAM_get_TYPE() retrieves a value of type \f(BI\s-1TYPE\s0 from the parameter \fIp. The value is copied to the address val. Type coercion takes place as discussed in the \s-1NOTES\s0 section.

\fBOSSL_PARAM_set_TYPE() stores a value val of type \f(BI\s-1TYPE\s0 into the parameter p. If the parameter's data field is \s-1NULL,\s0 then only its return_size field will be assigned the size the parameter's data buffer should have. Type coercion takes place as discussed in the \s-1NOTES\s0 section.

\fBOSSL_PARAM_get_BN() retrieves a \s-1BIGNUM\s0 from the parameter pointed to by p. The \s-1BIGNUM\s0 referenced by val is updated and is allocated if *val is \s-1NULL.\s0

\fBOSSL_PARAM_set_BN() stores the \s-1BIGNUM\s0 val into the parameter p. If the parameter's data field is \s-1NULL,\s0 then only its return_size field will be assigned the size the parameter's data buffer should have.

\fBOSSL_PARAM_get_utf8_string() retrieves a \s-1UTF8\s0 string from the parameter pointed to by p. The string is stored into *val with a size limit of max_len, which must be large enough to accommodate a terminating \s-1NUL\s0 byte, otherwise this function will fail. If *val is \s-1NULL,\s0 memory is allocated for the string (including the terminating \s-1NUL\s0 byte) and max_len is ignored. If memory is allocated by this function, it must be freed by the caller.

\fBOSSL_PARAM_set_utf8_string() sets a \s-1UTF8\s0 string from the parameter pointed to by p to the value referenced by val. If the parameter's data field isn't \s-1NULL,\s0 its data_size must indicate that the buffer is large enough to accommodate the string that val points at, not including the terminating \s-1NUL\s0 byte, or this function will fail. A terminating \s-1NUL\s0 byte is added only if the parameter's data_size indicates the buffer is longer than the string length, otherwise the string will not be \s-1NUL\s0 terminated. If the parameter's data field is \s-1NULL,\s0 then only its return_size field will be assigned the minimum size the parameter's data buffer should have to accommodate the string, not including a terminating \s-1NUL\s0 byte.

\fBOSSL_PARAM_get_octet_string() retrieves an \s-1OCTET\s0 string from the parameter pointed to by p. The OCTETs are either stored into *val with a length limit of max_len or, in the case when *val is \s-1NULL,\s0 memory is allocated and \fImax_len is ignored. *used_len is populated with the number of OCTETs stored. If val is \s-1NULL\s0 then the \s-1OCTETS\s0 are not stored, but *used_len is still populated. If memory is allocated by this function, it must be freed by the caller.

\fBOSSL_PARAM_set_octet_string() sets an \s-1OCTET\s0 string from the parameter pointed to by p to the value referenced by val. If the parameter's data field is \s-1NULL,\s0 then only its return_size field will be assigned the size the parameter's data buffer should have.

\fBOSSL_PARAM_get_utf8_ptr() retrieves the \s-1UTF8\s0 string pointer from the parameter referenced by p and stores it in *val.

\fBOSSL_PARAM_set_utf8_ptr() sets the \s-1UTF8\s0 string pointer in the parameter referenced by p to the values val.

\fBOSSL_PARAM_get_octet_ptr() retrieves the \s-1OCTET\s0 string pointer from the parameter referenced by p and stores it in *val. The length of the \s-1OCTET\s0 string is stored in *used_len.

\fBOSSL_PARAM_set_octet_ptr() sets the \s-1OCTET\s0 string pointer in the parameter referenced by p to the values val. The length of the \s-1OCTET\s0 string is provided by used_len.

\fBOSSL_PARAM_get_utf8_string_ptr() retrieves the pointer to a \s-1UTF8\s0 string from the parameter pointed to by p, and stores that pointer in *val. This is different from OSSL_PARAM_get_utf8_string(), which copies the string.

\fBOSSL_PARAM_get_octet_string_ptr() retrieves the pointer to a octet string from the parameter pointed to by p, and stores that pointer in *val, along with the string's length in *used_len. This is different from OSSL_PARAM_get_octet_string(), which copies the string.

The \s-1OSSL_PARAM_UNMODIFIED\s0 macro is used to detect if a parameter was set. On creation, via either the macros or construct calls, the return_size field is set to this. If the parameter is set using the calls defined herein, the \fIreturn_size field is changed.

\fBOSSL_PARAM_modified() queries if the parameter param has been set or not using the calls defined herein.

\fBOSSL_PARAM_set_all_unmodified() resets the unused indicator for all parameters in the array params.

"RETURN VALUES"
Header "RETURN VALUES" \fBOSSL_PARAM_construct_TYPE(), OSSL_PARAM_construct_BN(), \fBOSSL_PARAM_construct_utf8_string(), OSSL_PARAM_construct_octet_string(), \fBOSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_construct_octet_ptr() return a populated \s-1OSSL_PARAM\s0\|(3) structure.

\fBOSSL_PARAM_locate() and OSSL_PARAM_locate_const() return a pointer to the matching \s-1OSSL_PARAM\s0\|(3) object. They return \s-1NULL\s0 on error or when no object matching key exists in the array.

\fBOSSL_PARAM_modified() returns 1 if the parameter was set and 0 otherwise.

All other functions return 1 on success and 0 on failure.

"NOTES"
Header "NOTES" Native types will be converted as required only if the value is exactly representable by the target type or parameter. Apart from that, the functions must be used appropriately for the expected type of the parameter.

\fBOSSL_PARAM_get_BN() and OSSL_PARAM_set_BN() currently only support nonnegative \s-1BIGNUM\s0s, and by consequence, only \fB\s-1OSSL_PARAM_UNSIGNED_INTEGER\s0. OSSL_PARAM_construct_BN() currently constructs an \s-1OSSL_PARAM\s0\|(3) structure with the data type \fB\s-1OSSL_PARAM_UNSIGNED_INTEGER\s0.

For OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_consstruct_octet_ptr(), \fIbsize is not relevant if the purpose is to send the \s-1OSSL_PARAM\s0\|(3) array to a responder, i.e. to get parameter data back. In that case, bsize can safely be given zero. See \*(L"\s-1DESCRIPTION\*(R"\s0 in \s-1OSSL_PARAM\s0\|(3) for further information on the possible purposes.

"EXAMPLES"
Header "EXAMPLES" Reusing the examples from \s-1OSSL_PARAM\s0\|(3) to just show how \s-1OSSL_PARAM\s0\|(3) arrays can be handled using the macros and functions defined herein.
"Example 1"
Subsection "Example 1" This example is for setting parameters on some object:

.Vb 1 #include <openssl/core.h> \& const char *foo = "some string"; size_t foo_l = strlen(foo); const char bar[] = "some other string"; const OSSL_PARAM set[] = { OSSL_PARAM_utf8_ptr("foo", &foo, foo_l), OSSL_PARAM_utf8_string("bar", bar, sizeof(bar) - 1), OSSL_PARAM_END }; .Ve

"Example 2"
Subsection "Example 2" This example is for requesting parameters on some object, and also demonstrates that the requester isn't obligated to request all available parameters:

.Vb 7 const char *foo = NULL; char bar[1024]; OSSL_PARAM request[] = { OSSL_PARAM_utf8_ptr("foo", &foo, 0), OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)), OSSL_PARAM_END }; .Ve

A responder that receives this array (as \*(C`params\*(C' in this example) could fill in the parameters like this:

.Vb 1 /* OSSL_PARAM *params */ \& OSSL_PARAM *p; \& if ((p = OSSL_PARAM_locate(params, "foo")) != NULL) OSSL_PARAM_set_utf8_ptr(p, "foo value"); if ((p = OSSL_PARAM_locate(params, "bar")) != NULL) OSSL_PARAM_set_utf8_string(p, "bar value"); if ((p = OSSL_PARAM_locate(params, "cookie")) != NULL) OSSL_PARAM_set_utf8_ptr(p, "cookie value"); .Ve

"SEE ALSO"
Header "SEE ALSO" \fBopenssl-core.h\|(7), \s-1OSSL_PARAM\s0\|(3)
"HISTORY"
Header "HISTORY" These APIs were introduced in OpenSSL 3.0.
"COPYRIGHT"
Header "COPYRIGHT" Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.