From 31e1927e1a163c72360b2aea8f87701e4da2a6fb Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 19 Jan 2016 17:24:06 +0100 Subject: Rename module compat -> catlfish_compat. Can't have two modules with the same name in a release. --- src/catlfish_compat.erl | 27 +++++++++++++++++++++++++++ src/compat.erl | 27 --------------------------- src/x509.erl | 4 ++-- 3 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 src/catlfish_compat.erl delete mode 100644 src/compat.erl diff --git a/src/catlfish_compat.erl b/src/catlfish_compat.erl new file mode 100644 index 0000000..55c2b2e --- /dev/null +++ b/src/catlfish_compat.erl @@ -0,0 +1,27 @@ +-module(catlfish_compat). +-export([unpack_issuer/1, unpack_signature/1]). +-include_lib("public_key/include/public_key.hrl"). + +unpack_issuer(Issuer) -> + unpack_issuer(erlang:system_info(otp_release), Issuer). +unpack_signature(Signature) -> + unpack_signature(erlang:system_info(otp_release), Signature). + +%% @doc Dig out alg, params and key from issuer. +unpack_issuer("17", Issuer) -> + #'SubjectPublicKeyInfo'{ + algorithm = #'AlgorithmIdentifier'{algorithm = Alg, parameters = Params}, + subjectPublicKey = {0, Key}} = Issuer, + {Alg, Params, Key}; +unpack_issuer("18", Issuer) -> + #'SubjectPublicKeyInfo'{ + algorithm = #'AlgorithmIdentifier'{algorithm = Alg, parameters = Params}, + subjectPublicKey = Key} = Issuer, + {Alg, Params, Key}. + +%% @doc Unpack a #'Certificate'.signature, return the signature. +unpack_signature("17", Signature) -> + {_, Sig} = Signature, + Sig; +unpack_signature("18", Signature) -> + Signature. diff --git a/src/compat.erl b/src/compat.erl deleted file mode 100644 index bbb58a1..0000000 --- a/src/compat.erl +++ /dev/null @@ -1,27 +0,0 @@ --module(compat). --export([unpack_issuer/1, unpack_signature/1]). --include_lib("public_key/include/public_key.hrl"). - -unpack_issuer(Issuer) -> - unpack_issuer(erlang:system_info(otp_release), Issuer). -unpack_signature(Signature) -> - unpack_signature(erlang:system_info(otp_release), Signature). - -%% @doc Dig out alg, params and key from issuer. -unpack_issuer("17", Issuer) -> - #'SubjectPublicKeyInfo'{ - algorithm = #'AlgorithmIdentifier'{algorithm = Alg, parameters = Params}, - subjectPublicKey = {0, Key}} = Issuer, - {Alg, Params, Key}; -unpack_issuer("18", Issuer) -> - #'SubjectPublicKeyInfo'{ - algorithm = #'AlgorithmIdentifier'{algorithm = Alg, parameters = Params}, - subjectPublicKey = Key} = Issuer, - {Alg, Params, Key}. - -%% @doc Unpack a #'Certificate'.signature, return the signature. -unpack_signature("17", Signature) -> - {_, Sig} = Signature, - Sig; -unpack_signature("18", Signature) -> - Signature. diff --git a/src/x509.erl b/src/x509.erl index 2d4cffa..e0d8ea7 100644 --- a/src/x509.erl +++ b/src/x509.erl @@ -171,7 +171,7 @@ signed_by_p(SubjectDer, IssuerDer) -> end. verify_sig(IssuerSPKI, {DigestOrPlainText, DigestType, Signature}) -> - {Alg, Params, Key0} = compat:unpack_issuer(IssuerSPKI), + {Alg, Params, Key0} = catlfish_compat:unpack_issuer(IssuerSPKI), KeyType = pubkey_cert_records:supportedPublicKeyAlgorithms(Alg), IssuerKey = case KeyType of @@ -193,7 +193,7 @@ verify_sig(IssuerSPKI, {DigestOrPlainText, DigestType, Signature}) -> %% Code from pubkey_cert:extract_verify_data/2. extract_verify_data(Cert, DerCert) -> PlainText = encoded_tbs_cert(DerCert), - Sig = compat:unpack_signature(Cert#'Certificate'.signature), + Sig = catlfish_compat:unpack_signature(Cert#'Certificate'.signature), SigAlgRecord = Cert#'Certificate'.signatureAlgorithm, SigAlg = SigAlgRecord#'AlgorithmIdentifier'.algorithm, try -- cgit v1.1