summaryrefslogtreecommitdiff
path: root/src/catlfish.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/catlfish.erl')
-rw-r--r--src/catlfish.erl25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/catlfish.erl b/src/catlfish.erl
index 04b3332..6d8d430 100644
--- a/src/catlfish.erl
+++ b/src/catlfish.erl
@@ -103,9 +103,9 @@ sct_data(TimestampedEntry) ->
serialise_signature_type(certificate_timestamp),
serialise(TimestampedEntry)]).
-calc_sct(TimestampedEntry, Signatures) ->
+calc_sct_sig(TimestampedEntry, Signatures) ->
plop:serialise(
- plop:spt(sct_data(TimestampedEntry), Signatures)).
+ plop:spt_sig(sct_data(TimestampedEntry), Signatures)).
create_logentry(Type, LeafCert, CertChain) ->
EntryType = case Type of
@@ -126,16 +126,21 @@ get_ratelimit_token(Type) ->
maybe_add_to_db(Hash, LogEntry, TimestampedEntry, HasEntry) ->
- CachedSCTSig = plop:get_spt(Hash),
-
- case {HasEntry, CachedSCTSig} of
- {true, SCT} when is_binary(SCT) ->
- SCT;
+ CachedSCTSig = plop:get_spt_sig(Hash),
+ HasSig = is_binary(CachedSCTSig),
+
+ case {HasEntry, HasSig} of
+ {true, true} ->
+ %% Entry is present in the database and a signature was
+ %% found in the SCT cache.
+ CachedSCTSig;
_ ->
+ %% We don't have the entry or we don't have the SCT in the
+ %% cache.
{ok, Signatures} = plop:add(LogEntry, Hash),
- SCT = calc_sct(TimestampedEntry, Signatures),
- plop:add_spt(Hash, SCT),
- SCT
+ SCT_sig = calc_sct_sig(TimestampedEntry, Signatures),
+ ok = plop:add_spt_sig(Hash, SCT_sig),
+ SCT_sig
end.
-spec add_chain(binary(), [binary()], normal|precert) -> {[{_,_},...]}.