summaryrefslogtreecommitdiff
path: root/src/catlfish.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2015-05-06 12:04:51 +0200
committerLinus Nordberg <linus@nordberg.se>2015-05-06 12:04:51 +0200
commit0e27a8f7b0fff609f463cca3b2bfb40a916fcc13 (patch)
treec83538159453a2f432b29781b95e7d84dda2a203 /src/catlfish.erl
parentca8cbe163492f7fcb321d22d7e3700d8f0646d99 (diff)
Dialyzer clean.
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} ->