summaryrefslogtreecommitdiff
path: root/src/catlfish.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-08-17 17:46:46 +0200
committerLinus Nordberg <linus@nordu.net>2015-08-19 16:26:07 +0200
commitaa703d32d55717b4934c91cf187f0ed165196fd0 (patch)
treefcf5bb88410aab1eda0767cd00dd41cc8cb10acc /src/catlfish.erl
parent3464a089a9ccbac1a8bc92c8dfba402e7e307733 (diff)
Wrap entries in plop wrapper
Diffstat (limited to 'src/catlfish.erl')
-rw-r--r--src/catlfish.erl23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/catlfish.erl b/src/catlfish.erl
index d940147..68e96ea 100644
--- a/src/catlfish.erl
+++ b/src/catlfish.erl
@@ -293,27 +293,26 @@ entryhash_from_entry(PackedEntry) ->
%% Private functions.
-spec pack_entry(normal|precert, binary(), binary(), [binary()]) -> binary().
pack_entry(Type, MTLText, EndEntityCert, CertChain) ->
- list_to_binary(
- [tlv:encode(<<"MTL1">>, MTLText),
- tlv:encode(case Type of
- normal -> <<"EEC1">>;
- precert -> <<"PRC1">>
- end, EndEntityCert),
- tlv:encode(<<"CHN1">>,
- list_to_binary(
- [tlv:encode(<<"X509">>, E) || E <- CertChain]))]).
+ [{<<"MTL1">>, MTLText},
+ {case Type of
+ normal -> <<"EEC1">>;
+ precert -> <<"PRC1">>
+ end, EndEntityCert},
+ {<<"CHN1">>,
+ list_to_binary(
+ [tlv:encode(<<"X509">>, E) || E <- CertChain])}].
-spec unpack_entry(binary()) -> {normal|precert, binary(), binary(), [binary()]}.
unpack_entry(Entry) ->
- {<<"MTL1">>, MTLText, Rest1} = tlv:decode(Entry),
- {EECType, EndEntityCert, Rest2} = tlv:decode(Rest1),
+ [{<<"MTL1">>, MTLText}|Rest1] = Entry,
+ [{EECType, EndEntityCert}|Rest2] = Rest1,
Type = case EECType of
<<"EEC1">> ->
normal;
<<"PRC1">> ->
precert
end,
- {<<"CHN1">>, PackedChain, _Rest3} = tlv:decode(Rest2), % Ignore rest.
+ [{<<"CHN1">>, PackedChain}|_Rest3] = Rest2,
Chain = unpack_certchain(PackedChain),
{Type, MTLText, EndEntityCert, Chain}.