diff options
author | Ingela Anderton Andin <[email protected]> | 2014-08-21 09:52:05 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2014-08-22 11:19:26 +0200 |
commit | f993ce5f68f875f95c24f085773e4a0916568e9d (patch) | |
tree | 10e9a21697097055be4647d7dd388a1bf1bb17ee /lib/public_key/src/public_key.erl | |
parent | 41bb781d809effb185a857b25009615bb9acbea7 (diff) | |
download | otp-f993ce5f68f875f95c24f085773e4a0916568e9d.tar.gz otp-f993ce5f68f875f95c24f085773e4a0916568e9d.tar.bz2 otp-f993ce5f68f875f95c24f085773e4a0916568e9d.zip |
public_key: Add PBES1 decoding support
Diffstat (limited to 'lib/public_key/src/public_key.erl')
-rw-r--r-- | lib/public_key/src/public_key.erl | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index a732455aa7..c70053d2d9 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -133,20 +133,19 @@ pem_entry_decode({Asn1Type, CryptDer, {Cipher, #'PBES2-params'{}}} = PemEntry, is_binary(CryptDer) andalso is_list(Cipher) -> do_pem_entry_decode(PemEntry, Password); -pem_entry_decode({Asn1Type, CryptDer, {Cipher, Salt}} = PemEntry, +pem_entry_decode({Asn1Type, CryptDer, {Cipher, {#'PBEParameter'{},_}}} = PemEntry, Password) when is_atom(Asn1Type) andalso is_binary(CryptDer) andalso - is_list(Cipher) andalso - is_binary(Salt) andalso - erlang:byte_size(Salt) == 8 -> + is_list(Cipher) -> do_pem_entry_decode(PemEntry, Password); -pem_entry_decode({Asn1Type, CryptDer, {"AES-128-CBC"=Cipher, IV}} = PemEntry, +pem_entry_decode({Asn1Type, CryptDer, {Cipher, Salt}} = PemEntry, Password) when is_atom(Asn1Type) andalso is_binary(CryptDer) andalso is_list(Cipher) andalso - is_binary(IV) andalso - erlang:byte_size(IV) == 16 -> - do_pem_entry_decode(PemEntry, Password). + is_binary(Salt) andalso + ((erlang:byte_size(Salt) == 8) or (erlang:byte_size(Salt) == 16)) -> + do_pem_entry_decode(PemEntry, Password). + %%-------------------------------------------------------------------- -spec pem_entry_encode(pki_asn1_type(), term()) -> pem_entry(). |