[erlang-bugs] Failure to decode EC private key via public_key application

Papadomitsos Panagiotis priestjim@REDACTED
Sat Aug 1 00:43:19 CEST 2015


Hi all,

I've been trying to read an EC password protected private key in pem 
format into Erlang but I've been getting this error:

{ok, M} = file:read_file("m.key"),
[Pem] = public_key:pem_decode(M),
exception error: no function clause matching
                  pubkey_pbe:cipher({'PBES2-params_encryptionScheme',
                                     {2,16,840,1,101,3,4,1,42},
                                     {asn1_OPENTYPE,
<<4,16,255,71,145,188,80,110,6,134,174,
100,0,176,46,76,243,205>>}}) (pubkey_pbe.erl, line 271)
   in function  pubkey_pbe:decrypt_parameters/2 (pubkey_pbe.erl, line 185)
   in call from pubkey_pem:decode_encrypted_private_keyinfo/1 
(pubkey_pem.erl, line 146)
   in call from pubkey_pem:decode_pem_entries/2 (pubkey_pem.erl, line 121)

This is in Erlang 18.0.2, both on MacOS 10.10.4 and Ubuntu 14.04. 
OpenSSL is 1.0.1f.

A sample key in the format that causes the issue is:

-----BEGIN ENCRYPTED PRIVATE KEY-----
MIHeMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAhIMXJLXX+miQICCAAw
HQYJYIZIAWUDBAEqBBD/R5G8UG4Ghq5kALAuTPPNBIGQSk3UlBws+Y/BiJg5KIyV
IuqsCngm+l10zFNFVrFQNlFQ8+nQHuHYOMXk5UCoqMPkAVD+xSJ1pj00wQiQ85Y5
XS3B9YObYN5iSzFOyTe4S9+qJtW2OI5VQ5gW7xq9LMUKBwJzkpsd9w5lyOgN9/Gt
Meq24+3LkqP8DjB7L5fc9U+1F9+BMoUuE+HiLBy6Sww3
-----END ENCRYPTED PRIVATE KEY-----

-- 
Panagiotis Papadomitsos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150731/54d26844/attachment.htm>


More information about the erlang-bugs mailing list