summaryrefslogtreecommitdiff
path: root/src/plop_compat.erl
blob: d59edf0c5c492fbf7e85b63205c4006dd3518ec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-module(plop_compat).
-export([unpack_spki/1, timestamp/0]).
-include_lib("public_key/include/public_key.hrl").

unpack_spki(SPKI) ->
    unpack_spki(erlang:system_info(otp_release), SPKI).
timestamp() ->
    timestamp(erlang:system_info(otp_release)).


unpack_spki("17", SPKI) ->
    #'SubjectPublicKeyInfo'{subjectPublicKey = {_, Octets},
                            algorithm = Algorithm} = SPKI,
    {Octets, Algorithm};
unpack_spki("18", SPKI) ->
    #'SubjectPublicKeyInfo'{subjectPublicKey = Octets,
                            algorithm = Algorithm} = SPKI,
    {Octets, Algorithm}.

%% <=R17: now/0, >=R18 timestamp/0
timestamp("17") ->
    erlang:now();
timestamp("18") ->
    erlang:timestamp().