diff options
author | Pauli <paul.dale@oracle.com> | 2020-03-26 00:28:01 +0100 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-03-28 03:27:22 +0100 |
commit | 6d4e6009d27712a405e1e3a4c33fb8a8566f134a (patch) | |
tree | 09d94a8c8f8f6f493cc758b6fd704837be82cb8c /test/param_build_test.c | |
parent | NEWS: note OSSL_PARAM_BLD API as public. (diff) | |
download | openssl-6d4e6009d27712a405e1e3a4c33fb8a8566f134a.tar.xz openssl-6d4e6009d27712a405e1e3a4c33fb8a8566f134a.zip |
Param build: make structures opaque.
Since this is public, it is best to make the underlying structure opaque.
This means converting from stack allocation to dynamic allocation for all
usages.
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/11390)
Diffstat (limited to 'test/param_build_test.c')
-rw-r--r-- | test/param_build_test.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/test/param_build_test.c b/test/param_build_test.c index cbb4456bd7..9b20e33360 100644 --- a/test/param_build_test.c +++ b/test/param_build_test.c @@ -16,7 +16,7 @@ static int template_public_test(void) { - OSSL_PARAM_BLD bld; + OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new(); OSSL_PARAM *params = NULL, *p; BIGNUM *bn = NULL, *bn_res = NULL; int i; @@ -28,20 +28,20 @@ static int template_public_test(void) const char *cutf; int res = 0; - OSSL_PARAM_BLD_init(&bld); - if (!TEST_true(OSSL_PARAM_BLD_push_int(&bld, "i", -6)) - || !TEST_true(OSSL_PARAM_BLD_push_long(&bld, "l", 42)) - || !TEST_true(OSSL_PARAM_BLD_push_int32(&bld, "i32", 1532)) - || !TEST_true(OSSL_PARAM_BLD_push_int64(&bld, "i64", -9999999)) - || !TEST_true(OSSL_PARAM_BLD_push_double(&bld, "d", 1.61803398875)) + if (!TEST_ptr(bld) + || !TEST_true(OSSL_PARAM_BLD_push_int(bld, "i", -6)) + || !TEST_true(OSSL_PARAM_BLD_push_long(bld, "l", 42)) + || !TEST_true(OSSL_PARAM_BLD_push_int32(bld, "i32", 1532)) + || !TEST_true(OSSL_PARAM_BLD_push_int64(bld, "i64", -9999999)) + || !TEST_true(OSSL_PARAM_BLD_push_double(bld, "d", 1.61803398875)) || !TEST_ptr(bn = BN_new()) || !TEST_true(BN_set_word(bn, 1729)) - || !TEST_true(OSSL_PARAM_BLD_push_BN(&bld, "bignumber", bn)) - || !TEST_true(OSSL_PARAM_BLD_push_utf8_string(&bld, "utf8_s", "foo", + || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, "bignumber", bn)) + || !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld, "utf8_s", "foo", sizeof("foo"))) - || !TEST_true(OSSL_PARAM_BLD_push_utf8_ptr(&bld, "utf8_p", "bar-boom", + || !TEST_true(OSSL_PARAM_BLD_push_utf8_ptr(bld, "utf8_p", "bar-boom", 0)) - || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(&bld)) + || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) /* Check int */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "i")) || !TEST_true(OSSL_PARAM_get_int(p, &i)) @@ -95,7 +95,8 @@ static int template_public_test(void) goto err; res = 1; err: - OSSL_PARAM_BLD_free(params); + OSSL_PARAM_BLD_free_params(params); + OSSL_PARAM_BLD_free(bld); OPENSSL_free(utf); BN_free(bn); BN_free(bn_res); @@ -106,7 +107,7 @@ static int template_private_test(void) { static int data1[] = { 2, 3, 5, 7, 11, 15, 17 }; static unsigned char data2[] = { 2, 4, 6, 8, 10 }; - OSSL_PARAM_BLD bld; + OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new(); OSSL_PARAM *params = NULL, *p; unsigned int i; unsigned long int l; @@ -116,20 +117,20 @@ static int template_private_test(void) BIGNUM *bn = NULL, *bn_res = NULL; int res = 0; - OSSL_PARAM_BLD_init(&bld); - if (!TEST_true(OSSL_PARAM_BLD_push_uint(&bld, "i", 6)) - || !TEST_true(OSSL_PARAM_BLD_push_ulong(&bld, "l", 42)) - || !TEST_true(OSSL_PARAM_BLD_push_uint32(&bld, "i32", 1532)) - || !TEST_true(OSSL_PARAM_BLD_push_uint64(&bld, "i64", 9999999)) - || !TEST_true(OSSL_PARAM_BLD_push_size_t(&bld, "st", 65537)) + if (!TEST_ptr(bld) + || !TEST_true(OSSL_PARAM_BLD_push_uint(bld, "i", 6)) + || !TEST_true(OSSL_PARAM_BLD_push_ulong(bld, "l", 42)) + || !TEST_true(OSSL_PARAM_BLD_push_uint32(bld, "i32", 1532)) + || !TEST_true(OSSL_PARAM_BLD_push_uint64(bld, "i64", 9999999)) + || !TEST_true(OSSL_PARAM_BLD_push_size_t(bld, "st", 65537)) || !TEST_ptr(bn = BN_secure_new()) || !TEST_true(BN_set_word(bn, 1729)) - || !TEST_true(OSSL_PARAM_BLD_push_BN(&bld, "bignumber", bn)) - || !TEST_true(OSSL_PARAM_BLD_push_octet_string(&bld, "oct_s", data1, + || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, "bignumber", bn)) + || !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld, "oct_s", data1, sizeof(data1))) - || !TEST_true(OSSL_PARAM_BLD_push_octet_ptr(&bld, "oct_p", data2, + || !TEST_true(OSSL_PARAM_BLD_push_octet_ptr(bld, "oct_p", data2, sizeof(data2))) - || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(&bld)) + || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) /* Check unsigned int */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "i")) || !TEST_true(OSSL_PARAM_get_uint(p, &i)) @@ -184,7 +185,8 @@ static int template_private_test(void) goto err; res = 1; err: - OSSL_PARAM_BLD_free(params); + OSSL_PARAM_BLD_free_params(params); + OSSL_PARAM_BLD_free(bld); BN_free(bn); BN_free(bn_res); return res; |