[openssl] master update

Dr. Paul Dale pauli at openssl.org
Wed Feb 12 09:46:35 UTC 2020


The branch master has been updated
       via  903f582016cdc31b3f3557c168883ccd8a4debf5 (commit)
       via  99b9aa95c435058bd35fb3b83b885894e2247c82 (commit)
      from  663247bf1181043d168a542b0d0d56cc0318e2f7 (commit)


- Log -----------------------------------------------------------------
commit 903f582016cdc31b3f3557c168883ccd8a4debf5
Author: Pauli <paul.dale at oracle.com>
Date:   Tue Feb 11 09:19:19 2020 +1000

    Remove unused ossl_param_bld_to_param_ex() function.
    
    The recently introduced ossl_param_bld_to_param_ex() function is only
    called by the unit tests.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/11053)

commit 99b9aa95c435058bd35fb3b83b885894e2247c82
Author: Pauli <paul.dale at oracle.com>
Date:   Tue Feb 11 09:13:33 2020 +1000

    Remove unused OSSL_PARAM_construct_from_text() function.
    
    This function is recently introduced and never called by the library or tests.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/11053)

-----------------------------------------------------------------------

Summary of changes:
 crypto/param_build.c                               |  30 ------
 crypto/params_from_text.c                          |  31 ------
 crypto/sm2/sm2_pmeth.c                             |   3 +-
 doc/internal/man3/ossl_param_bld_init.pod          |  18 +---
 ..._text.pod => OSSL_PARAM_allocate_from_text.pod} |  15 +--
 include/internal/param_build.h                     |   4 -
 include/openssl/params.h                           |   5 -
 test/param_build_test.c                            | 119 ---------------------
 util/libcrypto.num                                 |   1 -
 9 files changed, 7 insertions(+), 219 deletions(-)
 rename doc/man3/{OSSL_PARAM_construct_from_text.pod => OSSL_PARAM_allocate_from_text.pod} (86%)

diff --git a/crypto/param_build.c b/crypto/param_build.c
index 21bed31393..7c3b1a597a 100644
--- a/crypto/param_build.c
+++ b/crypto/param_build.c
@@ -330,33 +330,3 @@ void ossl_param_bld_free(OSSL_PARAM *params)
         OPENSSL_free(params);
     }
 }
-
-OSSL_PARAM *ossl_param_bld_to_param_ex(OSSL_PARAM_BLD *bld, OSSL_PARAM *params,
-                                       size_t param_n, void *data,
-                                       size_t data_n, void *secure,
-                                       size_t secure_n)
-{
-    if (params == NULL || data == NULL) {
-        CRYPTOerr(CRYPTO_F_OSSL_PARAM_BLD_TO_PARAM_EX,
-                  CRYPTO_R_INVALID_NULL_ARGUMENT);
-        return NULL;
-    }
-    if (param_n < bld->curr + 1) {
-        CRYPTOerr(CRYPTO_F_OSSL_PARAM_BLD_TO_PARAM_EX,
-                  CRYPTO_R_INSUFFICIENT_PARAM_SIZE);
-        return NULL;
-    }
-    if (data_n < ALIGN_SIZE * bld->total_blocks) {
-        CRYPTOerr(CRYPTO_F_OSSL_PARAM_BLD_TO_PARAM_EX,
-                  CRYPTO_R_INSUFFICIENT_DATA_SPACE);
-        return NULL;
-    }
-    if (bld->secure_blocks > 0 && secure_n < ALIGN_SIZE * bld->secure_blocks) {
-        CRYPTOerr(CRYPTO_F_OSSL_PARAM_BLD_TO_PARAM_EX,
-                  CRYPTO_R_INSUFFICIENT_SECURE_DATA_SPACE);
-        return NULL;
-    }
-    param_bld_convert(bld, params, (OSSL_PARAM_BLD_BLOCK *)data,
-                      (OSSL_PARAM_BLD_BLOCK *)secure);
-    return params;
-}
diff --git a/crypto/params_from_text.c b/crypto/params_from_text.c
index 053b93d2c3..59cee5f115 100644
--- a/crypto/params_from_text.c
+++ b/crypto/params_from_text.c
@@ -160,37 +160,6 @@ static int construct_from_text(OSSL_PARAM *to, const OSSL_PARAM *paramdef,
     return 1;
 }
 
-int OSSL_PARAM_construct_from_text(OSSL_PARAM *to,
-                                   const OSSL_PARAM *paramdefs,
-                                   const char *key, const char *value,
-                                   size_t value_n,
-                                   void *buf, size_t *buf_n)
-{
-    const OSSL_PARAM *paramdef = NULL;
-    int ishex = 0;
-    BIGNUM *tmpbn = NULL;
-    int ok = 0;
-
-    if (to == NULL || paramdefs == NULL)
-        return 0;
-
-    if (!prepare_from_text(paramdefs, key, value, value_n,
-                           &paramdef, &ishex, buf_n, &tmpbn))
-        return 0;
-
-    /*
-     * The user gets the expected buffer size back even if the buffer isn't
-     * allocated.
-     */
-    if (buf == NULL)
-        return 1;
-
-    ok = construct_from_text(to, paramdef, value, value_n, ishex,
-                             buf, *buf_n, tmpbn);
-    BN_free(tmpbn);
-    return ok;
-}
-
 int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to,
                                   const OSSL_PARAM *paramdefs,
                                   const char *key, const char *value,
diff --git a/crypto/sm2/sm2_pmeth.c b/crypto/sm2/sm2_pmeth.c
index 681a0ab130..c3ba9280c5 100644
--- a/crypto/sm2/sm2_pmeth.c
+++ b/crypto/sm2/sm2_pmeth.c
@@ -253,8 +253,7 @@ static int pkey_sm2_ctrl_str(EVP_PKEY_CTX *ctx,
     } else if (strcmp(type, "sm2_hex_id") == 0) {
         /*
          * TODO(3.0): reconsider the name "sm2_hex_id", OR change
-         * OSSL_PARAM_construct_from_text() / OSSL_PARAM_allocate_from_text()
-         * to handle infix "_hex_"
+         * OSSL_PARAM_allocate_from_text() to handle infix "_hex_"
          */
         hex_id = OPENSSL_hexstr2buf((const char *)value, &hex_len);
         if (hex_id == NULL) {
diff --git a/doc/internal/man3/ossl_param_bld_init.pod b/doc/internal/man3/ossl_param_bld_init.pod
index 545eaf1415..110192fbe0 100644
--- a/doc/internal/man3/ossl_param_bld_init.pod
+++ b/doc/internal/man3/ossl_param_bld_init.pod
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-ossl_param_bld_init, ossl_param_bld_to_param, ossl_param_bld_to_param_ex,
+ossl_param_bld_init, ossl_param_bld_to_param,
 ossl_param_bld_free, ossl_param_bld_push_int, ossl_param_bld_push_uint,
 ossl_param_bld_push_long, ossl_param_bld_push_ulong,
 ossl_param_bld_push_int32, ossl_param_bld_push_uint32,
@@ -24,10 +24,6 @@ ossl_param_bld_push_octet_string, ossl_param_bld_push_octet_ptr
 
  void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
  OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld);
- OSSL_PARAM *ossl_param_bld_to_param_ex(OSSL_PARAM_BLD *bld,
-                                        OSSL_PARAM *params, size_t param_n,
-                                        void *data, size_t data_n,
-                                        void *secure, size_t secure_n);
  void ossl_param_bld_free(OSSL_PARAM *params);
 
  int ossl_param_bld_push_TYPE(OSSL_PARAM_BLD *bld, const char *key, TYPE val);
@@ -64,14 +60,6 @@ ossl_param_bld_free() with the functions return value.
 ossl_param_bld_free() deallocates the memory allocated by
 ossl_param_bld_to_param().
 
-ossl_param_bld_to_param_ex() behaves like ossl_param_bld_to_param(), except that
-no additional memory is allocated.
-An OSSL_PARAM array of at least I<param_n> elements is passed in as I<params>.
-The auxiliary storage for the parameters is a block of memory pointed to
-by I<data> of at least I<data_n> bytes in size.
-If required, secure memory for private BIGNUMs should be pointed to by
-I<secure> of at least I<secure_n> bytes in size.
-
 =begin comment
 
 POD is pretty good at recognising function names and making them appropriately
@@ -125,8 +113,8 @@ scope until the OSSL_PARAM array is freed.
 
 =head1 RETURN VALUES
 
-ossl_param_bld_to_param() and ossl_param_bld_to_param_ex() return the
-allocated OSSL_PARAM array, or NULL on error.
+ossl_param_bld_to_param() returns the allocated OSSL_PARAM array, or NULL
+on error.
 
 All of the ossl_param_bld_push_TYPE functions return 1 on success and 0
 on error.
diff --git a/doc/man3/OSSL_PARAM_construct_from_text.pod b/doc/man3/OSSL_PARAM_allocate_from_text.pod
similarity index 86%
rename from doc/man3/OSSL_PARAM_construct_from_text.pod
rename to doc/man3/OSSL_PARAM_allocate_from_text.pod
index 7e6c3e9193..c16491e702 100644
--- a/doc/man3/OSSL_PARAM_construct_from_text.pod
+++ b/doc/man3/OSSL_PARAM_allocate_from_text.pod
@@ -2,18 +2,13 @@
 
 =head1 NAME
 
-OSSL_PARAM_construct_from_text, OSSL_PARAM_allocate_from_text
+OSSL_PARAM_allocate_from_text
 - OSSL_PARAM construction utilities
 
 =head1 SYNOPSIS
 
  #include <openssl/params.h>
 
- int OSSL_PARAM_construct_from_text(OSSL_PARAM *to,
-                                    const OSSL_PARAM *paramdefs,
-                                    const char *key, const char *value,
-                                    size_t value_n,
-                                    void *buf, size_t *buf_n)
  int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to,
                                    const OSSL_PARAM *paramdefs,
                                    const char *key, const char *value,
@@ -30,7 +25,7 @@ OpenSSL 3.0 introduces a new mechanism to do the same thing with an
 array of parameters that contain name, value, value type and value
 size (see L<OSSL_PARAM(3)> for more information).
 
-OSSL_PARAM_construct_from_text() takes a control I<key>, I<value> and
+OSSL_PARAM_allocate_from_text() takes a control I<key>, I<value> and
 value size I<value_n>, and given a parameter descriptor array
 I<paramdefs>, it converts the value to something suitable for
 L<OSSL_PARAM(3)> and stores that in the buffer I<buf>, and modifies
@@ -42,9 +37,6 @@ left untouched, allowing a caller to find out how large the buffer
 should be.
 I<buf> needs to be correctly aligned for the type of the B<OSSL_PARAM>
 I<key>.
-
-OSSL_PARAM_allocate_from_text() works like OSSL_PARAM_construct_from_text(),
-except it allocates the buffer internally.
 The caller must remember to free the data of I<to> when it's not
 useful any more.
 
@@ -57,8 +49,7 @@ as parameter value.
 
 =head1 RETURN VALUES
 
-OSSL_PARAM_construct_from_text() and OSSL_PARAM_allocate_from_text()
-returns 1 on success, and 0 on error.
+OSSL_PARAM_allocate_from_text() returns 1 on success, and 0 on error.
 
 =head1 NOTES
 
diff --git a/include/internal/param_build.h b/include/internal/param_build.h
index ac1945f6f6..59104b93aa 100644
--- a/include/internal/param_build.h
+++ b/include/internal/param_build.h
@@ -42,10 +42,6 @@ typedef struct {
 void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
 OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld);
 void ossl_param_bld_free(OSSL_PARAM *params);
-OSSL_PARAM *ossl_param_bld_to_param_ex(OSSL_PARAM_BLD *bld,
-                                       OSSL_PARAM *params, size_t param_n,
-                                       void *data, size_t data_n,
-                                       void *secure, size_t secure_n);
 
 int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
 int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key,
diff --git a/include/openssl/params.h b/include/openssl/params.h
index aec3bc18b8..a5d2fd4f41 100644
--- a/include/openssl/params.h
+++ b/include/openssl/params.h
@@ -89,11 +89,6 @@ OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
                                           size_t bsize);
 OSSL_PARAM OSSL_PARAM_construct_end(void);
 
-int OSSL_PARAM_construct_from_text(OSSL_PARAM *to,
-                                   const OSSL_PARAM *paramdefs,
-                                   const char *key, const char *value,
-                                   size_t value_n,
-                                   void *buf, size_t *buf_n);
 int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to,
                                   const OSSL_PARAM *paramdefs,
                                   const char *key, const char *value,
diff --git a/test/param_build_test.c b/test/param_build_test.c
index 6d54946cb9..9ac76d0115 100644
--- a/test/param_build_test.c
+++ b/test/param_build_test.c
@@ -190,128 +190,9 @@ err:
     return res;
 }
 
-static int template_static_params_test(int n)
-{
-    unsigned char data[1000], secure[500];
-    OSSL_PARAM_BLD bld;
-    OSSL_PARAM params[20], *p;
-    BIGNUM *bn = NULL, *bn_r = NULL;
-    BIGNUM *bn0 = NULL, *bn0_r = NULL;
-    const size_t bn_bytes = 200;
-    unsigned int i;
-    char *utf = NULL;
-    int res = 0;
-
-    ossl_param_bld_init(&bld);
-    if (!TEST_true(ossl_param_bld_push_uint(&bld, "i", 6))
-        || !TEST_ptr(bn = (n & 1) == 0 ? BN_new() : BN_secure_new())
-        || !TEST_true(BN_set_word(bn, 1337))
-        || !TEST_false(ossl_param_bld_push_BN_pad(&bld, "bn", bn, 0))
-        || !TEST_false(ossl_param_bld_push_BN_pad(&bld, "bn", bn, 1))
-        || !TEST_true(ossl_param_bld_push_BN_pad(&bld, "bn", bn, bn_bytes))
-        || !TEST_ptr(bn0 = BN_new())
-        || !TEST_true(ossl_param_bld_push_BN_pad(&bld, "bn0", bn0, 0))
-        || !TEST_true(ossl_param_bld_push_utf8_string(&bld, "utf8_s", "bar",
-                                                      0))
-        || !TEST_ptr(ossl_param_bld_to_param_ex(&bld, params,
-                                                OSSL_NELEM(params),
-                                                data, sizeof(data),
-                                                secure, sizeof(secure)))
-        /* Check unsigned int */
-        || !TEST_ptr(p = OSSL_PARAM_locate(params, "i"))
-        || !TEST_true(OSSL_PARAM_get_uint(p, &i))
-        || !TEST_str_eq(p->key, "i")
-        || !TEST_uint_eq(p->data_type, OSSL_PARAM_UNSIGNED_INTEGER)
-        || !TEST_size_t_eq(p->data_size, sizeof(int))
-        || !TEST_uint_eq(i, 6)
-        /* Check BIGNUM */
-        || !TEST_ptr(p = OSSL_PARAM_locate(params, "bn"))
-        || !TEST_true(OSSL_PARAM_get_BN(p, &bn_r))
-        || !TEST_str_eq(p->key, "bn")
-        || !TEST_uint_eq(p->data_type, OSSL_PARAM_UNSIGNED_INTEGER)
-        || !TEST_size_t_eq(p->data_size, bn_bytes)
-        || !TEST_uint_eq((unsigned int)BN_get_word(bn_r), 1337)
-        /* Check BIGNUM zero */
-        || !TEST_ptr(p = OSSL_PARAM_locate(params, "bn0"))
-        || !TEST_true(OSSL_PARAM_get_BN(p, &bn0_r))
-        || !TEST_str_eq(p->key, "bn0")
-        || !TEST_uint_eq(p->data_type, OSSL_PARAM_UNSIGNED_INTEGER)
-        || !TEST_size_t_eq(p->data_size, 0)
-        || !TEST_uint_eq((unsigned int)BN_get_word(bn0_r), 0)
-        /* Check UTF8 string */
-        || !TEST_ptr(p = OSSL_PARAM_locate(params, "utf8_s"))
-        || !TEST_str_eq(p->data, "bar")
-        || !TEST_true(OSSL_PARAM_get_utf8_string(p, &utf, 0))
-        || !TEST_str_eq(utf, "bar"))
-        goto err;
-    res = 1;
-err:
-    OPENSSL_free(utf);
-    BN_free(bn);
-    BN_free(bn_r);
-    BN_free(bn0);
-    BN_free(bn0_r);
-    return res;
-}
-
-static int template_static_fail_test(int n)
-{
-    unsigned char data[10000], secure[500];
-    OSSL_PARAM_BLD bld;
-    OSSL_PARAM prms[20];
-    BIGNUM *bn = NULL;
-    int res = 0;
-
-    ossl_param_bld_init(&bld);
-    if (!TEST_true(ossl_param_bld_push_uint(&bld, "i", 6))
-        || !TEST_ptr(bn = (n & 1) == 0 ? BN_new() : BN_secure_new())
-        || !TEST_true(BN_hex2bn(&bn, "ABCDEF78901234567890ABCDEF0987987654321"))
-        || !TEST_true(ossl_param_bld_push_BN(&bld, "bn", bn))
-        || !TEST_true(ossl_param_bld_push_utf8_string(&bld, "utf8_s", "abc",
-                                                      1000))
-        /* No OSSL_PARAMS */
-        || !TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, NULL, 0, data,
-                                                     sizeof(data), secure,
-                                                     sizeof(secure)))
-        /* Short OSSL_PARAMS */
-        || !TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, prms, 2,
-                                                     data, sizeof(data),
-                                                     secure, sizeof(secure)))
-        /* No normal data */
-        || !TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, prms,
-                                                     OSSL_NELEM(prms),
-                                                     NULL, 0, secure,
-                                                     sizeof(secure)))
-        /* Not enough normal data */
-        || !TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, prms,
-                                                     OSSL_NELEM(prms),
-                                                     data, 50, secure,
-                                                     sizeof(secure))))
-            goto err;
-        if ((n & 1) == 1) {
-            /* No secure data */
-            if (!TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, prms,
-                                                          OSSL_NELEM(prms),
-                                                          data, sizeof(data),
-                                                          NULL, 0))
-            /* Not enough secure data */
-            || !TEST_ptr_null(ossl_param_bld_to_param_ex(&bld, prms,
-                                                         OSSL_NELEM(prms),
-                                                         data, sizeof(data),
-                                                         secure, 4)))
-                goto err;
-        }
-    res = 1;
-err:
-    BN_free(bn);
-    return res;
-}
-
 int setup_tests(void)
 {
     ADD_TEST(template_public_test);
     ADD_TEST(template_private_test);
-    ADD_ALL_TESTS(template_static_params_test, 2);
-    ADD_ALL_TESTS(template_static_fail_test, 2);
     return 1;
 }
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 29e37b4a41..a87630b633 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -4688,7 +4688,6 @@ EC_KEY_new_ex                           ?	3_0_0	EXIST::FUNCTION:EC
 EC_KEY_new_by_curve_name_ex             ?	3_0_0	EXIST::FUNCTION:EC
 OPENSSL_hexstr2buf_ex                   ?	3_0_0	EXIST::FUNCTION:
 OPENSSL_buf2hexstr_ex                   ?	3_0_0	EXIST::FUNCTION:
-OSSL_PARAM_construct_from_text          ?	3_0_0	EXIST::FUNCTION:
 OSSL_PARAM_allocate_from_text           ?	3_0_0	EXIST::FUNCTION:
 EVP_MD_gettable_params                  ?	3_0_0	EXIST::FUNCTION:
 EVP_MD_CTX_settable_params              ?	3_0_0	EXIST::FUNCTION:


More information about the openssl-commits mailing list