summaryrefslogtreecommitdiff
path: root/src/catlfish.erl
diff options
context:
space:
mode:
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}.