OSSL_PARAM_BLD(3SSL)
π OSSL_PARAM_BLD β the OpenSSL param-builder glow-up π
hey bestie, you foundOSSL_PARAM_BLD(3SSL), aka the little helper gang that makes buildingOSSL_PARAMarrays not a whole ordeal. pull up a chair, we're doing this together π«Ά
β¨ NAME β¨
OSSL_PARAM_BLD, OSSL_PARAM_BLD_new, OSSL_PARAM_BLD_to_param, OSSL_PARAM_BLD_free, OSSL_PARAM_BLD_push_int, OSSL_PARAM_BLD_push_uint, OSSL_PARAM_BLD_push_long, OSSL_PARAM_BLD_push_ulong, OSSL_PARAM_BLD_push_int32, OSSL_PARAM_BLD_push_uint32, OSSL_PARAM_BLD_push_int64, OSSL_PARAM_BLD_push_uint64, OSSL_PARAM_BLD_push_size_t, OSSL_PARAM_BLD_push_time_t, OSSL_PARAM_BLD_push_double, OSSL_PARAM_BLD_push_BN, OSSL_PARAM_BLD_push_BN_pad, OSSL_PARAM_BLD_push_utf8_string, OSSL_PARAM_BLD_push_utf8_ptr, OSSL_PARAM_BLD_push_octet_string, OSSL_PARAM_BLD_push_octet_ptr β they're the functions that assist in the creation of OSSL_PARAM arrays. that's the whole job, that's the whole squad π
πΈ SYNOPSIS πΈ
#include <openssl/param_build.h>
typedef struct OSSL_PARAM_BLD;
OSSL_PARAM_BLD *OSSL_PARAM_BLD_new(void);
OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld);
void OSSL_PARAM_BLD_free(OSSL_PARAM_BLD *bld);
int OSSL_PARAM_BLD_push_TYPE(OSSL_PARAM_BLD *bld, const char *key, TYPE val);
int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn);
int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn, size_t sz);
int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
const char *buf, size_t bsize);
int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
char *buf, size_t bsize);
int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
const void *buf, size_t bsize);
int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
void *buf, size_t bsize);
π¦ DESCRIPTION π¦
okay so. it's a collection of utility functions that simplify the creation of OSSL_PARAM arrays. that's the mission statement, no notes. the TYPE names are as per OSSL_PARAM_int(3) β go check that one if you need the lineup. π
OSSL_PARAM_BLD_new()β allocates and initialises a newOSSL_PARAM_BLDstructure so that values can be added. any existing values are cleared. fresh start energy, we love that for us β¨OSSL_PARAM_BLD_free()β deallocates the memory allocates byOSSL_PARAM_BLD_new(). if the argument isNULL, nothing is done. respect. it just minds its business πOSSL_PARAM_BLD_to_param()β converts a built upOSSL_PARAM_BLDstructure bld into an allocatedOSSL_PARAMarray. theOSSL_PARAMarray and all associated storage must be freed by callingOSSL_PARAM_free(); if the contents ofOSSL_PARAMarray are confidential callOSSL_PARAM_clear_free().OSSL_PARAM_BLD_free()can safely be called any time after this function is. two separate cleanups bestie, don't mix them up πOSSL_PARAM_BLD_push_TYPE()β this is a whole series of functions which will createOSSL_PARAMobjects of the specified size and correct type for the val argument. val is stored by value and an expression or auto variable can be used. so casual, so convenient π- when
TYPEdenotes an integer type, signed integer types will normally get theOSSL_PARAMtypeOSSL_PARAM_INTEGERparams. whenTYPEdenotes an unsigned integer type will get theOSSL_PARAMtypeOSSL_PARAM_UNSIGNED_INTEGER. signed vs unsigned, the eternal vibe check β OSSL_PARAM_BLD_push_BN()β creates anOSSL_PARAMobject that holds the specifiedBIGNUMbn. when the bn is zero or positive, itsOSSL_PARAMtype becomesOSSL_PARAM_UNSIGNED_INTEGER. when the bn is negative, itsOSSL_PARAMtype becomesOSSL_PARAM_INTEGER. if bn is marked as being securely allocated, itsOSSL_PARAMrepresentation will also be securely allocated. the bn argument is stored by reference and the underlyingBIGNUMobject must exist until afterOSSL_PARAM_BLD_to_param()has been called. β οΈ by reference means by reference, bestie β if yourBIGNUMdips out early, everything falls apart. keep it alive till the conversion, fr fr.OSSL_PARAM_BLD_push_BN_pad()β creates anOSSL_PARAMobject that holds the specifiedBIGNUMbn. the object will be padded to occupy exactly sz bytes, if insufficient space is specified an error results. when the bn is zero or positive, itsOSSL_PARAMtype becomesOSSL_PARAM_UNSIGNED_INTEGER. when the bn is negative, itsOSSL_PARAMtype becomesOSSL_PARAM_INTEGER. if bn is marked as being securely allocated, itsOSSL_PARAMrepresentation will also be securely allocated. the bn argument is stored by reference and the underlyingBIGNUMobject must exist until afterOSSL_PARAM_BLD_to_param()has been called. same lifetime drama as above, just with a padding commitment πOSSL_PARAM_BLD_push_utf8_string()β creates anOSSL_PARAMobject that references the UTF8 string specified by buf. the length of the string bsize should not include the terminating NUL byte. if it is zero then it will be calculated. the string that buf points to is stored by reference and must remain in scope until afterOSSL_PARAM_BLD_to_param()has been called. π scope. until. to_param. write that down.OSSL_PARAM_BLD_push_octet_string()β creates anOSSL_PARAMobject that references the octet string specified by buf and<bsize>. the memory that buf points to is stored by reference and must remain in scope until afterOSSL_PARAM_BLD_to_param()has been called. octet bestie said "same rules" πOSSL_PARAM_BLD_push_utf8_ptr()β creates anOSSL_PARAMobject that references the UTF8 string specified by buf. the length of the string bsize should not include the terminating NUL byte. if it is zero then it will be calculated. the string buf points to is stored by reference and must remain in scope until theOSSL_PARAMarray is freed. π¨ ptr variant = longer lifetime window β not just tillto_param(), but all the way until the array itself is freed. different clock, same rules energy.OSSL_PARAM_BLD_push_octet_ptr()β creates anOSSL_PARAMobject that references the octet string specified by buf. the memory buf points to is stored by reference and must remain in scope until theOSSL_PARAMarray is freed. yeah, same extended window as the utf8 ptr one. no cap π§
π RETURN VALUES π
OSSL_PARAM_BLD_new()returns the allocatedOSSL_PARAM_BLDstructure, orNULLon error.OSSL_PARAM_BLD_to_param()returns the allocatedOSSL_PARAMarray, orNULLon error.- all of the
OSSL_PARAM_BLD_push_TYPEfunctions return1on success and0on error.
so: NULL means sad, 1 means slay, 0 means sad. got it? got it. π
π NOTES π
OSSL_PARAM_BLD_push_BN()andOSSL_PARAM_BLD_push_BN_pad()only support nonnegativeBIGNUMs. they return an error on negativeBIGNUMs. to pass signedBIGNUMs, useOSSL_PARAM_BLD_push_signed_BN().
not me learning this the hard way so you don't have to π read the note, bestie, it's there for a reason.
π EXAMPLES π
both examples creating an OSSL_PARAM array that contains an RSA key. for both, the predefined key variables are:
BIGNUM *n; /* modulus */
unsigned int e; /* public exponent */
BIGNUM *d; /* private exponent */
BIGNUM *p, *q; /* first two prime factors */
BIGNUM *dmp1, *dmq1; /* first two CRT exponents */
BIGNUM *iqmp; /* first CRT coefficient */
β¨ Example 1 β¨
this example shows how to create an OSSL_PARAM array that contains an RSA private key.
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
OSSL_PARAM *params = NULL;
if (bld == NULL
|| !OSSL_PARAM_BLD_push_BN(bld, "n", n)
|| !OSSL_PARAM_BLD_push_uint(bld, "e", e)
|| !OSSL_PARAM_BLD_push_BN(bld, "d", d)
|| !OSSL_PARAM_BLD_push_BN(bld, "rsa-factor1", p)
|| !OSSL_PARAM_BLD_push_BN(bld, "rsa-factor2", q)
|| !OSSL_PARAM_BLD_push_BN(bld, "rsa-exponent1", dmp1)
|| !OSSL_PARAM_BLD_push_BN(bld, "rsa-exponent2", dmq1)
|| !OSSL_PARAM_BLD_push_BN(bld, "rsa-coefficient1", iqmp)
|| (params = OSSL_PARAM_BLD_to_param(bld)) == NULL)
goto err;
OSSL_PARAM_BLD_free(bld);
/* Use params */
...
OSSL_PARAM_clear_free(params);
π Example 2 π
this example shows how to create an OSSL_PARAM array that contains an RSA public key.
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
OSSL_PARAM *params = NULL;
if (nld == NULL
|| !OSSL_PARAM_BLD_push_BN(bld, "n", n)
|| !OSSL_PARAM_BLD_push_uint(bld, "e", e)
|| (params = OSSL_PARAM_BLD_to_param(bld)) == NULL)
goto err;
OSSL_PARAM_BLD_free(bld);
/* Use params */
...
OSSL_PARAM_free(params);
(yes, the second one says nld β that's exactly what the page says, so it stays exactly what the page says. copy it verbatim if you're copying, bestie, it's not my business to "fix" it π
)
π₯ SEE ALSO π₯
OSSL_PARAM_int(3), OSSL_PARAM(3), OSSL_PARAM_free(3), OSSL_PARAM_clear_free(3)
β HISTORY β
the functions described here were all added in OpenSSL 3.0. glow-up era, periodt. π
π COPYRIGHT π
Copyright 2019-2026 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!! π this was OpenSSL 4.0.3, dated 2026-09-29 β go forth and build your param arrays, you absolute icon π¦β¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms