From faa64bca9f59b4390aed93dca75e53c3cacddc4a Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sun, 26 Jul 2020 09:21:29 +0200 Subject: [PATCH] STORE: Add missing function OSSL_STORE_LOADER_set_open_with_libctx() Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/12512) --- crypto/store/store_register.c | 8 ++++ doc/man3/OSSL_STORE_LOADER.pod | 86 +++++++++++++++++++++------------- doc/man3/OSSL_STORE_open.pod | 2 +- include/openssl/store.h | 3 ++ util/libcrypto.num | 1 + util/other.syms | 1 + 6 files changed, 68 insertions(+), 33 deletions(-) diff --git a/crypto/store/store_register.c b/crypto/store/store_register.c index 4fbf459afa5..f5106f00772 100644 --- a/crypto/store/store_register.c +++ b/crypto/store/store_register.c @@ -71,6 +71,14 @@ int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, return 1; } +int OSSL_STORE_LOADER_set_open_with_libctx + (OSSL_STORE_LOADER *loader, + OSSL_STORE_open_with_libctx_fn open_with_libctx_function) +{ + loader->open_with_libctx = open_with_libctx_function; + return 1; +} + int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader, OSSL_STORE_attach_fn attach_function) { diff --git a/doc/man3/OSSL_STORE_LOADER.pod b/doc/man3/OSSL_STORE_LOADER.pod index 64b15c18c80..3b6c178a9b5 100644 --- a/doc/man3/OSSL_STORE_LOADER.pod +++ b/doc/man3/OSSL_STORE_LOADER.pod @@ -4,14 +4,15 @@ OSSL_STORE_LOADER, OSSL_STORE_LOADER_CTX, OSSL_STORE_LOADER_new, OSSL_STORE_LOADER_get0_engine, OSSL_STORE_LOADER_get0_scheme, -OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_attach, -OSSL_STORE_LOADER_set_ctrl, OSSL_STORE_LOADER_set_expect, -OSSL_STORE_LOADER_set_find, OSSL_STORE_LOADER_set_load, -OSSL_STORE_LOADER_set_eof, OSSL_STORE_LOADER_set_error, -OSSL_STORE_LOADER_set_close, +OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_open_with_libctx, +OSSL_STORE_LOADER_set_attach, OSSL_STORE_LOADER_set_ctrl, +OSSL_STORE_LOADER_set_expect, OSSL_STORE_LOADER_set_find, +OSSL_STORE_LOADER_set_load, OSSL_STORE_LOADER_set_eof, +OSSL_STORE_LOADER_set_error, OSSL_STORE_LOADER_set_close, OSSL_STORE_LOADER_free, OSSL_STORE_register_loader, OSSL_STORE_unregister_loader, -OSSL_STORE_open_fn, OSSL_STORE_attach_fn, OSSL_STORE_ctrl_fn, +OSSL_STORE_open_fn, OSSL_STORE_open_with_libctx_fn, +OSSL_STORE_attach_fn, OSSL_STORE_ctrl_fn, OSSL_STORE_expect_fn, OSSL_STORE_find_fn, OSSL_STORE_load_fn, OSSL_STORE_eof_fn, OSSL_STORE_error_fn, OSSL_STORE_close_fn - Types and functions to manipulate, register and @@ -36,6 +37,11 @@ unregister STORE loaders for different URI schemes const char *uri, const UI_METHOD *ui_method, void *ui_data); int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *store_loader, OSSL_STORE_open_fn store_open_function); + typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_with_libctx_fn)( + const char *uri, const UI_METHOD *ui_method, void *ui_data); + int OSSL_STORE_LOADER_set_open_with_libctx + (OSSL_STORE_LOADER *store_loader, + OSSL_STORE_open_with_libctx_fn store_open_with_libctx_function); typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn) (const OSSL_STORE_LOADER *loader, BIO *bio, OPENSSL_CTX *libctx, const char *propq, @@ -81,34 +87,42 @@ schemes they support. B is the type to hold a loader. It contains a scheme and the functions needed to implement -OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof(), OSSL_STORE_error() and -OSSL_STORE_close() for this scheme. +OSSL_STORE_open(), OSSL_STORE_open_with_libctx(), OSSL_STORE_load(), +OSSL_STORE_eof(), OSSL_STORE_error() and OSSL_STORE_close() for this +scheme. B is a type template, to be defined by each loader using B. -B, B, B, -B, B, B, -and B +B, B, +B, B, B, +B, B, and B are the function pointer types used within a STORE loader. The functions pointed at define the functionality of the given loader. =over 4 -=item B +=item B and B -This function takes a URI and is expected to interpret it in the best -manner possible according to the scheme the loader implements, it also -takes a B and associated data, to be used any time -something needs to be prompted for. +B takes a URI and is expected to +interpret it in the best manner possible according to the scheme the +loader implements. It also takes a B and associated data, +to be used any time something needs to be prompted for, as well as a +library context I with an associated property query I, +to be used when fetching necessary algorithms to perform the loads. Furthermore, this function is expected to initialize what needs to be -initialized, to create a private data store (B, see -above), and to return it. +initialized, to create a private data store (B, +see above), and to return it. If something goes wrong, this function is expected to return NULL. -=item B +B does the same thing as +B but uses NULL for the library +context I and property query I. + +=item B -This function takes a B, otherwise works like B. +This function takes a B, otherwise works like +B. =item B @@ -200,6 +214,9 @@ OSSL_STORE_LOADER_get0_scheme() returns the scheme of the B. OSSL_STORE_LOADER_set_open() sets the opener function for the B. +OSSL_STORE_LOADER_set_open_with_libctx() sets the opener with library context +function for the I. + OSSL_STORE_LOADER_set_attach() sets the attacher function for the B. @@ -220,9 +237,10 @@ B. OSSL_STORE_LOADER_free() frees the given B. -OSSL_STORE_register_loader() register the given B and thereby -makes it available for use with OSSL_STORE_open(), OSSL_STORE_load(), -OSSL_STORE_eof() and OSSL_STORE_close(). +OSSL_STORE_register_loader() register the given B and +thereby makes it available for use with OSSL_STORE_open(), +OSSL_STORE_open_with_libctx(), OSSL_STORE_load(), OSSL_STORE_eof() +and OSSL_STORE_close(). OSSL_STORE_unregister_loader() unregister the store loader for the given B. @@ -233,18 +251,20 @@ The B scheme has built in support. =head1 RETURN VALUES -The functions with the types B, B, -B, -B, B and B have the -same return values as OSSL_STORE_open(), OSSL_STORE_ctrl(), OSSL_STORE_expect(), +The functions with the types B, +B, B, +B, B, B +and B have the same return values as OSSL_STORE_open(), +OSSL_STORE_open_with_libctx(), OSSL_STORE_ctrl(), OSSL_STORE_expect(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close(), respectively. OSSL_STORE_LOADER_new() returns a pointer to a B on success, or B on failure. -OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_ctrl(), -OSSL_STORE_LOADER_set_load(), OSSL_STORE_LOADER_set_eof() and -OSSL_STORE_LOADER_set_close() return 1 on success, or 0 on failure. +OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_open_with_libctx(), +OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(), +OSSL_STORE_LOADER_set_eof() and OSSL_STORE_LOADER_set_close() return 1 +on success, or 0 on failure. OSSL_STORE_register_loader() returns 1 on success, or 0 on failure. @@ -253,11 +273,13 @@ or B on failure. =head1 SEE ALSO -L, L +L, L, L =head1 HISTORY -OSSL_STORE_LOADER(), OSSL_STORE_LOADER_CTX(), OSSL_STORE_LOADER_new(), +OSSL_STORE_open_with_libctx_fn() was added in OpenSSL 3.0. + +B, B, OSSL_STORE_LOADER_new(), OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(), OSSL_STORE_LOADER_set_eof(), OSSL_STORE_LOADER_set_close(), diff --git a/doc/man3/OSSL_STORE_open.pod b/doc/man3/OSSL_STORE_open.pod index ef1a9341946..ee885012f8f 100644 --- a/doc/man3/OSSL_STORE_open.pod +++ b/doc/man3/OSSL_STORE_open.pod @@ -161,7 +161,7 @@ L OSSL_STORE_open_with_libctx() was added in OpenSSL 3.0. -OSSL_STORE_CTX(), OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(), +B, OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(), OSSL_STORE_ctrl(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close() were added in OpenSSL 1.1.1. diff --git a/include/openssl/store.h b/include/openssl/store.h index b75c79868cb..64a36672319 100644 --- a/include/openssl/store.h +++ b/include/openssl/store.h @@ -258,6 +258,9 @@ typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_with_libctx_fn) int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, OSSL_STORE_open_fn open_function); +int OSSL_STORE_LOADER_set_open_with_libctx + (OSSL_STORE_LOADER *loader, + OSSL_STORE_open_with_libctx_fn open_with_libctx_function); typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn) (const OSSL_STORE_LOADER *loader, BIO *bio, OPENSSL_CTX *libctx, const char *propq, diff --git a/util/libcrypto.num b/util/libcrypto.num index 549ab0a7c7e..54c28ad6886 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -5272,3 +5272,4 @@ PEM_read_bio_PUBKEY_ex ? 3_0_0 EXIST::FUNCTION: PEM_read_PUBKEY_ex ? 3_0_0 EXIST::FUNCTION:STDIO PEM_read_bio_Parameters_ex ? 3_0_0 EXIST::FUNCTION: EC_GROUP_new_from_params ? 3_0_0 EXIST::FUNCTION:EC +OSSL_STORE_LOADER_set_open_with_libctx ? 3_0_0 EXIST::FUNCTION: diff --git a/util/other.syms b/util/other.syms index 97f71906dab..964e09f0bdc 100644 --- a/util/other.syms +++ b/util/other.syms @@ -66,6 +66,7 @@ OSSL_STORE_eof_fn datatype OSSL_STORE_error_fn datatype OSSL_STORE_load_fn datatype OSSL_STORE_open_fn datatype +OSSL_STORE_open_with_libctx_fn datatype OSSL_STORE_post_process_info_fn datatype OSSL_trace_cb datatype PROFESSION_INFO datatype -- 2.47.2