summaryrefslogtreecommitdiff
path: root/src/catlfish_compat.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2016-01-19 17:24:06 +0100
committerLinus Nordberg <linus@nordu.net>2016-08-18 14:46:26 +0200
commit31e1927e1a163c72360b2aea8f87701e4da2a6fb (patch)
tree2c0f9e8afd0b9c54dfdef1e96377e668bb2f5718 /src/catlfish_compat.erl
parent0124ba48d6751b1d5cb4e8a26945562f4d1b05f3 (diff)
Rename module compat -> catlfish_compat.
Can't have two modules with the same name in a release.
Diffstat (limited to 'src/catlfish_compat.erl')
-rw-r--r--src/catlfish_compat.erl27
1 files changed, 27 insertions, 0 deletions
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.