From aa703d32d55717b4934c91cf187f0ed165196fd0 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Mon, 17 Aug 2015 17:46:46 +0200 Subject: Wrap entries in plop wrapper --- src/catlfish.erl | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') 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}. -- cgit v1.1