]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
DECODER: Add support for OSSL_FUNC_decoder_does_selection()
authorRichard Levitte <levitte@openssl.org>
Mon, 26 Oct 2020 12:08:54 +0000 (13:08 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 11 Nov 2020 10:42:06 +0000 (11:42 +0100)
OSSL_FUNC_decoder_does_selection() is a dispatchable decoder implementation
function that should return 1 if the given |selection| is supported by an
decoder implementation and 0 if not.  This can be used by libcrypto
functionality to figure out if an encoder implementation should be
considered or not.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13248)

crypto/encode_decode/decoder_meth.c
crypto/encode_decode/encoder_local.h
include/openssl/core_dispatch.h

index edbb140c44210adecb90ba7e2e14e639178d1dc8..0d389ac5a64b98d332491bb34e6110544bb4c8a9 100644 (file)
@@ -198,6 +198,11 @@ void *ossl_decoder_from_dispatch(int id, const OSSL_ALGORITHM *algodef,
                 decoder->settable_ctx_params =
                     OSSL_FUNC_decoder_settable_ctx_params(fns);
             break;
+        case OSSL_FUNC_DECODER_DOES_SELECTION:
+            if (decoder->does_selection == NULL)
+                decoder->does_selection =
+                    OSSL_FUNC_decoder_does_selection(fns);
+            break;
         case OSSL_FUNC_DECODER_DECODE:
             if (decoder->decode == NULL)
                 decoder->decode = OSSL_FUNC_decoder_decode(fns);
index 9378393a42789170cb9a36c403109d21dd52b455..18cddf50fb3257fe05d88a21a2173045a0511703 100644 (file)
@@ -46,6 +46,7 @@ struct ossl_decoder_st {
     OSSL_FUNC_decoder_gettable_params_fn *gettable_params;
     OSSL_FUNC_decoder_set_ctx_params_fn *set_ctx_params;
     OSSL_FUNC_decoder_settable_ctx_params_fn *settable_ctx_params;
+    OSSL_FUNC_decoder_does_selection_fn *does_selection;
     OSSL_FUNC_decoder_decode_fn *decode;
     OSSL_FUNC_decoder_export_object_fn *export_object;
 };
index 3b0cf3d3ed0ee38eedd1452938d7c59931843162..cc8e6712ede113737beb618b6306551f00edaa91 100644 (file)
@@ -789,8 +789,9 @@ OSSL_CORE_MAKE_FUNC(void, encoder_free_object, (void *obj))
 # define OSSL_FUNC_DECODER_GETTABLE_PARAMS             4
 # define OSSL_FUNC_DECODER_SET_CTX_PARAMS              5
 # define OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS         6
-# define OSSL_FUNC_DECODER_DECODE                     10
-# define OSSL_FUNC_DECODER_EXPORT_OBJECT              11
+# define OSSL_FUNC_DECODER_DOES_SELECTION             10
+# define OSSL_FUNC_DECODER_DECODE                     11
+# define OSSL_FUNC_DECODER_EXPORT_OBJECT              20
 OSSL_CORE_MAKE_FUNC(void *, decoder_newctx, (void *provctx))
 OSSL_CORE_MAKE_FUNC(void, decoder_freectx, (void *ctx))
 OSSL_CORE_MAKE_FUNC(int, decoder_get_params, (OSSL_PARAM params[]))
@@ -801,8 +802,10 @@ OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params,
 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params,
                     (void *provctx))
 
+OSSL_CORE_MAKE_FUNC(int, decoder_does_selection,
+                    (void *provctx, int selection))
 OSSL_CORE_MAKE_FUNC(int, decoder_decode,
-                    (void *ctx, OSSL_CORE_BIO *in,
+                    (void *ctx, OSSL_CORE_BIO *in, int selection,
                      OSSL_CALLBACK *metadata_cb, void *metadata_cbarg,
                      OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg))
 OSSL_CORE_MAKE_FUNC(int, decoder_export_object,