OPENSSL_s390xcap.pod: list msa9 facility bit (155)
[openssl.git] / doc / man3 / OSSL_PARAM.pod
index a90069cd479a0cddaa1a2c39b57cc913c0ab82d9..61ff378e461b2a6240db23e59fe18688e0331e75 100644 (file)
@@ -14,7 +14,7 @@ OSSL_PARAM - a structure to pass or request object parameters
      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;         /* OPTIONAL: address to content size */
+     size_t return_size;          /* returned size */
  };
 
 =head1 DESCRIPTION
@@ -27,27 +27,37 @@ 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 two purposes:
+Arrays of this type can be used for the following purposes:
 
 =over 4
 
-=item *
+=item * Setting parameters for some object
 
-Setting parameters for some object.
 The caller sets up the C<OSSL_PARAM> array and calls some function
 (the I<setter>) that has intimate knowledge about the object that can
 take the data from the C<OSSL_PARAM> array and assign them in a
 suitable form for the internal structure of the object.
 
-=item *
+=item * Request parameters of some object
 
-Request parameters of some object.
 The caller (the I<requestor>) sets up the C<OSSL_PARAM> array and
 calls some function (the I<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
 I<requestor> and pointed at with the C<OSSL_PARAM> C<data>.
 
+=item * Request parameter descriptors
+
+The caller gets an array of constant C<OSSL_PARAM>, 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.
+
+The caller may then use the information from this descriptor array to
+build up its own C<OSSL_PARAM> array to pass down to a I<setter> or
+I<responder>.
+
 =back
 
 =head2 C<OSSL_PARAM> fields
@@ -78,6 +88,11 @@ setting parameters) or shall (when requesting parameters) be stored,
 and C<data_size> is its size in bytes.
 The organization of the data depends on the parameter type and flag.
 
+When the C<OSSL_PARAM> is used as a parameter descriptor, C<data>
+should be ignored.
+If C<data_size> is zero, it means that an arbitrary data size is
+accepted, otherwise it specifies the maximum size allowed.
+
 =item C<return_size>
 
 When an array of C<OSSL_PARAM> is used to request data, the
@@ -86,6 +101,9 @@ parameter data.
 In case the C<data_size> is too small for the data, the I<responder>
 must still set this field to indicate the minimum data size required.
 
+When the C<OSSL_PARAM> is used as a parameter descriptor,
+C<return_size> should be ignored.
+
 =back
 
 B<NOTE:>
@@ -118,8 +136,6 @@ systems.
 
 =item C<OSSL_PARAM_REAL>
 
-=for comment It's still debated if we need this or not.
-
 The parameter data is a floating point value in native form.
 
 =item C<OSSL_PARAM_UTF8_STRING>
@@ -130,47 +146,50 @@ The parameter data is a printable string.
 
 The parameter data is an arbitrary string of bytes.
 
-=back
-
-Additionally, this flag can be added to any type:
-
-=over 4
+=item C<OSSL_PARAM_UTF8_PTR>
 
-=item C<OSSL_PARAM_POINTER_FLAG>
+The parameter data is a pointer to a printable string.
 
-With this flag, C<data> doesn't point directly at the data, but at a
-pointer that points at the data.
+The difference between this and C<OSSL_PARAM_UTF8_STRING> is that C<data>
+doesn't point directly at the data, but to a pointer that points to the data.
 
-This can be used to indicate that constant data is or will be passed,
+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.
 
-If an C<OSSL_PARAM> with this flag set is used to set a parameter,
-C<data_size> must be set to the size of the data, not the size of
-the pointer to the data.
+C<data_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,
+C<data_size> is not relevant.  However, the I<responder> will set
+C<return_size> to the size of the data.
 
-If this C<OSSL_PARAM> is used in a parameter request, C<data_size>
-is not relevant.
-However, the I<responder> will set C<*return_size> to the size of the
-data (again, not the size of the pointer to the data).
-
-Note that the use of this flag is B<fragile> and can only be safely
+Note that the use of this type is B<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).
 
-=back
+=item C<OSSL_PARAM_OCTET_PTR>
 
-For convenience, these types are provided:
+The parameter data is a pointer to an arbitrary string of bytes.
 
-=over 4
+The difference between this and C<OSSL_PARAM_OCTET_STRING> is that
+C<data> doesn't point directly at the data, but to a pointer that
+points to the data.
 
-=item C<OSSL_PARAM_UTF8_STRING_PTR>
+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.
 
-=item C<OSSL_PARAM_OCTET_STRING_PTR>
+C<data_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,
+C<data_size> is not relevant.  However, the I<responder> will set
+C<return_size> to the size of the data.
 
-These are combinations of C<OSSL_PARAM_UTF8_STRING> as well as
-C<OSSL_PARAM_OCTET_STRING> with C<OSSL_PARAM_POINTER_FLAG>.
+Note that the use of this type is B<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).
 
 =back
 
@@ -195,9 +214,10 @@ enough set of data, that call should succeed.
 
 =item *
 
-A I<responder> must never change the fields of an C<OSSL_PARAM>, it
-may only change the contents of the memory that C<data> and
-C<return_size> point at.
+Apart from the C<return_size>, a I<responder> must never change the fields
+of an C<OSSL_PARAM>.
+To return a value, it should change the contents of the memory that
+C<data> points at.
 
 =item *
 
@@ -213,7 +233,7 @@ C<OSSL_PARAM_OCTET_STRING>), but this is in no way mandatory.
 =item *
 
 If a I<responder> finds that some data sizes are too small for the
-requested data, it must set C<*return_size> for each such
+requested data, it must set C<return_size> for each such
 C<OSSL_PARAM> item to the required size, and eventually return an
 error.
 
@@ -243,9 +263,9 @@ This example is for setting parameters on some object:
     const char *foo = "some string";
     size_t foo_l = strlen(foo) + 1;
     const char bar[] = "some other string";
-    const OSSL_PARAM set[] = {
-        { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, NULL },
-        { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), NULL },
+    OSSL_PARAM set[] = {
+        { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, 0 },
+        { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
         { NULL, 0, NULL, 0, NULL }
     };
 
@@ -257,33 +277,33 @@ This example is for requesting parameters on some object:
     size_t foo_l;
     char bar[1024];
     size_t bar_l;
-    const OSSL_PARAM request[] = {
-        { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, &foo_l },
-        { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), &bar_l },
+    OSSL_PARAM request[] = {
+        { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, 0 },
+        { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
         { NULL, 0, NULL, 0, NULL }
     };
 
 A I<responder> that receives this array (as C<params> in this example)
 could fill in the parameters like this:
 
-    /* const OSSL_PARAM *params */
+    /* 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 = 10; /* size of "foo value" */
+            params[i].return_size = 10; /* size of "foo value" */
         } else if (strcmp(params[i].key, "bar") == 0) {
-            memcpy(params[1].data, "bar value", 10);
-            *params[1].return_size = 10; /* size of "bar value" */
+            memcpy(params[i].data, "bar value", 10);
+            params[i].return_size = 10; /* size of "bar value" */
         }
         /* Ignore stuff we don't know */
     }
 
 =head1 SEE ALSO
 
-L<openssl-core.h(7)>
+L<openssl-core.h(7)>, L<OSSL_PARAM_get_int(3)>
 
 =head1 HISTORY