summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/catlfish.erl25
-rwxr-xr-xtools/compileconfig.py2
3 files changed, 28 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index cd445e3..58a1160 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
build all:
- erl -pa ../lager/ebin -make
+ ./make.erl
clean:
-rm ebin/*.beam
release: all
diff --git a/src/catlfish.erl b/src/catlfish.erl
index 2e5ffd4..ed75495 100644
--- a/src/catlfish.erl
+++ b/src/catlfish.erl
@@ -5,6 +5,7 @@
-export([add_chain/3, entries/2, entry_and_proof/2]).
-export([known_roots/0, update_known_roots/0]).
-export([init_cache_table/0]).
+-export([entryhash_from_entry/1]).
-include_lib("eunit/include/eunit.hrl").
-define(PROTOCOL_VERSION, 0).
@@ -243,6 +244,30 @@ init_cache_table() ->
end,
ets:new(?CACHE_TABLE, [set, public, named_table]).
+deserialise_extra_data(ExtraData) ->
+ case decode_tls_vector(ExtraData, 3) of
+ {E, <<>>} ->
+ [E];
+ {E, Rest} ->
+ [E | deserialise_extra_data(Rest)]
+ end.
+
+entryhash_from_entry(Entry) ->
+ {MTLText, ExtraDataPacked} = unpack_entry(Entry),
+ {ExtraData, <<>>} = decode_tls_vector(ExtraDataPacked, 3),
+ MTL = deserialise_mtl(MTLText),
+ TimestampedEntry = MTL#mtl.entry,
+ Chain = deserialise_extra_data(ExtraData),
+ Data =
+ case TimestampedEntry#timestamped_entry.entry_type of
+ x509_entry ->
+ SignedEntry = TimestampedEntry#timestamped_entry.signed_entry,
+ [SignedEntry#signed_x509_entry.asn1_cert | Chain];
+ precert_entry ->
+ Chain
+ end,
+ crypto:hash(sha256, Data).
+
%% Private functions.
-spec unpack_entry(binary()) -> {binary(), binary()}.
unpack_entry(Entry) ->
diff --git a/tools/compileconfig.py b/tools/compileconfig.py
index 30424c5..e3d9ee0 100755
--- a/tools/compileconfig.py
+++ b/tools/compileconfig.py
@@ -188,6 +188,8 @@ def gen_config(nodename, config, localconfig):
if nodetype == "frontendnodes":
plopconfig += [
(Symbol("sth_path"), paths["db"] + "sth"),
+ (Symbol("entryhash_from_entry"),
+ (Symbol("catlfish"), Symbol("entryhash_from_entry"))),
]
signingnode = config["signingnodes"][0]