| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "OSSL_PARAM_INT 3SSL" |
| 58 |
.TH OSSL_PARAM_INT 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
OSSL_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64, |
| 65 |
OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_time_t, OSSL_PARAM_uint, |
| 66 |
OSSL_PARAM_uint32, OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN, |
| 67 |
OSSL_PARAM_utf8_string, OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr, |
| 68 |
OSSL_PARAM_octet_ptr, |
| 69 |
OSSL_PARAM_END, OSSL_PARAM_DEFN, |
| 70 |
OSSL_PARAM_construct_double, OSSL_PARAM_construct_int, |
| 71 |
OSSL_PARAM_construct_int32, OSSL_PARAM_construct_int64, |
| 72 |
OSSL_PARAM_construct_long, OSSL_PARAM_construct_size_t, |
| 73 |
OSSL_PARAM_construct_time_t, OSSL_PARAM_construct_uint, |
| 74 |
OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64, |
| 75 |
OSSL_PARAM_construct_ulong, OSSL_PARAM_construct_BN, |
| 76 |
OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr, |
| 77 |
OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr, |
| 78 |
OSSL_PARAM_construct_end, |
| 79 |
OSSL_PARAM_locate, OSSL_PARAM_locate_const, |
| 80 |
OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32, |
| 81 |
OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t, |
| 82 |
OSSL_PARAM_get_time_t, OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32, |
| 83 |
OSSL_PARAM_get_uint64, OSSL_PARAM_get_ulong, OSSL_PARAM_get_BN, |
| 84 |
OSSL_PARAM_get_utf8_string, OSSL_PARAM_get_octet_string, |
| 85 |
OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_get_octet_ptr, |
| 86 |
OSSL_PARAM_get_utf8_string_ptr, OSSL_PARAM_get_octet_string_ptr, |
| 87 |
OSSL_PARAM_set_double, OSSL_PARAM_set_int, OSSL_PARAM_set_int32, |
| 88 |
OSSL_PARAM_set_int64, OSSL_PARAM_set_long, OSSL_PARAM_set_size_t, |
| 89 |
OSSL_PARAM_set_time_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32, |
| 90 |
OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_set_BN, |
| 91 |
OSSL_PARAM_set_utf8_string, OSSL_PARAM_set_octet_string, |
| 92 |
OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_set_octet_ptr, |
| 93 |
OSSL_PARAM_set_octet_string_or_ptr, |
| 94 |
OSSL_PARAM_UNMODIFIED, OSSL_PARAM_modified, OSSL_PARAM_set_all_unmodified |
| 95 |
\&\- OSSL_PARAM helpers |
| 96 |
.SH SYNOPSIS |
| 97 |
.IX Header "SYNOPSIS" |
| 98 |
.Vb 1 |
| 99 |
\& #include <openssl/params.h> |
| 100 |
\& |
| 101 |
\& /* |
| 102 |
\& * TYPE in function names is one of: |
| 103 |
\& * double, int, int32, int64, long, size_t, time_t, uint, uint32, uint64, ulong |
| 104 |
\& * Corresponding TYPE in function arguments is one of: |
| 105 |
\& * double, int, int32_t, int64_t, long, size_t, time_t, unsigned int, uint32_t, |
| 106 |
\& * uint64_t, unsigned long |
| 107 |
\& */ |
| 108 |
\& |
| 109 |
\& #define OSSL_PARAM_TYPE(key, address) |
| 110 |
\& #define OSSL_PARAM_BN(key, address, size) |
| 111 |
\& #define OSSL_PARAM_utf8_string(key, address, size) |
| 112 |
\& #define OSSL_PARAM_octet_string(key, address, size) |
| 113 |
\& #define OSSL_PARAM_utf8_ptr(key, address, size) |
| 114 |
\& #define OSSL_PARAM_octet_ptr(key, address, size) |
| 115 |
\& #define OSSL_PARAM_END |
| 116 |
\& |
| 117 |
\& #define OSSL_PARAM_UNMODIFIED |
| 118 |
\& |
| 119 |
\& #define OSSL_PARAM_DEFN(key, type, addr, sz) \e |
| 120 |
\& { (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED } |
| 121 |
\& |
| 122 |
\& OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf); |
| 123 |
\& OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, |
| 124 |
\& size_t bsize); |
| 125 |
\& OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, |
| 126 |
\& size_t bsize); |
| 127 |
\& OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, |
| 128 |
\& size_t bsize); |
| 129 |
\& OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, |
| 130 |
\& size_t bsize); |
| 131 |
\& OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, |
| 132 |
\& size_t bsize); |
| 133 |
\& OSSL_PARAM OSSL_PARAM_construct_end(void); |
| 134 |
\& |
| 135 |
\& OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key); |
| 136 |
\& const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array, |
| 137 |
\& const char *key); |
| 138 |
\& |
| 139 |
\& int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, TYPE *val); |
| 140 |
\& int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, TYPE val); |
| 141 |
\& |
| 142 |
\& int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val); |
| 143 |
\& int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val); |
| 144 |
\& |
| 145 |
\& int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, |
| 146 |
\& size_t max_len); |
| 147 |
\& int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); |
| 148 |
\& |
| 149 |
\& int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, |
| 150 |
\& size_t max_len, size_t *used_len); |
| 151 |
\& int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); |
| 152 |
\& |
| 153 |
\& int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); |
| 154 |
\& int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val); |
| 155 |
\& |
| 156 |
\& int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, |
| 157 |
\& size_t *used_len); |
| 158 |
\& int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, |
| 159 |
\& size_t used_len); |
| 160 |
\& |
| 161 |
\& int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val); |
| 162 |
\& int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, |
| 163 |
\& size_t *used_len); |
| 164 |
\& |
| 165 |
\& int OSSL_PARAM_modified(const OSSL_PARAM *param); |
| 166 |
\& void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *params); |
| 167 |
.Ve |
| 168 |
.PP |
| 169 |
int OSSL_PARAM_set_octet_string_or_ptr(OSSL_PARAM *p, const void *val, |
| 170 |
size_t len); |
| 171 |
.SH DESCRIPTION |
| 172 |
.IX Header "DESCRIPTION" |
| 173 |
A collection of utility functions that simplify and add type safety to the |
| 174 |
\&\fBOSSL_PARAM\fR\|(3) arrays. The following \fR\f(BITYPE\fR\fB\fR names are supported: |
| 175 |
.IP \(bu 2 |
| 176 |
double |
| 177 |
.IP \(bu 2 |
| 178 |
int |
| 179 |
.IP \(bu 2 |
| 180 |
int32 (int32_t) |
| 181 |
.IP \(bu 2 |
| 182 |
int64 (int64_t) |
| 183 |
.IP \(bu 2 |
| 184 |
long int (long) |
| 185 |
.IP \(bu 2 |
| 186 |
time_t |
| 187 |
.IP \(bu 2 |
| 188 |
size_t |
| 189 |
.IP \(bu 2 |
| 190 |
uint32 (uint32_t) |
| 191 |
.IP \(bu 2 |
| 192 |
uint64 (uint64_t) |
| 193 |
.IP \(bu 2 |
| 194 |
unsigned int (uint) |
| 195 |
.IP \(bu 2 |
| 196 |
unsigned long int (ulong) |
| 197 |
.PP |
| 198 |
\&\fBOSSL_PARAM_TYPE()\fR are a series of macros designed to assist initialising an |
| 199 |
array of \fBOSSL_PARAM\fR\|(3) structures. |
| 200 |
Each of these macros defines a parameter of the specified \fR\f(BITYPE\fR\fB\fR with the |
| 201 |
provided \fIkey\fR and parameter variable \fIaddress\fR. |
| 202 |
.PP |
| 203 |
\&\fBOSSL_PARAM_utf8_string()\fR, \fBOSSL_PARAM_octet_string()\fR, \fBOSSL_PARAM_utf8_ptr()\fR, |
| 204 |
\&\fBOSSL_PARAM_octet_ptr()\fR, \fBOSSL_PARAM_BN()\fR are macros that provide support |
| 205 |
for defining UTF8 strings, OCTET strings and big numbers. |
| 206 |
A parameter with name \fIkey\fR is defined. |
| 207 |
The storage for this parameter is at \fIaddress\fR and is of \fIsize\fR bytes. |
| 208 |
.PP |
| 209 |
OSSL_PARAM_END provides an end of parameter list marker. |
| 210 |
This should terminate all \fBOSSL_PARAM\fR\|(3) arrays. |
| 211 |
.PP |
| 212 |
The \fBOSSL_PARAM_DEFN()\fR macro provides the ability to construct a single |
| 213 |
\&\fBOSSL_PARAM\fR\|(3) (typically used in the construction of \fBOSSL_PARAM\fR arrays). The |
| 214 |
\&\fIkey\fR, \fItype\fR, \fIaddr\fR and \fIsz\fR arguments correspond to the \fIkey\fR, |
| 215 |
\&\fIdata_type\fR, \fIdata\fR and \fIdata_size\fR fields of the \fBOSSL_PARAM\fR\|(3) structure as |
| 216 |
described on the \fBOSSL_PARAM\fR\|(3) page. |
| 217 |
.PP |
| 218 |
\&\fBOSSL_PARAM_construct_TYPE()\fR are a series of functions that create \fBOSSL_PARAM\fR\|(3) |
| 219 |
records dynamically. |
| 220 |
A parameter with name \fIkey\fR is created. |
| 221 |
The parameter will use storage pointed to by \fIbuf\fR and return size of \fIret\fR. |
| 222 |
.PP |
| 223 |
\&\fBOSSL_PARAM_construct_BN()\fR is a function that constructs a large integer |
| 224 |
\&\fBOSSL_PARAM\fR\|(3) structure. |
| 225 |
A parameter with name \fIkey\fR, storage \fIbuf\fR, size \fIbsize\fR and return |
| 226 |
size \fIrsize\fR is created. |
| 227 |
.PP |
| 228 |
\&\fBOSSL_PARAM_construct_utf8_string()\fR is a function that constructs a UTF8 |
| 229 |
string \fBOSSL_PARAM\fR\|(3) structure. |
| 230 |
A parameter with name \fIkey\fR, storage \fIbuf\fR and size \fIbsize\fR is created. |
| 231 |
If \fIbsize\fR is zero, the string length is determined using \fBstrlen\fR\|(3). |
| 232 |
Generally pass zero for \fIbsize\fR instead of calling \fBstrlen\fR\|(3) yourself. |
| 233 |
.PP |
| 234 |
\&\fBOSSL_PARAM_construct_octet_string()\fR is a function that constructs an OCTET |
| 235 |
string \fBOSSL_PARAM\fR\|(3) structure. |
| 236 |
A parameter with name \fIkey\fR, storage \fIbuf\fR and size \fIbsize\fR is created. |
| 237 |
.PP |
| 238 |
\&\fBOSSL_PARAM_construct_utf8_ptr()\fR is a function that constructs a UTF8 string |
| 239 |
pointer \fBOSSL_PARAM\fR\|(3) structure. |
| 240 |
A parameter with name \fIkey\fR, storage pointer \fI*buf\fR and size \fIbsize\fR |
| 241 |
is created. |
| 242 |
.PP |
| 243 |
\&\fBOSSL_PARAM_construct_octet_ptr()\fR is a function that constructs an OCTET string |
| 244 |
pointer \fBOSSL_PARAM\fR\|(3) structure. |
| 245 |
A parameter with name \fIkey\fR, storage pointer \fI*buf\fR and size \fIbsize\fR |
| 246 |
is created. |
| 247 |
.PP |
| 248 |
\&\fBOSSL_PARAM_construct_end()\fR is a function that constructs the terminating |
| 249 |
\&\fBOSSL_PARAM\fR\|(3) structure. |
| 250 |
.PP |
| 251 |
\&\fBOSSL_PARAM_locate()\fR is a function that searches an \fIarray\fR of parameters for |
| 252 |
the one matching the \fIkey\fR name. |
| 253 |
.PP |
| 254 |
\&\fBOSSL_PARAM_locate_const()\fR behaves exactly like \fBOSSL_PARAM_locate()\fR except for |
| 255 |
the presence of \fIconst\fR for the \fIarray\fR argument and its return value. |
| 256 |
.PP |
| 257 |
\&\fBOSSL_PARAM_get_TYPE()\fR retrieves a value of type \fR\f(BITYPE\fR\fB\fR from the parameter |
| 258 |
\&\fIp\fR. |
| 259 |
The value is copied to the address \fIval\fR. |
| 260 |
Type coercion takes place as discussed in the NOTES section. |
| 261 |
.PP |
| 262 |
\&\fBOSSL_PARAM_set_TYPE()\fR stores a value \fIval\fR of type \fR\f(BITYPE\fR\fB\fR into the |
| 263 |
parameter \fIp\fR. |
| 264 |
If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field |
| 265 |
will be assigned the size the parameter's \fIdata\fR buffer should have. |
| 266 |
Type coercion takes place as discussed in the NOTES section. |
| 267 |
.PP |
| 268 |
\&\fBOSSL_PARAM_get_BN()\fR retrieves a BIGNUM from the parameter pointed to by \fIp\fR. |
| 269 |
The BIGNUM referenced by \fIval\fR is updated and is allocated if \fI*val\fR is |
| 270 |
NULL. |
| 271 |
.PP |
| 272 |
\&\fBOSSL_PARAM_set_BN()\fR stores the BIGNUM \fIval\fR into the parameter \fIp\fR. |
| 273 |
If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field |
| 274 |
will be assigned the size the parameter's \fIdata\fR buffer should have. |
| 275 |
.PP |
| 276 |
\&\fBOSSL_PARAM_get_utf8_string()\fR retrieves a UTF8 string from the parameter |
| 277 |
pointed to by \fIp\fR. |
| 278 |
The string is stored into \fI*val\fR with a size limit of \fImax_len\fR, |
| 279 |
which must be large enough to accommodate a terminating NUL byte, |
| 280 |
otherwise this function will fail. |
| 281 |
If \fI*val\fR is NULL, memory is allocated for the string (including the |
| 282 |
terminating NUL byte) and \fImax_len\fR is ignored. |
| 283 |
If memory is allocated by this function, it must be freed by the caller. |
| 284 |
.PP |
| 285 |
\&\fBOSSL_PARAM_set_utf8_string()\fR sets a UTF8 string from the parameter pointed to |
| 286 |
by \fIp\fR to the value referenced by \fIval\fR. |
| 287 |
If the parameter's \fIdata\fR field isn't NULL, its \fIdata_size\fR must indicate |
| 288 |
that the buffer is large enough to accommodate the string that \fIval\fR points at, |
| 289 |
not including the terminating NUL byte, or this function will fail. |
| 290 |
A terminating NUL byte is added only if the parameter's \fIdata_size\fR indicates |
| 291 |
the buffer is longer than the string length, otherwise the string will not be |
| 292 |
NUL terminated. |
| 293 |
If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field |
| 294 |
will be assigned the minimum size the parameter's \fIdata\fR buffer should have |
| 295 |
to accommodate the string, not including a terminating NUL byte. |
| 296 |
.PP |
| 297 |
\&\fBOSSL_PARAM_get_octet_string()\fR retrieves an OCTET string from the parameter |
| 298 |
pointed to by \fIp\fR. |
| 299 |
The OCTETs are either stored into \fI*val\fR with a length limit of \fImax_len\fR or, |
| 300 |
in the case when \fI*val\fR is NULL, memory is allocated and |
| 301 |
\&\fImax_len\fR is ignored. \fI*used_len\fR is populated with the number of OCTETs |
| 302 |
stored. If \fIval\fR is NULL then the OCTETS are not stored, but \fI*used_len\fR is |
| 303 |
still populated. |
| 304 |
If memory is allocated by this function, it must be freed by the caller. |
| 305 |
.PP |
| 306 |
\&\fBOSSL_PARAM_set_octet_string()\fR sets an OCTET string from the parameter |
| 307 |
pointed to by \fIp\fR to the value referenced by \fIval\fR. |
| 308 |
If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field |
| 309 |
will be assigned the size the parameter's \fIdata\fR buffer should have. |
| 310 |
.PP |
| 311 |
\&\fBOSSL_PARAM_get_utf8_ptr()\fR retrieves the UTF8 string pointer from the parameter |
| 312 |
referenced by \fIp\fR and stores it in \fI*val\fR. |
| 313 |
.PP |
| 314 |
\&\fBOSSL_PARAM_set_utf8_ptr()\fR sets the UTF8 string pointer in the parameter |
| 315 |
referenced by \fIp\fR to the values \fIval\fR. |
| 316 |
.PP |
| 317 |
\&\fBOSSL_PARAM_get_octet_ptr()\fR retrieves the OCTET string pointer from the parameter |
| 318 |
referenced by \fIp\fR and stores it in \fI*val\fR. |
| 319 |
The length of the OCTET string is stored in \fI*used_len\fR. |
| 320 |
.PP |
| 321 |
\&\fBOSSL_PARAM_set_octet_ptr()\fR sets the OCTET string pointer in the parameter |
| 322 |
referenced by \fIp\fR to the values \fIval\fR. |
| 323 |
The length of the OCTET string is provided by \fIused_len\fR. |
| 324 |
.PP |
| 325 |
\&\fBOSSL_PARAM_get_utf8_string_ptr()\fR retrieves the pointer to a UTF8 string from |
| 326 |
the parameter pointed to by \fIp\fR, and stores that pointer in \fI*val\fR. |
| 327 |
This is different from \fBOSSL_PARAM_get_utf8_string()\fR, which copies the |
| 328 |
string. |
| 329 |
.PP |
| 330 |
\&\fBOSSL_PARAM_get_octet_string_ptr()\fR retrieves the pointer to a octet string |
| 331 |
from the parameter pointed to by \fIp\fR, and stores that pointer in \fI*val\fR, |
| 332 |
along with the string's length in \fI*used_len\fR. |
| 333 |
This is different from \fBOSSL_PARAM_get_octet_string()\fR, which copies the |
| 334 |
string. |
| 335 |
.PP |
| 336 |
The OSSL_PARAM_UNMODIFIED macro is used to detect if a parameter was set. On |
| 337 |
creation, via either the macros or construct calls, the \fIreturn_size\fR field |
| 338 |
is set to this. If the parameter is set using the calls defined herein, the |
| 339 |
\&\fIreturn_size\fR field is changed. |
| 340 |
.PP |
| 341 |
\&\fBOSSL_PARAM_modified()\fR queries if the parameter \fIparam\fR has been set or not |
| 342 |
using the calls defined herein. |
| 343 |
.PP |
| 344 |
\&\fBOSSL_PARAM_set_all_unmodified()\fR resets the unused indicator for all parameters |
| 345 |
in the array \fIparams\fR. |
| 346 |
.PP |
| 347 |
\&\fBOSSL_PARAM_set_octet_string_or_ptr()\fR sets an OCTET string or string pointer |
| 348 |
from the parameter pointed to by \fIp\fR to the value referenced by \fIval\fR. If |
| 349 |
\&\fIp\fR is an OCTET string and the parameter's \fIdata\fR field is NULL, then only |
| 350 |
its \fIreturn_size\fR field will be assigned the size the parameter's \fIdata\fR |
| 351 |
buffer should have. The length of the OCTET string is provided by \fIlen\fR. |
| 352 |
.SH "RETURN VALUES" |
| 353 |
.IX Header "RETURN VALUES" |
| 354 |
\&\fBOSSL_PARAM_construct_TYPE()\fR, \fBOSSL_PARAM_construct_BN()\fR, |
| 355 |
\&\fBOSSL_PARAM_construct_utf8_string()\fR, \fBOSSL_PARAM_construct_octet_string()\fR, |
| 356 |
\&\fBOSSL_PARAM_construct_utf8_ptr()\fR and \fBOSSL_PARAM_construct_octet_ptr()\fR |
| 357 |
return a populated \fBOSSL_PARAM\fR\|(3) structure. |
| 358 |
.PP |
| 359 |
\&\fBOSSL_PARAM_locate()\fR and \fBOSSL_PARAM_locate_const()\fR return a pointer to |
| 360 |
the matching \fBOSSL_PARAM\fR\|(3) object. They return NULL on error or when |
| 361 |
no object matching \fIkey\fR exists in the \fIarray\fR. |
| 362 |
.PP |
| 363 |
\&\fBOSSL_PARAM_modified()\fR returns 1 if the parameter was set and 0 otherwise. |
| 364 |
.PP |
| 365 |
All other functions return 1 on success and 0 on failure. |
| 366 |
.SH NOTES |
| 367 |
.IX Header "NOTES" |
| 368 |
Native types will be converted as required only if the value is exactly |
| 369 |
representable by the target type or parameter. |
| 370 |
Apart from that, the functions must be used appropriately for the |
| 371 |
expected type of the parameter. |
| 372 |
.PP |
| 373 |
\&\fBOSSL_PARAM_get_BN()\fR and \fBOSSL_PARAM_set_BN()\fR only support nonnegative |
| 374 |
\&\fBBIGNUM\fRs when the desired data type is \fBOSSL_PARAM_UNSIGNED_INTEGER\fR. |
| 375 |
\&\fBOSSL_PARAM_construct_BN()\fR currently constructs an \fBOSSL_PARAM\fR\|(3) structure |
| 376 |
with the data type \fBOSSL_PARAM_UNSIGNED_INTEGER\fR. |
| 377 |
.PP |
| 378 |
For \fBOSSL_PARAM_construct_utf8_ptr()\fR and \fBOSSL_PARAM_consstruct_octet_ptr()\fR, |
| 379 |
\&\fIbsize\fR is not relevant if the purpose is to send the \fBOSSL_PARAM\fR\|(3) array |
| 380 |
to a \fIresponder\fR, i.e. to get parameter data back. |
| 381 |
In that case, \fIbsize\fR can safely be given zero. |
| 382 |
See "DESCRIPTION" in \fBOSSL_PARAM\fR\|(3) for further information on the |
| 383 |
possible purposes. |
| 384 |
.SH EXAMPLES |
| 385 |
.IX Header "EXAMPLES" |
| 386 |
Reusing the examples from \fBOSSL_PARAM\fR\|(3) to just show how |
| 387 |
\&\fBOSSL_PARAM\fR\|(3) arrays can be handled using the macros and functions |
| 388 |
defined herein. |
| 389 |
.SS "Example 1" |
| 390 |
.IX Subsection "Example 1" |
| 391 |
This example is for setting parameters on some object: |
| 392 |
.PP |
| 393 |
.Vb 1 |
| 394 |
\& #include <openssl/core.h> |
| 395 |
\& |
| 396 |
\& const char *foo = "some string"; |
| 397 |
\& size_t foo_l = strlen(foo); |
| 398 |
\& const char bar[] = "some other string"; |
| 399 |
\& const OSSL_PARAM set[] = { |
| 400 |
\& OSSL_PARAM_utf8_ptr("foo", &foo, foo_l), |
| 401 |
\& OSSL_PARAM_utf8_string("bar", bar, sizeof(bar) \- 1), |
| 402 |
\& OSSL_PARAM_END |
| 403 |
\& }; |
| 404 |
.Ve |
| 405 |
.SS "Example 2" |
| 406 |
.IX Subsection "Example 2" |
| 407 |
This example is for requesting parameters on some object, and also |
| 408 |
demonstrates that the requester isn't obligated to request all |
| 409 |
available parameters: |
| 410 |
.PP |
| 411 |
.Vb 7 |
| 412 |
\& const char *foo = NULL; |
| 413 |
\& char bar[1024]; |
| 414 |
\& OSSL_PARAM request[] = { |
| 415 |
\& OSSL_PARAM_utf8_ptr("foo", &foo, 0), |
| 416 |
\& OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)), |
| 417 |
\& OSSL_PARAM_END |
| 418 |
\& }; |
| 419 |
.Ve |
| 420 |
.PP |
| 421 |
A \fIresponder\fR that receives this array (as \f(CW\*(C`params\*(C'\fR in this example) |
| 422 |
could fill in the parameters like this: |
| 423 |
.PP |
| 424 |
.Vb 1 |
| 425 |
\& /* OSSL_PARAM *params */ |
| 426 |
\& |
| 427 |
\& OSSL_PARAM *p; |
| 428 |
\& |
| 429 |
\& if ((p = OSSL_PARAM_locate(params, "foo")) != NULL) |
| 430 |
\& OSSL_PARAM_set_utf8_ptr(p, "foo value"); |
| 431 |
\& if ((p = OSSL_PARAM_locate(params, "bar")) != NULL) |
| 432 |
\& OSSL_PARAM_set_utf8_string(p, "bar value"); |
| 433 |
\& if ((p = OSSL_PARAM_locate(params, "cookie")) != NULL) |
| 434 |
\& OSSL_PARAM_set_utf8_ptr(p, "cookie value"); |
| 435 |
.Ve |
| 436 |
.SS "Example 3" |
| 437 |
.IX Subsection "Example 3" |
| 438 |
This example shows a special case where |
| 439 |
\&\fI\-Wincompatible\-pointer\-types\-discards\-qualifiers\fR may be set during |
| 440 |
compilation. The value for \fIbuf\fR cannot be a \fIconst char *\fR type string. An |
| 441 |
alternative in this case would be to use \fBOSSL_PARAM\fR macro abbreviated calls |
| 442 |
rather than the specific callers which allows you to define the sha1 argument |
| 443 |
as a standard character array (\fIchar[]\fR). |
| 444 |
.PP |
| 445 |
For example, this code: |
| 446 |
.PP |
| 447 |
.Vb 3 |
| 448 |
\& OSSL_PARAM params[2]; |
| 449 |
\& params[0] = OSSL_PARAM_construct_utf8_string("digest", "SHA1", 0); |
| 450 |
\& params[1] = OSSL_PARAM_construct_end(); |
| 451 |
.Ve |
| 452 |
.PP |
| 453 |
Can be made compatible with the following version: |
| 454 |
.PP |
| 455 |
.Vb 2 |
| 456 |
\& char sha1[] = "SHA1"; /* sha1 is defined as char[] in this case */ |
| 457 |
\& OSSL_PARAM params[2]; |
| 458 |
\& |
| 459 |
\& params[0] = OSSL_PARAM_construct_utf8_string("digest", sha1, 0); |
| 460 |
\& params[1] = OSSL_PARAM_construct_end(); |
| 461 |
.Ve |
| 462 |
.SH "SEE ALSO" |
| 463 |
.IX Header "SEE ALSO" |
| 464 |
\&\fBopenssl\-core.h\fR\|(7), \fBOSSL_PARAM\fR\|(3) |
| 465 |
.SH HISTORY |
| 466 |
.IX Header "HISTORY" |
| 467 |
These functions were added in OpenSSL 3.0. |
| 468 |
.PP |
| 469 |
OSSL_PARAM_set_octet_string_or_ptr was added in OpenSSL 3.6. |
| 470 |
.SH COPYRIGHT |
| 471 |
.IX Header "COPYRIGHT" |
| 472 |
Copyright 2019\-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 473 |
.PP |
| 474 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 475 |
this file except in compliance with the License. You can obtain a copy |
| 476 |
in the file LICENSE in the source distribution or at |
| 477 |
<https://www.openssl.org/source/license.html>. |