OPENSSL_s390xcap.pod: list msa9 facility bit (155)
[openssl.git] / doc / man3 / OSSL_PARAM.pod
index fb8c6fdae32bb407f0bc190d8a07ddc52fd7cf73..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:>
@@ -143,7 +161,7 @@ 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.
+C<return_size> to the size of the data.
 
 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
@@ -166,7 +184,7 @@ 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.
+C<return_size> to the size of the data.
 
 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
@@ -196,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 *
 
@@ -214,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.
 
@@ -244,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 }
     };
 
@@ -258,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[i].data, "bar value", 10);
-            *params[i].return_size = 10; /* size of "bar value" */
+            params[i].return_size = 10; /* size of "bar value" */
         }
         /* Ignore stuff we don't know */
     }
 
 =head1 SEE ALSO
 
-L<openssl-core.h(7)>, L<OSSL_PARAM_get_int32_t(3)>
+L<openssl-core.h(7)>, L<OSSL_PARAM_get_int(3)>
 
 =head1 HISTORY