diff options
author | Ingela Anderton Andin <[email protected]> | 2016-03-09 15:36:32 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2016-03-10 15:44:12 +0100 |
commit | 2102dcca65b21de96f983aa8549a539503253c2b (patch) | |
tree | 243c5dc7199b703bc50f28af54df3771b0830d4b /lib/public_key/src/public_key.erl | |
parent | e4fd76bdd9dd15547531947aaecf487385a6d796 (diff) | |
download | otp-2102dcca65b21de96f983aa8549a539503253c2b.tar.gz otp-2102dcca65b21de96f983aa8549a539503253c2b.tar.bz2 otp-2102dcca65b21de96f983aa8549a539503253c2b.zip |
public_key: Handle PEM encoded EC public keys
Also add missing test for PEM encoded private EC keys.
Diffstat (limited to 'lib/public_key/src/public_key.erl')
-rw-r--r-- | lib/public_key/src/public_key.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index a79badef24..a5944bd604 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -134,7 +134,8 @@ pem_entry_decode({'SubjectPublicKeyInfo', Der, _}) -> {params, DssParams} = der_decode('DSAParams', Params), {der_decode(KeyType, Key0), DssParams}; 'ECPoint' -> - der_decode(KeyType, Key0) + ECCParams = der_decode('EcpkParameters', Params), + {#'ECPoint'{point = Key0}, ECCParams} end; pem_entry_decode({Asn1Type, Der, not_encrypted}) when is_atom(Asn1Type), is_binary(Der) -> @@ -181,6 +182,13 @@ pem_entry_encode('SubjectPublicKeyInfo', Spki = {'SubjectPublicKeyInfo', {'AlgorithmIdentifier', ?'id-dsa', ParamDer}, KeyDer}, pem_entry_encode('SubjectPublicKeyInfo', Spki); +pem_entry_encode('SubjectPublicKeyInfo', + {#'ECPoint'{point = Key}, ECParam}) when is_binary(Key)-> + Params = der_encode('EcpkParameters',ECParam), + Spki = {'SubjectPublicKeyInfo', + {'AlgorithmIdentifier', ?'id-ecPublicKey', Params}, + Key}, + pem_entry_encode('SubjectPublicKeyInfo', Spki); pem_entry_encode(Asn1Type, Entity) when is_atom(Asn1Type) -> Der = der_encode(Asn1Type, Entity), {Asn1Type, Der, not_encrypted}. |