Remove unused ossl_param_bld_to_param_ex() function.
authorPauli <paul.dale@oracle.com>
Mon, 10 Feb 2020 23:19:19 +0000 (09:19 +1000)
committerPauli <paul.dale@oracle.com>
Wed, 12 Feb 2020 09:45:42 +0000 (19:45 +1000)
The recently introduced ossl_param_bld_to_param_ex() function is only
called by the unit tests.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11053)

crypto/param_build.c
doc/internal/man3/ossl_param_bld_init.pod
include/internal/param_build.h
test/param_build_test.c

index 21bed31393fd8be89acc27e2a6acf74aadb69882..7c3b1a597a5d1ff47ce63edac760872e3d5fcce1 100644 (file)
@@ -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;
-}
index 545eaf141549f4787e8575944619cba7903ede65..110192fbe0455462c5165313c748161458798426 100644 (file)
@@ -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.
index ac1945f6f6bef8c509bdbdbe15782b9f38abce6a..59104b93aafdea22f1c96363fc85cc77859c7ac0 100644 (file)
@@ -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,
index 6d54946cb9f12370ce997c35612d26d99cc579de..9ac76d01150039e3257cb35467c67fd40f1ec108 100644 (file)
@@ -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;
 }