diff options
author | slontis <shane.lontis@oracle.com> | 2022-11-15 12:38:31 +1000 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-05-05 17:11:16 +0100 |
commit | bcd94b6335e37304a170d89977a2382fae370a97 (patch) | |
tree | c3e676015643d7aa82cdf9c6bac1381b0012abda /test | |
parent | f612673049b93387eb7f93c207aca821496da861 (diff) |
Add libctx to x931 keygen.
Added coverage test that failed without the change.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19677)
Diffstat (limited to 'test')
-rw-r--r-- | test/build.info | 7 | ||||
-rw-r--r-- | test/recipes/15-test_rsa.t | 9 | ||||
-rw-r--r-- | test/rsa_x931_test.c | 48 |
3 files changed, 62 insertions, 2 deletions
diff --git a/test/build.info b/test/build.info index 4de1c19d4d..996825c075 100644 --- a/test/build.info +++ b/test/build.info @@ -890,6 +890,13 @@ IF[{- !$disabled{tests} -}] INCLUDE[rsa_sp800_56b_test]=.. ../include ../crypto/rsa ../apps/include DEPEND[rsa_sp800_56b_test]=../libcrypto.a libtestutil.a + IF[{- !$disabled{'deprecated-3.0'} -}] + PROGRAMS{noinst}=rsa_x931_test + SOURCE[rsa_x931_test]=rsa_x931_test.c + INCLUDE[rsa_x931_test]=.. ../include ../apps/include + DEPEND[rsa_x931_test]=../libcrypto.a libtestutil.a + ENDIF + SOURCE[bn_internal_test]=bn_internal_test.c INCLUDE[bn_internal_test]=.. ../include ../crypto/bn ../apps/include DEPEND[bn_internal_test]=../libcrypto.a libtestutil.a diff --git a/test/recipes/15-test_rsa.t b/test/recipes/15-test_rsa.t index 420a57f8c1..c3c0bc34d6 100644 --- a/test/recipes/15-test_rsa.t +++ b/test/recipes/15-test_rsa.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the Apache License 2.0 (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy @@ -16,7 +16,7 @@ use OpenSSL::Test::Utils; setup("test_rsa"); -plan tests => 12; +plan tests => 14; require_ok(srctop_file('test', 'recipes', 'tconversion.pl')); @@ -33,6 +33,11 @@ sub run_rsa_tests { "$cmd -check" ); SKIP: { + skip "Skipping Deprecated rsa_x931_test", 1 if disabled("deprecated-3.0"); + ok(run(test(['rsa_x931_test'])), "RSA X931 test"); + }; + + SKIP: { skip "Skipping $cmd conversion test", 3 if disabled("rsa"); diff --git a/test/rsa_x931_test.c b/test/rsa_x931_test.c new file mode 100644 index 0000000000..5f3396a3a0 --- /dev/null +++ b/test/rsa_x931_test.c @@ -0,0 +1,48 @@ +/* + * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/deprecated.h" + +#include <openssl/rsa.h> +#include <openssl/bn.h> +#include "crypto/rsa.h" +#include "testutil.h" + +static OSSL_PROVIDER *prov_null = NULL; +static OSSL_LIB_CTX *libctx = NULL; + +static int test_rsa_x931_keygen(void) +{ + int ret = 0; + BIGNUM *e = NULL; + RSA *rsa = NULL; + + ret = TEST_ptr(rsa = ossl_rsa_new_with_ctx(libctx)) + && TEST_ptr(e = BN_new()) + && TEST_int_eq(BN_set_word(e, RSA_F4), 1) + && TEST_int_eq(RSA_X931_generate_key_ex(rsa, 1024, e, NULL), 1); + BN_free(e); + RSA_free(rsa); + return ret; +} + +int setup_tests(void) +{ + if (!test_get_libctx(&libctx, &prov_null, NULL, NULL, NULL)) + return 0; + + ADD_TEST(test_rsa_x931_keygen); + return 1; +} + +void cleanup_tests(void) +{ + OSSL_PROVIDER_unload(prov_null); + OSSL_LIB_CTX_free(libctx); +} |