summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2015-08-07 11:36:51 +0200
committerLinus Nordberg <linus@nordu.net>2015-08-07 11:36:51 +0200
commita9477afb3623c4d09ad080e5a0c31dde27518a8d (patch)
treeb155b873c450e616d66b90602a92429bb7c9c1aa /src
parent6904422f3e8ca95ece5a309ef121a6cd6159e0a8 (diff)
Rename extra_data/3 and move it some.
Diffstat (limited to 'src')
-rw-r--r--src/catlfish.erl28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/catlfish.erl b/src/catlfish.erl
index d483249..ffa2ec5 100644
--- a/src/catlfish.erl
+++ b/src/catlfish.erl
@@ -215,6 +215,18 @@ deserialise_signed_precert_entry(Data) ->
tbs_certificate = TBSCertificate},
RestData2}.
+serialise_extra_data(Type, Cert, Chain) ->
+ EncodedChain = encode_tls_vector(
+ list_to_binary(
+ [encode_tls_vector(C, 3) || C <- Chain]), 3),
+ case Type of
+ normal ->
+ EncodedChain;
+ precert ->
+ list_to_binary(
+ [encode_tls_vector(Cert, 3) | EncodedChain])
+ end.
+
-spec entries(non_neg_integer(), non_neg_integer()) -> {[{entries, list()},...]}.
entries(Start, End) ->
{[{entries, x_entries(plop:get(Start, End))}]}.
@@ -224,7 +236,7 @@ entry_and_proof(Index, TreeSize) ->
case plop:inclusion_and_entry(Index, TreeSize) of
{ok, Entry, Path} ->
{Type, MTLText, Cert, Chain} = unpack_entry(Entry),
- ExtraData = extra_data(Type, Cert, Chain),
+ ExtraData = serialise_extra_data(Type, Cert, Chain),
{[{leaf_input, base64:encode(MTLText)},
{extra_data, base64:encode(ExtraData)},
{audit_path, [base64:encode(X) || X <- Path]}]};
@@ -311,25 +323,13 @@ unpack_certchain(Data) ->
{<<"X509">>, Unpacked, Rest} = tlv:decode(Data),
[Unpacked | unpack_certchain(Rest)].
-extra_data(Type, Cert, Chain) ->
- EncodedChain = encode_tls_vector(
- list_to_binary(
- [encode_tls_vector(C, 3) || C <- Chain]), 3),
- case Type of
- normal ->
- EncodedChain;
- precert ->
- list_to_binary(
- [encode_tls_vector(Cert, 3) | EncodedChain])
- end.
-
-spec x_entries([{non_neg_integer(), binary(), binary()}]) -> list().
x_entries([]) ->
[];
x_entries([H|T]) ->
{_Index, _Hash, Entry} = H,
{Type, MTL, Cert, Chain} = unpack_entry(Entry),
- ExtraData = extra_data(Type, Cert, Chain),
+ ExtraData = serialise_extra_data(Type, Cert, Chain),
[{[{leaf_input, base64:encode(MTL)},
{extra_data, base64:encode(ExtraData)}]} | x_entries(T)].