Replace OSSL_ITEM with OSSL_PARAM as parameter descriptor, everywhere
authorRichard Levitte <levitte@openssl.org>
Thu, 11 Jul 2019 10:19:33 +0000 (12:19 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 23 Jul 2019 05:30:33 +0000 (07:30 +0200)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9346)

crypto/provider.c
crypto/provider_core.c
doc/internal/man3/ossl_provider_new.pod
doc/man3/OSSL_PROVIDER.pod
include/internal/provider.h
include/openssl/core.h
include/openssl/core_numbers.h
include/openssl/provider.h
providers/default/defltprov.c
providers/fips/fipsprov.c
test/p_test.c

index 8c9c6dae14bb76bdbad545b8009fcd18b8295061..f81260cdaba00580d53fbf434575ae283e56da2d 100644 (file)
@@ -35,7 +35,7 @@ int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov)
     return 1;
 }
 
-const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov)
+const OSSL_PARAM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov)
 {
     return ossl_provider_get_param_types(prov);
 }
index c16e91d1d4be803813147e505e75b25891163ee9..d96e2144f493052c45e513ac99279570371454a2 100644 (file)
@@ -680,7 +680,7 @@ void ossl_provider_teardown(const OSSL_PROVIDER *prov)
         prov->teardown(prov->provctx);
 }
 
-const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov)
+const OSSL_PARAM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov)
 {
     return prov->get_param_types == NULL
         ? NULL : prov->get_param_types(prov->provctx);
@@ -712,13 +712,13 @@ const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
  * discovery.  We do not expect that many providers will use this, but one
  * never knows.
  */
-static const OSSL_ITEM param_types[] = {
-    { OSSL_PARAM_UTF8_PTR, "openssl-version" },
-    { OSSL_PARAM_UTF8_PTR, "provider-name" },
-    { 0, NULL }
+static const OSSL_PARAM param_types[] = {
+    OSSL_PARAM_DEFN("openssl-verstion", OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_DEFN("provider-name", OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_END
 };
 
-static const OSSL_ITEM *core_get_param_types(const OSSL_PROVIDER *prov)
+static const OSSL_PARAM *core_get_param_types(const OSSL_PROVIDER *prov)
 {
     return param_types;
 }
index cb40cb2cf966e301281d82b3213394e3ced3bc4e..426d95393dd5504da12907e2bfaca4160b0cb32f 100644 (file)
@@ -51,7 +51,7 @@ ossl_provider_get_params, ossl_provider_query_operation
 
  /* Thin wrappers around calls to the provider */
  void ossl_provider_teardown(const OSSL_PROVIDER *prov);
- const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
+ const OSSL_PARAM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
  int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
  const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
                                                      int operation_id,
@@ -174,7 +174,7 @@ the provider has one.
 
 ossl_provider_get_param_types() calls the provider's I<get_param_types>
 function, if the provider has one.
-It should return an array of I<OSSL_ITEM> to describe all the
+It should return an array of I<OSSL_PARAM> to describe all the
 parameters that the provider has for the provider object.
 
 ossl_provider_get_params() calls the provider's parameter request
@@ -235,9 +235,9 @@ is returned.
 
 ossl_provider_teardown() doesnt't return any value.
 
-ossl_provider_get_param_types() returns a pointer to an I<OSSL_ITEM>
-array if this function is available in the provider, otherwise
-NULL.
+ossl_provider_get_param_types() returns a pointer to a constant
+I<OSSL_PARAM> array if this function is available in the provider,
+otherwise NULL.
 
 ossl_provider_get_params() returns 1 on success, or 0 on error.
 If this function isn't available in the provider, 0 is returned.
index fec67060f0cd8297648e593955a6f1e21ddf5d47..1453fcc50a2c37a683ae6c2b58aed6faf45c9f68 100644 (file)
@@ -15,7 +15,7 @@ OSSL_PROVIDER_add_builtin, OSSL_PROVIDER_name - provider routines
  OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
  int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
 
- const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov);
+ const OSSL_PARAM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov);
  int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
 
  int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name,
@@ -50,11 +50,8 @@ For a provider added with OSSL_PROVIDER_add_builtin(), this simply
 runs its teardown function.
 
 OSSL_PROVIDER_get_param_types() is used to get a provider parameter
-descriptor set as an B<OSSL_ITEM> array.
-Each element is a tuple of an B<OSSL_PARAM> parameter type and a name
-in form of a C string.
-See L<openssl-core.h(7)> for more information on B<OSSL_ITEM> and
-parameter types.
+descriptor set as a constant B<OSSL_PARAM> array.
+See L<OSSL_PARAM(3)> for more information.
 
 OSSL_PROVIDER_get_params() is used to get provider parameter values.
 The caller must prepare the B<OSSL_PARAM> array before calling this
@@ -72,8 +69,8 @@ success, or B<NULL> on error.
 
 OSSL_PROVIDER_unload() returns 1 on success, or 0 on error.
 
-OSSL_PROVIDER_get_param_types() returns a pointer to a constant array
-of B<OSSL_ITEM>, or NULL if none is provided.
+OSSL_PROVIDER_get_param_types() returns a pointer to an array
+of constant B<OSSL_PARAM>, or NULL if none is provided.
 
 OSSL_PROVIDER_get_params() returns 1 on success, or 0 on error.
 
index 493fbde0b325ae6577998a1307340a74486a01d6..fbc60fc6ee7c4de77dc09d65fe540b7e4abdfe09 100644 (file)
@@ -62,7 +62,7 @@ const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
 
 /* Thin wrappers around calls to the provider */
 void ossl_provider_teardown(const OSSL_PROVIDER *prov);
-const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
+const OSSL_PARAM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
 int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
 const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
                                                     int operation_id,
index e9bc4891cbf254a0b9cc2e3ce60080cbf300a2c2..43e9d0a6bce2c625c8e19c6e3d335f1e3bb39ece 100644 (file)
@@ -43,7 +43,7 @@ struct ossl_dispatch_st {
  * tables remain tables with function pointers only.
  *
  * This is used whenever we need to pass things like a table of error reason
- * codes <-> reason string maps, parameter name <-> parameter type maps, ...
+ * codes <-> reason string maps, ...
  *
  * Usage determines which field works as key if any, rather than field order.
  *
index 905094d09a8ac90edba438f33054efb3f48d0c9b..21f430315054981db7c537aea54dd6ec2580c193 100644 (file)
@@ -58,7 +58,7 @@ extern "C" {
  */
 /* Functions provided by the Core to the provider, reserved numbers 1-1023 */
 # define OSSL_FUNC_CORE_GET_PARAM_TYPES        1
-OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,
+OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
                     core_get_param_types,(const OSSL_PROVIDER *prov))
 # define OSSL_FUNC_CORE_GET_PARAMS             2
 OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_PROVIDER *prov,
@@ -132,7 +132,7 @@ OSSL_CORE_MAKE_FUNC(unsigned char *,
 # define OSSL_FUNC_PROVIDER_TEARDOWN         1024
 OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx))
 # define OSSL_FUNC_PROVIDER_GET_PARAM_TYPES  1025
-OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,
+OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
                     provider_get_param_types,(void *provctx))
 # define OSSL_FUNC_PROVIDER_GET_PARAMS       1026
 OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx,
index 722e83b14a43b73d526829f50d35ae2a23bfe0e3..68d5d10a12a768a189a007bde6d6eaf3a01afb57 100644 (file)
@@ -20,7 +20,7 @@ extern "C" {
 OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
 int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
 
-const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov);
+const OSSL_PARAM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov);
 int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
 
 /* Add a built in providers */
index 18e3a5c36f89be105cd5cd19306c5ecc6042af6f..2c25bf77d1f1f7fd10da3d85a3b60e8433d21697 100644 (file)
@@ -20,14 +20,14 @@ static OSSL_core_get_param_types_fn *c_get_param_types = NULL;
 static OSSL_core_get_params_fn *c_get_params = NULL;
 
 /* Parameters we provide to the core */
-static const OSSL_ITEM deflt_param_types[] = {
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_NAME },
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_VERSION },
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_BUILDINFO },
-    { 0, NULL }
+static const OSSL_PARAM deflt_param_types[] = {
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_END
 };
 
-static const OSSL_ITEM *deflt_get_param_types(const OSSL_PROVIDER *prov)
+static const OSSL_PARAM *deflt_get_param_types(const OSSL_PROVIDER *prov)
 {
     return deflt_param_types;
 }
index c1fbe4a3f57c917dec172313a9f04b90655d7d2f..50d3c4b0d74a8f5331967a17abe4231eb4e5911a 100644 (file)
@@ -80,11 +80,11 @@ static const OPENSSL_CTX_METHOD fips_prov_ossl_ctx_method = {
 
 
 /* Parameters we provide to the core */
-static const OSSL_ITEM fips_param_types[] = {
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_NAME },
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_VERSION },
-    { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_BUILDINFO },
-    { 0, NULL }
+static const OSSL_PARAM fips_param_types[] = {
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0),
+    OSSL_PARAM_END
 };
 
 /* TODO(3.0): To be removed */
@@ -149,7 +149,7 @@ static int dummy_evp_call(void *provctx)
     return ret;
 }
 
-static const OSSL_ITEM *fips_get_param_types(const OSSL_PROVIDER *prov)
+static const OSSL_PARAM *fips_get_param_types(const OSSL_PROVIDER *prov)
 {
     return fips_param_types;
 }
index 904b75b2de45680e867928b6f205e04bbf5d7fd7..a730530463b5803397906b641d010cef046ff5ee 100644 (file)
@@ -33,16 +33,16 @@ static OSSL_core_get_param_types_fn *c_get_param_types = NULL;
 static OSSL_core_get_params_fn *c_get_params = NULL;
 
 /* Tell the core what params we provide and what type they are */
-static const OSSL_ITEM p_param_types[] = {
-    { OSSL_PARAM_UTF8_STRING, "greeting" },
-    { 0, NULL }
+static const OSSL_PARAM p_param_types[] = {
+    { "greeting", OSSL_PARAM_UTF8_STRING, NULL, 0, 0 },
+    { NULL, 0, NULL, 0, 0 }
 };
 
 /* This is a trick to ensure we define the provider functions correctly */
 static OSSL_provider_get_param_types_fn p_get_param_types;
 static OSSL_provider_get_params_fn p_get_params;
 
-static const OSSL_ITEM *p_get_param_types(void *_)
+static const OSSL_PARAM *p_get_param_types(void *_)
 {
     return p_param_types;
 }