diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-04 13:53:53 +1000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-03-11 09:25:57 +1000 |
commit | 141cc94e44db93cded4ce3f0d97b9b5b928f43f2 (patch) | |
tree | 111a6e47c2a86347a6d969d00844a5b2dc8a5805 /test | |
parent | 7a45d51ce3268d16409405b9d54d7b4bb77a7fc3 (diff) |
Add a real type for OSSL_CORE_BIO which is distinct from and not castable to BIO
Providers (particularly the FIPS provider) needs access to BIOs from libcrypto.
Libcrypto is allowed to change the internal format of the BIO structure and it
is still expected to work with providers that were already built. This means
that the libcrypto BIO must be distinct from and not castable to the provider
side OSSL_CORE_BIO.
Unfortunately, this requirement was broken in both directions. This fixes
things by forcing the two to be different and any casts break loudly.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14419)
Diffstat (limited to 'test')
-rw-r--r-- | test/ossl_store_test.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/test/ossl_store_test.c b/test/ossl_store_test.c index 7424aed0dd..e06c0b55de 100644 --- a/test/ossl_store_test.c +++ b/test/ossl_store_test.c @@ -139,19 +139,21 @@ static int test_store_get_params(int idx) static int test_store_attach_unregistered_scheme(void) { int ret; - OSSL_STORE_CTX *store_ctx; - OSSL_PROVIDER *provider; - OSSL_LIB_CTX *libctx; - BIO *bio; - libctx = OSSL_LIB_CTX_new(); - provider = OSSL_PROVIDER_load(libctx, "default"); - bio = BIO_new_file("test/certs/sm2-root.crt", "r"); - - ret = TEST_ptr(store_ctx = OSSL_STORE_attach(bio, "file", libctx, NULL, - NULL, NULL, NULL, NULL)) && - TEST_int_ne(ERR_GET_LIB(ERR_peek_error()), ERR_LIB_OSSL_STORE) && - TEST_int_ne(ERR_GET_REASON(ERR_peek_error()), - OSSL_STORE_R_UNREGISTERED_SCHEME); + OSSL_STORE_CTX *store_ctx = NULL; + OSSL_PROVIDER *provider = NULL; + OSSL_LIB_CTX *libctx = NULL; + BIO *bio = NULL; + char *input = test_mk_file_path(inputdir, sm2file); + + ret = TEST_ptr(input) + && TEST_ptr(libctx = OSSL_LIB_CTX_new()) + && TEST_ptr(provider = OSSL_PROVIDER_load(libctx, "default")) + && TEST_ptr(bio = BIO_new_file(input, "r")) + && TEST_ptr(store_ctx = OSSL_STORE_attach(bio, "file", libctx, NULL, + NULL, NULL, NULL, NULL)) + && TEST_int_ne(ERR_GET_LIB(ERR_peek_error()), ERR_LIB_OSSL_STORE) + && TEST_int_ne(ERR_GET_REASON(ERR_peek_error()), + OSSL_STORE_R_UNREGISTERED_SCHEME); BIO_free(bio); OSSL_STORE_close(store_ctx); |