diff options
author | Richard Levitte <levitte@openssl.org> | 2020-08-02 12:46:00 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-03 17:48:32 +0200 |
commit | 63f187cfedd21550094b5d69a52f7f617545b209 (patch) | |
tree | aa2b6649e267d28c516d843b5e94f376ad6b3a80 /include | |
parent | 16feca71544681cabf873fecd3f860f9853bdf07 (diff) |
STORE: Add a built-in 'file:' storemgmt implementation (loader)
This replaces the older 'file:' loader that is now an engine.
It's still possible to use the older 'file:' loader by explicitly
using the engine, and tests will remain for it as long as ENGINEs are
still supported (even through deprecated).
To support this storemgmt implementation, a few internal OSSL_DECODER
modifications are needed:
- An internal function that implements most of
OSSL_DECODER_CTX_new_by_EVP_PKEY(), but operates on an already
existing OSSL_DECODER_CTX instead of allocating a new one.
- Allow direct creation of a OSSL_DECODER from an OSSL_ALGORITHM.
It isn't attached to any provider, and is only used internally, to
simply catch any DER encoded object to be passed back to the
object callback with no further checking. This implementation
becomes the last resort decoder, when all "normal"
decodation attempts (i.e. those that are supposed to result
in an OpenSSL object of some sort) have failed.
Because file_store_attach() uses BIO_tell(), we must also support
BIO_ctrl() as a libcrypto upcall.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/decoder.h | 40 | ||||
-rw-r--r-- | include/openssl/core_dispatch.h | 3 | ||||
-rw-r--r-- | include/openssl/err.h | 5 |
3 files changed, 46 insertions, 2 deletions
diff --git a/include/crypto/decoder.h b/include/crypto/decoder.h new file mode 100644 index 0000000000..b465752971 --- /dev/null +++ b/include/crypto/decoder.h @@ -0,0 +1,40 @@ +/* + * Copyright 2020 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 + */ + +#ifndef OSSL_CRYPTO_DECODER_H +# define OSSL_CRYPTO_DECODER_H + +# include <openssl/decoder.h> + +OSSL_DECODER *ossl_decoder_fetch_by_number(OPENSSL_CTX *libctx, + int id, + const char *properties); + +/* + * These are specially made for the 'file:' provider-native loader, which + * uses this to install a DER to anything decoder, which doesn't do much + * except read a DER blob and pass it on as a provider object abstraction + * (provider-object(7)). + */ +void *ossl_decoder_from_dispatch(int id, const OSSL_ALGORITHM *algodef, + OSSL_PROVIDER *prov); + +OSSL_DECODER_INSTANCE * +ossl_decoder_instance_new(OSSL_DECODER *decoder, void *decoderctx); +void ossl_decoder_instance_free(OSSL_DECODER_INSTANCE *decoder_inst); +int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_INSTANCE *di); + +int ossl_decoder_ctx_setup_for_EVP_PKEY(OSSL_DECODER_CTX *ctx, + EVP_PKEY **pkey, + OPENSSL_CTX *libctx, + const char *propquery); + +#endif + diff --git a/include/openssl/core_dispatch.h b/include/openssl/core_dispatch.h index b21fe559f7..ac83f88cc4 100644 --- a/include/openssl/core_dispatch.h +++ b/include/openssl/core_dispatch.h @@ -137,6 +137,7 @@ OSSL_CORE_MAKE_FUNC(void, #define OSSL_FUNC_BIO_VSNPRINTF 46 #define OSSL_FUNC_BIO_PUTS 47 #define OSSL_FUNC_BIO_GETS 48 +#define OSSL_FUNC_BIO_CTRL 49 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename, @@ -153,6 +154,8 @@ OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format, va_list args)) OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf, (char *buf, size_t n, const char *fmt, va_list args)) +OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, (OSSL_CORE_BIO *bio, + int cmd, long num, void *ptr)) #define OSSL_FUNC_SELF_TEST_CB 100 OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX *ctx, OSSL_CALLBACK **cb, diff --git a/include/openssl/err.h b/include/openssl/err.h index 497436d2c5..3e3b64b158 100644 --- a/include/openssl/err.h +++ b/include/openssl/err.h @@ -113,8 +113,8 @@ struct err_state_st { # define ERR_LIB_CRMF 56 # define ERR_LIB_PROV 57 # define ERR_LIB_CMP 58 -# define ERR_LIB_OSSL_ENCODER 59 -# define ERR_LIB_OSSL_DECODER 60 +# define ERR_LIB_OSSL_ENCODER 59 +# define ERR_LIB_OSSL_DECODER 60 # define ERR_LIB_HTTP 61 # define ERR_LIB_USER 128 @@ -304,6 +304,7 @@ static ossl_inline int ERR_FATAL_ERROR(unsigned long errcode) # define ERR_R_UI_LIB ERR_LIB_UI/* 40 */ # define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */ # define ERR_R_OSSL_STORE_LIB ERR_LIB_OSSL_STORE/* 44 */ +# define ERR_R_OSSL_DECODER_LIB ERR_LIB_OSSL_DECODER/* 60 */ /* * global reason codes, range 64..99 (sub-system specific codes start at 100) |