summaryrefslogtreecommitdiff
path: root/src/catlfish.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/catlfish.erl')
-rw-r--r--src/catlfish.erl19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/catlfish.erl b/src/catlfish.erl
index 4410203..d1f4425 100644
--- a/src/catlfish.erl
+++ b/src/catlfish.erl
@@ -10,7 +10,7 @@
-define(PROTOCOL_VERSION, 0).
-%%-type signature_type() :: certificate_timestamp | tree_hash | test. % uint8
+-type signature_type() :: certificate_timestamp | tree_hash | test. % uint8
-type entry_type() :: x509_entry | precert_entry | test. % uint16
-type leaf_type() :: timestamped_entry | test. % uint8
-type leaf_version() :: v1 | v2. % uint8
@@ -88,11 +88,9 @@ deserialise_entry_type(<<0:16>>) ->
deserialise_entry_type(<<1:16>>) ->
precert_entry.
--spec serialise_signature_type(certificate_timestamp|tree_hash) -> binary().
+-spec serialise_signature_type(signature_type()) -> binary().
serialise_signature_type(certificate_timestamp) ->
- <<0:8>>;
-serialise_signature_type(tree_hash) ->
- <<1:8>>.
+ <<0:8>>.
calc_sct(TimestampedEntry) ->
plop:serialise(
@@ -115,9 +113,10 @@ get_sct(Hash, TimestampedEntry) ->
calc_sct(TimestampedEntry)
end.
--spec add_chain(binary(), [binary()], normal|precert) -> nonempty_string().
+-spec add_chain(binary(), [binary()], normal|precert) -> {[{_,_},...]}.
add_chain(LeafCert, CertChain, Type) ->
- EntryHash = crypto:hash(sha256, [LeafCert | CertChain]),
+ CombinedChain = [LeafCert | CertChain],
+ EntryHash = crypto:hash(sha256, CombinedChain),
EntryType = case Type of
normal -> x509_entry;
precert -> precert_entry
@@ -134,7 +133,7 @@ add_chain(LeafCert, CertChain, Type) ->
ExtraData =
case Type of
normal -> CertChain;
- precert -> [LeafCert | CertChain]
+ precert -> CombinedChain
end,
LogEntry =
list_to_binary(
@@ -219,11 +218,11 @@ deserialise_signed_precert_entry(Data) ->
tbs_certificate = TBSCertificate},
RestData2}.
--spec entries(non_neg_integer(), non_neg_integer()) -> list().
+-spec entries(non_neg_integer(), non_neg_integer()) -> {[{entries, list()},...]}.
entries(Start, End) ->
{[{entries, x_entries(plop:get(Start, End))}]}.
--spec entry_and_proof(non_neg_integer(), non_neg_integer()) -> list().
+-spec entry_and_proof(non_neg_integer(), non_neg_integer()) -> {[{_,_},...]}.
entry_and_proof(Index, TreeSize) ->
case plop:inclusion_and_entry(Index, TreeSize) of
{ok, Entry, Path} ->