]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Params: add OSSL_PARAM_construct_end()
authorRichard Levitte <levitte@openssl.org>
Tue, 9 Apr 2019 07:49:58 +0000 (09:49 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 9 Apr 2019 09:18:26 +0000 (11:18 +0200)
OSSL_PARAM_END is a macro that can only be used to initialize an
OSSL_PARAM array, not to assign an array element later on.  For
completion, we add an end constructor to facilitate that kind of
assignment.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8704)

crypto/params.c
doc/man3/OSSL_PARAM_TYPE.pod
include/openssl/params.h
test/params_api_test.c
test/params_test.c
util/libcrypto.num

index 465bb32711ade3c55e40d4106cb8c3beec55b93b..8b75e0483980c26d6a25a2555f34e2af6f7af5cd 100644 (file)
@@ -590,3 +590,10 @@ OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
 {
     return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, 0, rsize);
 }
+
+OSSL_PARAM OSSL_PARAM_construct_end(void)
+{
+    OSSL_PARAM end = OSSL_PARAM_END;
+
+    return end;
+}
index 2842eae317c0d1c9a7a0fab81defb1c1480f9f69..dd887f3089596c61d0be8cd70330cbe7a86c9975 100644 (file)
@@ -10,7 +10,8 @@ OSSL_PARAM_SIZED_octet_ptr, OSSL_PARAM_END, OSSL_PARAM_construct_TYPE,
 OSSL_PARAM_END,
 OSSL_PARAM_construct_BN, OSSL_PARAM_construct_utf8_string,
 OSSL_PARAM_construct_utf8_ptr, OSSL_PARAM_construct_octet_string,
-OSSL_PARAM_construct_octet_ptr, OSSL_PARAM_locate, OSSL_PARAM_get_TYPE,
+OSSL_PARAM_construct_octet_ptr, OSSL_PARAM_construct_end,
+OSSL_PARAM_locate, OSSL_PARAM_get_TYPE,
 OSSL_PARAM_set_TYPE, OSSL_PARAM_get_BN, OSSL_PARAM_set_BN,
 OSSL_PARAM_get_utf8_string, OSSL_PARAM_set_utf8_string,
 OSSL_PARAM_get_octet_string, OSSL_PARAM_set_octet_string,
@@ -46,6 +47,7 @@ OSSL_PARAM_set_octet_ptr
                                           size_t *rsize);
  OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
                                            size_t *rsize);
+ OSSL_PARAM OSSL_PARAM_construct_end(void);
 
  OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key);
 
@@ -179,6 +181,9 @@ pointer OSSL_PARAM structure.
 A parameter with name B<key>, storage pointer B<*buf> and return size B<rsize>
 is created.
 
+OSSL_PARAM_construct_end() is a function that constructs the terminating
+OSSL_PARAM structure.
+
 OSSL_PARAM_locate() is a function that searches an B<array> of parameters for
 the one matching the B<key> name.
 
index 10ed28d356cb6518374e86ee32fc6a86576b6f14..cf9ffa8c7a174a20454d6c390912638b1296d942 100644 (file)
@@ -137,6 +137,7 @@ OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
                                              size_t bsize, size_t *rsize);
 OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
                                           size_t *rsize);
+OSSL_PARAM OSSL_PARAM_construct_end(void);
 
 int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val);
 int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val);
index c78a42bade4152684dfdca5c57b8460dfd3c1ade..a3d23377459eea04848460864cd963ef3bec60a7 100644 (file)
@@ -448,7 +448,6 @@ static int test_param_construct(void)
     void *vp, *vpn = NULL, *vp2;
     OSSL_PARAM *p;
     const OSSL_PARAM *cp;
-    static const OSSL_PARAM pend = OSSL_PARAM_END;
     int i, n = 0, ret = 0;
     unsigned int u;
     long int l;
@@ -478,7 +477,7 @@ static int test_param_construct(void)
                                                     &sz);
     params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, &sz);
     params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, &sz);
-    params[n] = pend;
+    params[n] = OSSL_PARAM_construct_end();
 
     /* Search failure */
     if (!TEST_ptr_null(OSSL_PARAM_locate(params, "fnord")))
index 338e6b20434496ad3a1be6b890818b891a0d1304..8d456bbbde28b221d1c681d6b335a902d942c3cc 100644 (file)
@@ -391,7 +391,6 @@ static OSSL_PARAM *construct_api_params(void)
 {
     size_t n = 0;
     static OSSL_PARAM params[10];
-    OSSL_PARAM param_end = OSSL_PARAM_END;
 
     params[n++] = OSSL_PARAM_construct_int("p1", &app_p1, NULL);
     params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin),
@@ -404,7 +403,7 @@ static OSSL_PARAM *construct_api_params(void)
                                                 &app_p6_l);
     params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo),
                                                     &foo_l);
-    params[n++] = param_end;
+    params[n++] = OSSL_PARAM_construct_end();
 
     return params;
 }
index 638897306654369e04e2591329e386f9d13f8222..d275e579ba4ffb51de54bea4fa667d37846124d2 100644 (file)
@@ -4794,3 +4794,4 @@ EVP_PKEY_get0_engine                    4741      3_0_0   EXIST::FUNCTION:ENGINE
 EVP_MD_upref                            4742   3_0_0   EXIST::FUNCTION:
 EVP_MD_fetch                            4743   3_0_0   EXIST::FUNCTION:
 EVP_set_default_properties              4744   3_0_0   EXIST::FUNCTION:
+OSSL_PARAM_construct_end                4745   3_0_0   EXIST::FUNCTION: