aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public_key/src/public_key.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2016-03-16 10:03:53 +0100
committerIngela Anderton Andin <[email protected]>2016-03-16 10:03:53 +0100
commitcee5b753e8dbd294b2677f684c404d16dcfcd643 (patch)
tree3636afffae2c3fe65b47e146ec66f06eafaefd68 /lib/public_key/src/public_key.erl
parent12c3609f15dbe367684ecb506b61f07c15205c51 (diff)
parent2102dcca65b21de96f983aa8549a539503253c2b (diff)
downloadotp-cee5b753e8dbd294b2677f684c404d16dcfcd643.tar.gz
otp-cee5b753e8dbd294b2677f684c404d16dcfcd643.tar.bz2
otp-cee5b753e8dbd294b2677f684c404d16dcfcd643.zip
Merge branch 'ia/public_key/EC-public_key/OTP-13408'
* ia/public_key/EC-public_key/OTP-13408: public_key: Handle PEM encoded EC public keys
Diffstat (limited to 'lib/public_key/src/public_key.erl')
-rw-r--r--lib/public_key/src/public_key.erl10
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}.