Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) 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
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). 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 3" OSSL_PARAM 3 "2023-05-30" "3.0.9" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes way too many mistakes in technical documents. "NAME"
OSSL_PARAM - a structure to pass or request object parameters
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1
#include <
openssl/
core.h>
\&
typedef struct ossl_param_st OSSL_PARAM;
struct ossl_param_st {
const char *key; /* the name of the parameter */
unsigned char data_type; /* declare what kind of content is in data */
void *data; /* value being passed in or out */
size_t data_size; /* data size */
size_t return_size; /* returned size */
};
.Ve
"DESCRIPTION"
Header "DESCRIPTION" \fB\s-1OSSL_PARAM\s0 is a type that allows passing arbitrary data for some
object between two parties that have no or very little shared
knowledge about their respective internal structures for that object.
A typical usage example could be an application that wants to set some
parameters for an object, or wants to find out some parameters of an
object.
Arrays of this type can be used for the following purposes:
"\(bu" 4
Setting parameters for some object
.Sp
The caller sets up the
\s-1OSSL_PARAM\s0 array and calls some function
(the
setter) that has intimate knowledge about the object that can
take the data from the
\s-1OSSL_PARAM\s0 array and assign them in a
suitable form for the internal structure of the object.
"\(bu" 4
Request parameters of some object
.Sp
The caller (the
requester) sets up the
\s-1OSSL_PARAM\s0 array and
calls some function (the
responder) that has intimate knowledge
about the object, which can take the internal data of the object and
copy (possibly convert) that to the memory prepared by the
\fIrequester and pointed at with the
\s-1OSSL_PARAM\s0 data.
"\(bu" 4
Request parameter descriptors
.Sp
The caller gets an array of constant
\s-1OSSL_PARAM\s0, which describe
available parameters and some of their properties; name, data type and
expected data size.
For a detailed description of each field for this use, see the field
descriptions below.
.Sp
The caller may then use the information from this descriptor array to
build up its own
\s-1OSSL_PARAM\s0 array to pass down to a
setter or
\fIresponder.
Normally, the order of the an \s-1OSSL_PARAM\s0 array is not relevant.
However, if the responder can handle multiple elements with the
same key, those elements must be handled in the order they are in.
An \s-1OSSL_PARAM\s0 array must have a terminating element, where key
is \s-1NULL.\s0 The usual full terminating template is:
.Vb 1
{ NULL, 0, NULL, 0, 0 }
.Ve
This can also be specified using \s-1OSSL_PARAM_END\s0\|(3).
"Functional support"
Subsection "Functional support" Libcrypto offers a limited set of helper functions to handle
\fB\s-1OSSL_PARAM\s0 items and arrays, please see
OSSL_PARAM_get_int\|(3).
Developers are free to extend or replace those as they see fit.
"\s-1OSSL_PARAM\s0 fields"
Subsection "OSSL_PARAM fields" "key" 4
Item "key" The identity of the parameter in the form of a string.
.Sp
In an
\s-1OSSL_PARAM\s0 array, an item with this field set to \s-1NULL\s0 is
considered a terminating item.
"data_type" 4
Item "data_type" The
data_type is a value that describes the type and organization of
the data.
See \*(L"Supported types\*(R" below for a description of the types.
"data" 4
Item "data" 0
"data_size" 4
Item "data_size"
\fIdata is a pointer to the memory where the parameter data is (when
setting parameters) or shall (when requesting parameters) be stored,
and data_size is its size in bytes.
The organization of the data depends on the parameter type and flag.
.Sp
The data_size needs special attention with the parameter type
\fB\s-1OSSL_PARAM_UTF8_STRING\s0 in relation to C strings. When setting
parameters, the size should be set to the length of the string, not
counting the terminating \s-1NUL\s0 byte. When requesting parameters, the
size should be set to the size of the buffer to be populated, which
should accomodate enough space for a terminating \s-1NUL\s0 byte.
.Sp
When requesting parameters, it's acceptable for data to be \s-1NULL.\s0
This can be used by the requester to figure out dynamically exactly
how much buffer space is needed to store the parameter data.
In this case, data_size is ignored.
.Sp
When the \s-1OSSL_PARAM\s0 is used as a parameter descriptor, data
should be ignored.
If data_size is zero, it means that an arbitrary data size is
accepted, otherwise it specifies the maximum size allowed.
"return_size" 4
Item "return_size" When an array of
\s-1OSSL_PARAM\s0 is used to request data, the
\fIresponder must set this field to indicate size of the parameter
data, including padding as the case may be.
In case the
data_size is an unsuitable size for the data, the
\fIresponder must still set this field to indicate the minimum data
size required.
(further notes on this in \*(L"\s-1NOTES\*(R"\s0 below).
.Sp
When the
\s-1OSSL_PARAM\s0 is used as a parameter descriptor,
\fIreturn_size should be ignored.
\fB\s-1NOTE:\s0
The key names and associated types are defined by the entity that
offers these parameters, i.e. names for parameters provided by the
OpenSSL libraries are defined by the libraries, and names for
parameters provided by providers are defined by those providers,
except for the pointer form of strings (see data type descriptions
below).
Entities that want to set or request parameters need to know what
those keys are and of what type, any functionality between those two
entities should remain oblivious and just pass the \s-1OSSL_PARAM\s0 array
along.
"Supported types"
Subsection "Supported types" The
data_type field can be one of the following types:
"\s-1OSSL_PARAM_INTEGER\s0" 4
Item "OSSL_PARAM_INTEGER" 0
"\s-1OSSL_PARAM_UNSIGNED_INTEGER\s0" 4
Item "OSSL_PARAM_UNSIGNED_INTEGER"
The parameter data is an integer (signed or unsigned) of arbitrary
length, organized in native form, i.e. most significant byte first on
Big-Endian systems, and least significant byte first on Little-Endian
systems.
"\s-1OSSL_PARAM_REAL\s0" 4
Item "OSSL_PARAM_REAL" The parameter data is a floating point value in native form.
"\s-1OSSL_PARAM_UTF8_STRING\s0" 4
Item "OSSL_PARAM_UTF8_STRING" The parameter data is a printable string.
"\s-1OSSL_PARAM_OCTET_STRING\s0" 4
Item "OSSL_PARAM_OCTET_STRING" The parameter data is an arbitrary string of bytes.
"\s-1OSSL_PARAM_UTF8_PTR\s0" 4
Item "OSSL_PARAM_UTF8_PTR" The parameter data is a pointer to a printable string.
.Sp
The difference between this and
\s-1OSSL_PARAM_UTF8_STRING\s0 is that
data
doesn't point directly at the data, but to a pointer that points to the data.
.Sp
If there is any uncertainty about which to use,
\s-1OSSL_PARAM_UTF8_STRING\s0 is
almost certainly the correct choice.
.Sp
This is used to indicate that constant data is or will be passed,
and there is therefore no need to copy the data that is passed, just
the pointer to it.
.Sp
\fIdata_size must be set to the size of the data, not the size of the
pointer to the data.
If this is used in a parameter request,
\fIdata_size is not relevant. However, the
responder will set
\fIreturn_size to the size of the data.
.Sp
Note that the use of this type is
fragile and can only be safely
used for data that remains constant and in a constant location for a
long enough duration (such as the life-time of the entity that
offers these parameters).
"\s-1OSSL_PARAM_OCTET_PTR\s0" 4
Item "OSSL_PARAM_OCTET_PTR" The parameter data is a pointer to an arbitrary string of bytes.
.Sp
The difference between this and
\s-1OSSL_PARAM_OCTET_STRING\s0 is that
\fIdata doesn't point directly at the data, but to a pointer that
points to the data.
.Sp
If there is any uncertainty about which to use,
\s-1OSSL_PARAM_OCTET_STRING\s0 is
almost certainly the correct choice.
.Sp
This is used to indicate that constant data is or will be passed, and
there is therefore no need to copy the data that is passed, just the
pointer to it.
.Sp
\fIdata_size must be set to the size of the data, not the size of the
pointer to the data.
If this is used in a parameter request,
\fIdata_size is not relevant. However, the
responder will set
\fIreturn_size to the size of the data.
.Sp
Note that the use of this type is
fragile and can only be safely
used for data that remains constant and in a constant location for a
long enough duration (such as the life-time of the entity that
offers these parameters).
"NOTES"
Header "NOTES" Both when setting and requesting parameters, the functions that are
called will have to decide what is and what is not an error.
The recommended behaviour is:
"\(bu" 4
Keys that a
setter or
responder doesn't recognise should simply
be ignored.
That in itself isn't an error.
"\(bu" 4
If the keys that a called
setter recognises form a consistent
enough set of data, that call should succeed.
"\(bu" 4
Apart from the
return_size, a
responder must never change the fields
of an
\s-1OSSL_PARAM\s0.
To return a value, it should change the contents of the memory that
\fIdata points at.
"\(bu" 4
If the data type for a key that it's associated with is incorrect,
the called function may return an error.
.Sp
The called function may also try to convert the data to a suitable
form (for example, it's plausible to pass a large number as an octet
string, so even though a given key is defined as an
\fB\s-1OSSL_PARAM_UNSIGNED_INTEGER\s0, is plausible to pass the value as an
\fB\s-1OSSL_PARAM_OCTET_STRING\s0), but this is in no way mandatory.
"\(bu" 4
If
data for a
\s-1OSSL_PARAM_OCTET_STRING\s0 or a
\fB\s-1OSSL_PARAM_UTF8_STRING\s0 is \s-1NULL,\s0 the
responder should
set
return_size to the size of the item to be returned
and return success. Later the responder will be called again
with
data pointing at the place for the value to be put.
"\(bu" 4
If a
responder finds that some data sizes are too small for the
requested data, it must set
return_size for each such
\fB\s-1OSSL_PARAM\s0 item to the minimum required size, and eventually return
an error.
"\(bu" 4
For the integer type parameters (
\s-1OSSL_PARAM_UNSIGNED_INTEGER\s0 and
\fB\s-1OSSL_PARAM_INTEGER\s0), a
responder may choose to return an error
if the
data_size isn't a suitable size (even if
data_size is
bigger than needed). If the
responder finds the size suitable, it
must fill all
data_size bytes and ensure correct padding for the
native endianness, and set
return_size to the same value as
\fIdata_size.
"EXAMPLES"
Header "EXAMPLES" A couple of examples to just show how
\s-1OSSL_PARAM\s0 arrays could be
set up.
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";
OSSL_PARAM set[] = {
{ "foo", OSSL_PARAM_UTF8_PTR, &foo, foo_l, 0 },
{ "bar", OSSL_PARAM_UTF8_STRING, (void *)&bar, sizeof(bar) - 1, 0 },
{ NULL, 0, NULL, 0, 0 }
};
.Ve
Example 2
Subsection "Example 2"
This example is for requesting parameters on some object:
.Vb 9
const char *foo = NULL;
size_t foo_l;
char bar[1024];
size_t bar_l;
OSSL_PARAM request[] = {
{ "foo", OSSL_PARAM_UTF8_PTR, &foo, 0 /*irrelevant*/, 0 },
{ "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
{ NULL, 0, NULL, 0, 0 }
};
.Ve
A responder that receives this array (as params in this example)
could fill in the parameters like this:
.Vb 1
/* OSSL_PARAM *params */
\&
int i;
\&
for (i = 0; params[i].key != NULL; i++) {
if (strcmp(params[i].key, "foo") == 0) {
*(char **)params[i].data = "foo value";
params[i].return_size = 9; /* length of "foo value" string */
} else if (strcmp(params[i].key, "bar") == 0) {
memcpy(params[i].data, "bar value", 10);
params[i].return_size = 9; /* length of "bar value" string */
}
/* Ignore stuff we don\*(Aqt know */
}
.Ve
"SEE ALSO"
Header "SEE ALSO" \fBopenssl-
core.h\|(7),
OSSL_PARAM_get_int\|(3),
OSSL_PARAM_dup\|(3)
"HISTORY"
Header "HISTORY" \fB\s-1OSSL_PARAM\s0 was added 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>.