]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
DECODER: Add function to set an OSSL_PASSPHRASE_CALLBACK type callback
authorRichard Levitte <levitte@openssl.org>
Sun, 2 Aug 2020 12:29:33 +0000 (14:29 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 24 Aug 2020 08:02:26 +0000 (10:02 +0200)
This makes it possible to use OSSL_DECODER in functions that are passed
a OSSL_PASSPHRASE_CALLBACK already.

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

crypto/encode_decode/decoder_pkey.c
doc/man3/OSSL_DECODER_CTX_new_by_EVP_PKEY.pod
include/openssl/decoder.h
util/libcrypto.num

index 92c0d5a6ea8b6e5999f1ca35435254e2c132316e..0bb548abceefb5f6aa13e22a55d3f1452064de11 100644 (file)
@@ -36,6 +36,13 @@ int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx,
     return ossl_pw_set_pem_password_cb(&ctx->pwdata, cb, cbarg);
 }
 
+int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx,
+                                       OSSL_PASSPHRASE_CALLBACK *cb,
+                                       void *cbarg)
+{
+    return ossl_pw_set_ossl_passphrase_cb(&ctx->pwdata, cb, cbarg);
+}
+
 /*
  * Support for OSSL_DECODER_CTX_new_by_EVP_PKEY:
  * The construct data, and collecting keymgmt information for it
index 4486e6b00163a3d5d10e7e66db5098f9a36fff50..620688e322f0a52500e135a73ac153cb478fd232 100644 (file)
@@ -5,7 +5,8 @@
 OSSL_DECODER_CTX_new_by_EVP_PKEY,
 OSSL_DECODER_CTX_set_passphrase,
 OSSL_DECODER_CTX_set_pem_password_cb,
-OSSL_DECODER_CTX_set_passphrase_ui
+OSSL_DECODER_CTX_set_passphrase_ui,
+OSSL_DECODER_CTX_set_passphrase_cb
 - Decoder routines to decode EVP_PKEYs
 
 =head1 SYNOPSIS
@@ -25,6 +26,9 @@ OSSL_DECODER_CTX_set_passphrase_ui
  int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx,
                                         const UI_METHOD *ui_method,
                                         void *ui_data);
+ int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx,
+                                        OSSL_PASSPHRASE_CALLBACK *cb,
+                                        void *cbarg);
 
 =head1 DESCRIPTION
 
@@ -55,29 +59,26 @@ pass phrase to use when decrypting the encoded private key.
 Alternatively, a pass phrase callback may be specified with the
 following functions.
 
-OSSL_DECODER_CTX_set_pem_password_cb() and
-OSSL_DECODER_CTX_set_passphrase_ui() set up a callback method that
+OSSL_DECODER_CTX_set_pem_password_cb(),
+OSSL_DECODER_CTX_set_passphrase_ui() and
+OSSL_DECODER_CTX_set_passphrase_cb() set up a callback method that
 the implementation can use to prompt for a pass phrase, giving the caller
 the choice of prefered pass phrase callback form.  These are called
 indirectly, through an internal B<OSSL_PASSPHRASE_CALLBACK> function.
 
-The internal B<OSSL_PASSPHRASE_CALLBACK> function caches the pass phrase, to
-be re-used in all decodings that are performed in the same
-decoding run
+The internal B<OSSL_PASSPHRASE_CALLBACK> function caches the pass phrase,
+to be re-used in all decodings that are performed in the same decoding run
 (for example, within one L<OSSL_DECODER_from_bio(3)> call).
 
-=for comment the name OSSL_DECODER_CTX_set_pem_password_cb() leaves
-open the future possibility of having a function where the caller can set a
-B<OSSL_PASSPHRASE_CALLBACK> method as another option.
-
 =head1 RETURN VALUES
 
 OSSL_DECODER_CTX_new_by_EVP_PKEY() returns a pointer to a
 B<OSSL_DECODER_CTX>, or NULL if it couldn't be created.
 
 OSSL_DECODER_CTX_set_passphrase(),
-OSSL_DECODER_CTX_set_pem_password_cb() and
-OSSL_DECODER_CTX_set_passphrase_ui()
+OSSL_DECODER_CTX_set_pem_password_cb(),
+OSSL_DECODER_CTX_set_passphrase_ui() and
+OSSL_DECODER_CTX_set_passphrase_cb()
 all return 1 on success, or 0 on failure.
 
 =head1 NOTES
index cb5a404b8934667bafa5efed67bd720edbf8a7e4..91dfca4a094875e4d46695dd6694213567f78e40 100644 (file)
@@ -58,6 +58,9 @@ int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx,
 int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx,
                                          pem_password_cb *cb,
                                          void *cbarg);
+int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx,
+                                       OSSL_PASSPHRASE_CALLBACK *cb,
+                                       void *cbarg);
 int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx,
                                        const UI_METHOD *ui_method,
                                        void *ui_data);
index 5cda5b3d8dcab1ead5c044e3d2706550441eb92c..99790a1b74c64cba9dee94fb9a6c01ec35e2fec0 100644 (file)
@@ -5283,3 +5283,4 @@ OSSL_STORE_LOADER_do_all_provided       ? 3_0_0   EXIST::FUNCTION:
 OSSL_STORE_LOADER_names_do_all          ?      3_0_0   EXIST::FUNCTION:
 OSSL_PARAM_get_utf8_string_ptr          ?      3_0_0   EXIST::FUNCTION:
 OSSL_PARAM_get_octet_string_ptr         ?      3_0_0   EXIST::FUNCTION:
+OSSL_DECODER_CTX_set_passphrase_cb      ?      3_0_0   EXIST::FUNCTION: