File 3701-ssl-public_key-Allow-binary-keyfile-passwords.patch of Package erlang
From f3d345e38bee4d684e0cd5571e02c5e7b4323a6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= <lhoguin@vmware.com>
Date: Mon, 29 Nov 2021 11:08:18 +0100
Subject: [PATCH] ssl/public_key: Allow binary keyfile passwords
---
lib/public_key/src/pubkey_pbe.erl | 4 ++--
lib/public_key/src/pubkey_pem.erl | 4 ++--
lib/public_key/src/public_key.erl | 4 ++--
lib/ssl/src/ssl.erl | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/public_key/src/pubkey_pbe.erl b/lib/public_key/src/pubkey_pbe.erl
index dc327567e4..bd9a7c07e4 100644
--- a/lib/public_key/src/pubkey_pbe.erl
+++ b/lib/public_key/src/pubkey_pbe.erl
@@ -33,7 +33,7 @@
%%====================================================================
%%--------------------------------------------------------------------
--spec encode(binary(), string(), string(), term()) -> binary().
+-spec encode(binary(), iodata(), string(), term()) -> binary().
%%
%% Description: Performs password based encoding
%%--------------------------------------------------------------------
@@ -57,7 +57,7 @@ encode(Data, Password, "AES-256-CBC"= Cipher, KeyDevParams) ->
crypto:crypto_one_time(aes_256_cbc, Key, IV, pbe_pad(Data, block_size(aes_256_cbc)), true).
%%--------------------------------------------------------------------
--spec decode(binary(), string(), string(), term()) -> binary().
+-spec decode(binary(), iodata(), string(), term()) -> binary().
%%
%% Description: Performs password based decoding
%%--------------------------------------------------------------------
diff --git a/lib/public_key/src/pubkey_pem.erl b/lib/public_key/src/pubkey_pem.erl
index 4aa965e14f..e28fd4019c 100644
--- a/lib/public_key/src/pubkey_pem.erl
+++ b/lib/public_key/src/pubkey_pem.erl
@@ -72,7 +72,7 @@ encode(PemEntries) ->
-spec decipher({public_key:pki_asn1_type(), DerEncrypted::binary(),
{Cipher :: string(), Salt :: iodata() | #'PBES2-params'{}
| {#'PBEParameter'{}, atom()}}},
- string()) -> Der::binary().
+ iodata()) -> Der::binary().
%%
%% Description: Deciphers a decrypted pem entry.
%%--------------------------------------------------------------------
@@ -82,7 +82,7 @@ decipher({_, DecryptDer, {Cipher, KeyDevParams}}, Password) ->
%%--------------------------------------------------------------------
-spec cipher(Der::binary(), {Cipher :: string(), Salt :: iodata() | #'PBES2-params'{}
| {#'PBEParameter'{}, atom()}},
- string()) -> binary().
+ iodata()) -> binary().
%%
%% Description: Ciphers a PEM entry
%%--------------------------------------------------------------------
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl
index a345c275f7..33772df96b 100644
--- a/lib/public_key/src/public_key.erl
+++ b/lib/public_key/src/public_key.erl
@@ -243,7 +243,7 @@ pem_entry_decode({Asn1Type, Der, not_encrypted}) when is_atom(Asn1Type),
-spec pem_entry_decode(PemEntry, Password) -> term() when
PemEntry :: pem_entry(),
- Password :: string() | fun(() -> string()).
+ Password :: iodata() | fun(() -> iodata()).
pem_entry_decode(PemEntry, PasswordFun) when is_function(PasswordFun) ->
pem_entry_decode(PemEntry, PasswordFun());
pem_entry_decode({Asn1Type, Der, not_encrypted}, _) when is_atom(Asn1Type),
@@ -313,7 +313,7 @@ pem_entry_encode(Asn1Type, Entity) when is_atom(Asn1Type) ->
Entity :: term(),
InfoPwd :: {CipherInfo,Password},
CipherInfo :: cipher_info(),
- Password :: string() .
+ Password :: iodata() .
pem_entry_encode(Asn1Type, Entity, {{Cipher, #'PBES2-params'{}} = CipherInfo,
Password}) when is_atom(Asn1Type) andalso
is_list(Password) andalso
diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl
index e158f77c1d..1084437ac1 100644
--- a/lib/ssl/src/ssl.erl
+++ b/lib/ssl/src/ssl.erl
@@ -349,7 +349,7 @@
key_id := crypto:key_id(),
password => crypto:password()}. % exported
-type key_pem() :: file:filename().
--type key_password() :: string() | fun(() -> string()).
+-type key_password() :: iodata() | fun(() -> iodata()).
-type cipher_suites() :: ciphers().
-type ciphers() :: [erl_cipher_suite()] |
string(). % (according to old API) exported
@@ -2290,7 +2290,7 @@ validate_option(partial_chain, Value, _)
when is_function(Value) ->
Value;
validate_option(password, Value, _)
- when is_list(Value) ->
+ when is_list(Value); is_binary(Value) ->
Value;
validate_option(password, Value, _)
when is_function(Value, 0) ->
--
2.31.1