OSSL_PARAM_INT(3ossl)
Hey bestie, welcome to OSSL_PARAM_INT(3ossl) β the OpenSSL manual page for the whole OSSL_PARAM helper crew πΈ. Itβs giving βtiny toolkit, massive main character energy,β and every single name below is part of the page. No cap π
π NAME π
Okay so these are all the icons in this manpage, grouped so your brain doesnβt have to do cardio π«Ά
- Typed helper macros:
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 - Constructors:
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 - Locating:
OSSL_PARAM_locate,OSSL_PARAM_locate_const - Getters:
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 - Setters:
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 - Status + reset helpers:
OSSL_PARAM_UNMODIFIED,OSSL_PARAM_modified,OSSL_PARAM_set_all_unmodified
And collectively? Theyβre the OSSL_PARAM helpers πβ¨
β¨ SYNOPSIS β¨
Hereβs the exact synopsis vibe, bestie β copy it character-for-character and let it slay π¦
#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) \
{ (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);
π DESCRIPTION π
Okay bestie, gather round, because this is the little utility squad that makes OSSL_PARAM(3) arrays actually bareable β it simplifies them and adds type safety, which is the whole vibe. Here's the cast of TYPE names that are supported:
doubleintint32(int32_t)int64(int64_t)long int(long)time_tsize_tuint32(uint32_t)uint64(uint64_t)unsigned int(uint)unsigned long int(ulong)
β¨ The macros β¨
OSSL_PARAM_TYPE()β a whole series of macros designed to assist initialising an array ofOSSL_PARAM(3)structures. Each one defines a parameter of the specifiedTYPEwith the providedkeyand parameter variableaddress. Iconic, no notes.OSSL_PARAM_utf8_string(),OSSL_PARAM_octet_string(),OSSL_PARAM_utf8_ptr(),OSSL_PARAM_octet_ptr(),OSSL_PARAM_BN()β macros that provide support for defining UTF8 strings, OCTET strings and big numbers. A parameter with namekeyis defined. The storage for this parameter is ataddressand is of sizebytes.OSSL_PARAM_ENDβ provides an end of parameter list marker. This should terminate allOSSL_PARAM(3)arrays. Like, all of them, fr fr. No list is complete without it πOSSL_PARAM_DEFN()β gives you the ability to construct a singleOSSL_PARAM(3)(typically used in the construction ofOSSL_PARAMarrays). Thekey,type,addrandszarguments correspond to thekey,data_type,dataanddata_sizefields of theOSSL_PARAM(3)structure as described on theOSSL_PARAM(3)page.
π¦ The constructors π¦
OSSL_PARAM_construct_TYPE()β a series of functions that createOSSL_PARAM(3)records dynamically. A parameter with namekeyis created. The parameter will use storage pointed to bybufand return size ofret.OSSL_PARAM_construct_BN()β constructs a large integerOSSL_PARAM(3)structure. A parameter with namekey, storagebuf, sizebsizeand return sizersizeis created.OSSL_PARAM_construct_utf8_string()β constructs a UTF8 stringOSSL_PARAM(3)structure. A parameter with namekey, storagebufand sizebsizeis created. Ifbsizeis zero, the string length is determined usingstrlen(3). Generally pass zero forbsizeinstead of callingstrlen(3)yourself β let the function do her thing πOSSL_PARAM_construct_octet_string()β constructs an OCTET stringOSSL_PARAM(3)structure. A parameter with namekey, storagebufand sizebsizeis created.OSSL_PARAM_construct_utf8_ptr()β constructs a UTF8 string pointerOSSL_PARAM(3)structure. A parameter with namekey, storage pointer*bufand sizebsizeis created.OSSL_PARAM_construct_octet_ptr()β constructs an OCTET string pointerOSSL_PARAM(3)structure. A parameter with namekey, storage pointer*bufand sizebsizeis created.OSSL_PARAM_construct_end()β constructs the terminatingOSSL_PARAM(3)structure. The closer. The last one to leave the party π
π Locating stuff π
OSSL_PARAM_locate()β searches an array of parameters for the one matching the key name.OSSL_PARAM_locate_const()β behaves exactly likeOSSL_PARAM_locate()except for the presence ofconstfor the array argument and its return value. Same energy, just const-flavoured.
πΈ Getters & setters for the native types πΈ
OSSL_PARAM_get_TYPE()β retrieves a value of typeTYPEfrom the parameterp. The value is copied to the addressval. Type coercion takes place as discussed in the NOTES section.OSSL_PARAM_set_TYPE()β stores a valuevalof typeTYPEinto the parameterp. If the parameter'sdatafield isNULL, then only itsreturn_sizefield will be assigned the size the parameter'sdatabuffer should have. Type coercion takes place as discussed in the NOTES section.
π§ Big numbers π§
OSSL_PARAM_get_BN()β retrieves aBIGNUMfrom the parameter pointed to byp. TheBIGNUMreferenced byvalis updated and is allocated if*valisNULL.OSSL_PARAM_set_BN()β stores theBIGNUMvalinto the parameterp. If the parameter'sdatafield isNULL, then only itsreturn_sizefield will be assigned the size the parameter'sdatabuffer should have.
π Strings, but make it copy π
OSSL_PARAM_get_utf8_string()β retrieves a UTF8 string from the parameter pointed to byp. The string is stored into*valwith a size limit ofmax_len, which must be large enough to accommodate a terminating NUL byte, otherwise this function will fail. If*valisNULL, memory is allocated for the string (including the terminating NUL byte) andmax_lenis ignored. If memory is allocated by this function, it must be freed by the caller. Yes, that means you, bestie β don't leave her hanging πOSSL_PARAM_set_utf8_string()β sets a UTF8 string from the parameter pointed to bypto the value referenced byval. If the parameter'sdatafield isn'tNULL, itsdata_sizemust indicate that the buffer is large enough to accommodate the string thatvalpoints at, not including the terminating NUL byte, or this function will fail. A terminating NUL byte is added only if the parameter'sdata_sizeindicates the buffer is longer than the string length, otherwise the string will not be NUL terminated. If the parameter'sdatafield isNULL, then only itsreturn_sizefield will be assigned the minimum size the parameter'sdatabuffer should have to accommodate the string, not including a terminating NUL byte. That NUL-conditional is doing a LOT of work here, so read it twice πOSSL_PARAM_get_octet_string()β retrieves an OCTET string from the parameter pointed to byp. The OCTETs are either stored into*valwith a length limit ofmax_lenor, in the case when*valisNULL, memory is allocated andmax_lenis ignored.*used_lenis populated with the number of OCTETs stored. IfvalisNULLthen the OCTETs are not stored, but*used_lenis still populated. If memory is allocated by this function, it must be freed by the caller. Same deal as above, periodt.OSSL_PARAM_set_octet_string()β sets an OCTET string from the parameter pointed to bypto the value referenced byval. If the parameter'sdatafield isNULL, then only itsreturn_sizefield will be assigned the size the parameter'sdatabuffer should have.
π Pointer flavours π
OSSL_PARAM_get_utf8_ptr()β retrieves the UTF8 string pointer from the parameter referenced bypand stores it in*val.OSSL_PARAM_set_utf8_ptr()β sets the UTF8 string pointer in the parameter referenced bypto the valuesval.OSSL_PARAM_get_octet_ptr()β retrieves the OCTET string pointer from the parameter referenced bypand stores it in*val. The length of the OCTET string is stored in*used_len.OSSL_PARAM_set_octet_ptr()β sets the OCTET string pointer in the parameter referenced bypto the valuesval. The length of the OCTET string is provided byused_len.
π Pointer-to-string, no copying allowed π
OSSL_PARAM_get_utf8_string_ptr()β retrieves the pointer to a UTF8 string from the parameter pointed to byp, and stores that pointer in*val. This is different fromOSSL_PARAM_get_utf8_string(), which copies the string.OSSL_PARAM_get_octet_string_ptr()β retrieves the pointer to a octet string from the parameter pointed to byp, and stores that pointer in*val, along with the string's length in*used_len. This is different fromOSSL_PARAM_get_octet_string(), which copies the string.
π The "was it even set tho?" squad π
OSSL_PARAM_UNMODIFIEDβ macro used to detect if a parameter was set. On creation, via either the macros or construct calls, thereturn_sizefield is set to this. If the parameter is set using the calls defined herein, thereturn_sizefield is changed.OSSL_PARAM_modified()β queries if the parameterparamhas been set or not using the calls defined herein.OSSL_PARAM_set_all_unmodified()β resets the unused indicator for all parameters in the arrayparams.
β RETURN VALUES β
OSSL_PARAM_construct_TYPE(),OSSL_PARAM_construct_BN(),OSSL_PARAM_construct_utf8_string(),OSSL_PARAM_construct_octet_string(),OSSL_PARAM_construct_utf8_ptr()andOSSL_PARAM_construct_octet_ptr()β return a populatedOSSL_PARAM(3)structure. She's ready, she's filled in, she's serving π«ΆOSSL_PARAM_locate()andOSSL_PARAM_locate_const()β return a pointer to the matchingOSSL_PARAM(3)object. They returnNULLon error or when no object matchingkeyexists in the array.OSSL_PARAM_modified()β returns1if the parameter was set and0otherwise.- All other functions β return
1on success and0on failure.
π 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. So no funny business with lossy conversions, bestie β if it doesn't fit exactly, it's not happening.
OSSL_PARAM_get_BN() and OSSL_PARAM_set_BN() only support nonnegative BIGNUMs when the desired data type is OSSL_PARAM_UNSIGNED_INTEGER. OSSL_PARAM_construct_BN() currently constructs an OSSL_PARAM(3) structure with the data type OSSL_PARAM_UNSIGNED_INTEGER.
For OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_consstruct_octet_ptr() β yes, that's literally how it's spelled in the source, three s's and all, she's quirky like that π
β bsize is not relevant if the purpose is to send the OSSL_PARAM(3) array to a responder, i.e. to get parameter data back. In that case, bsize can safely be given zero. See "DESCRIPTION" in OSSL_PARAM(3) for further information on the possible purposes.
Quick vibe check: those two pointer constructors only let you skip bsize in the "asking a responder for data" scenario. Any other purpose, and zero is not automatically your friend. Don't @ me, that's just what the page says π
π EXAMPLES π
Reusing the examples from OSSL_PARAM(3) to just show how OSSL_PARAM(3) arrays can be handled using the macros and functions defined herein. We're literally recycling, it's sustainable, mother earth is obsessed πΈ
Example 1
This example is for setting parameters on some object:
#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
};
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 β you can be picky, it's allowed:
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
};
A responder that receives this array (as params in this example) could fill in the parameters like this:
/* 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");
π¦ SEE ALSO π¦
openssl-core.h(7), OSSL_PARAM(3)
β¨ HISTORY β¨
These APIs were introduced in OpenSSL 3.0. So they're not new new, but they're still that girl.
π COPYRIGHT π
Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
And that's the whole page, bestie β go forth and construct your params with type safety and main character energy π Shoutout to the 3.5.0 docs drop, dated 2026-09-25, living under the page name OSSL_PARAM_INT(3ossl). Slay π
π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms