From 8ecfbfa2a57708366763d7adbfcb87f9b0df7d03 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Sat, 18 Feb 2017 00:41:07 +0100 Subject: Require that storage servers sign stored entries --- src/storage.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/storage.erl') diff --git a/src/storage.erl b/src/storage.erl index efe4768..489bf91 100644 --- a/src/storage.erl +++ b/src/storage.erl @@ -19,7 +19,10 @@ request(post, ?APPURL_PLOP_STORAGE, "sendentry", Input) -> ok = db:add_entry_sync(TreeLeafHash, LogEntry), ok = storagedb:add(TreeLeafHash), - success({[{result, <<"ok">>}]}) + {KeyName, Sig} = http_auth:sign_stored(plop:spt_from_entry(LogEntry)), + success({[{result, <<"ok">>}, + {"sig", KeyName ++ ":" ++ base64:encode_to_string(Sig)} + ]}) end; request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) -> case (catch mochijson2:decode(Input)) of @@ -30,6 +33,12 @@ request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) -> LeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)), db:add_entryhash(LeafHash, EntryHash), db:commit_entryhash(), + case proplists:get_value(<<"timestamp_signature">>, PropList) of + undefined -> + none; + TimestampSignature -> + plop:add_spt(LeafHash, base64:decode(TimestampSignature)) + end, success({[{result, <<"ok">>}]}) end; request(get, ?APPURL_PLOP_STORAGE, "fetchnewentries", _Input) -> -- cgit v1.1