summaryrefslogtreecommitdiff
path: root/src/compat.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2016-01-19 16:55:12 +0100
committerLinus Nordberg <linus@nordu.net>2016-08-18 14:46:26 +0200
commit748d1d453480df3108d1465b8c4b8893ca97c52b (patch)
tree5b77904aa8d00830ef6359b117da4c07a0a15adb /src/compat.erl
parentfcba73af863920411aa62dbc66793f95ee6cc1f6 (diff)
Add compatibility layer for digging around in non-public data structures.
Diffstat (limited to 'src/compat.erl')
-rw-r--r--src/compat.erl29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/compat.erl b/src/compat.erl
new file mode 100644
index 0000000..bc3101d
--- /dev/null
+++ b/src/compat.erl
@@ -0,0 +1,29 @@
+-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.
+
+