diff options
-rw-r--r-- | src/plop_compat.erl | 15 | ||||
-rw-r--r-- | src/sign.erl | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/plop_compat.erl b/src/plop_compat.erl new file mode 100644 index 0000000..d9f3620 --- /dev/null +++ b/src/plop_compat.erl @@ -0,0 +1,15 @@ +-module(plop_compat). +-export([unpack_spki/1]). +-include_lib("public_key/include/public_key.hrl"). + +unpack_spki(SPKI) -> + unpack_spki(erlang:system_info(otp_release), SPKI). + +unpack_spki("17", SPKI) -> + #'SubjectPublicKeyInfo'{subjectPublicKey = {_, Octets}, + algorithm = Algorithm} = SPKI, + {Octets, Algorithm}; +unpack_spki("18", SPKI) -> + #'SubjectPublicKeyInfo'{subjectPublicKey = Octets, + algorithm = Algorithm} = SPKI, + {Octets, Algorithm}. diff --git a/src/sign.erl b/src/sign.erl index ced218a..2c55429 100644 --- a/src/sign.erl +++ b/src/sign.erl @@ -92,8 +92,7 @@ read_keyfile_ec_logid(KeyFile) -> pem_entry_decode({'SubjectPublicKeyInfo', Der, _}) -> SPKI = public_key:der_decode('SubjectPublicKeyInfo', Der), - #'SubjectPublicKeyInfo'{subjectPublicKey = {_, Octets}, - algorithm = Algorithm} = SPKI, + {Octets, Algorithm} = plop_compat:unpack_spki(SPKI), #'AlgorithmIdentifier'{parameters = ECParams} = Algorithm, Params = public_key:der_decode('EcpkParameters', ECParams), Point = #'ECPoint'{point = Octets}, |