summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-09-24 15:08:06 +0200
committerLinus Nordberg <linus@nordberg.se>2014-09-24 15:08:06 +0200
commitf6df23343c6a34f18fa7989ae08eb986c8222ebe (patch)
tree0b5951ce24338eb0dce4c87861a69a93bf22fbd6
parent0b253574667acde453a50a2b61cf46d6f7a6c86e (diff)
-rw-r--r--src/db.hrl3
-rw-r--r--src/plop.erl22
2 files changed, 17 insertions, 8 deletions
diff --git a/src/db.hrl b/src/db.hrl
index bea9131..309f8e1 100644
--- a/src/db.hrl
+++ b/src/db.hrl
@@ -6,6 +6,9 @@
%% indexed, see init_tables/1.
%% NOTE: Don't change anything here without also fixing
%% select_index/2, which depends on the order of fields.
+%% NOTE2: This record has creeped into case matches in plop. This will
+%% change, but for now, don't change this record without looking
+%% carefully almost everywhere.
-record(plop, {
index :: non_neg_integer(), % Primary key.
entryhash :: binary(), % Hash over #plop_entry{} in mtl.
diff --git a/src/plop.erl b/src/plop.erl
index 39ab2c0..0b331f6 100644
--- a/src/plop.erl
+++ b/src/plop.erl
@@ -26,7 +26,7 @@
%% API.
-export([start_link/2, stop/0]).
-export([get_logid/0, serialise/1]).
--export([add/2, sth/0, get/2, consistency/2, inclusion/2, inclusion_and_more/2]).
+-export([add/2, sth/0, get/2, consistency/2, inclusion/2, inclusion_and_entry/2]).
%% API for tests.
-export([read_keyfile_rsa/2, read_keyfiles_ec/2]).
-export([testing_get_pubkey/0]).
@@ -118,10 +118,10 @@ consistency(TreeSizeFirst, TreeSizeSecond) ->
{ok, mtl()} | {notfound, string()}.
inclusion(Hash, TreeSize) ->
gen_server:call(?MODULE, {inclusion, {Hash, TreeSize}}).
--spec inclusion_and_more(non_neg_integer(), non_neg_integer()) ->
- {ok, {mtl(), binary()}} | {notfound, string()}.
-inclusion_and_more(Index, TreeSize) ->
- gen_server:call(?MODULE, {inclusion_and_more, {Index, TreeSize}}).
+-spec inclusion_and_entry(non_neg_integer(), non_neg_integer()) ->
+ {ok, {mtl(), binary()}} | {notfound, string()}.
+inclusion_and_entry(Index, TreeSize) ->
+ gen_server:call(?MODULE, {inclusion_and_entry, {Index, TreeSize}}).
get_logid() ->
gen_server:call(?MODULE, {get, logid}).
testing_get_pubkey() ->
@@ -167,7 +167,7 @@ handle_call({inclusion, {Hash, TreeSize}}, _From, Plop) ->
end,
{reply, R, Plop};
-handle_call({inclusion_and_more, {Index, TreeSize}}, _From, Plop) ->
+handle_call({inclusion_and_entry, {Index, TreeSize}}, _From, Plop) ->
R = case db:find(index, Index) of
[] ->
{notfound, "Unknown index"}; % FIXME: include Index
@@ -372,6 +372,8 @@ timestamp(Timestamp) ->
_ -> Timestamp
end.
+%% CT specific. Doesn't really belong in plop. FIXME: Add new field in
+%% #plop{} holding a fun.
serialise_tls_vector(Binary, LengthLen) ->
Length = byte_size(Binary),
<<Length:LengthLen/integer-unit:8, Binary/binary>>.
@@ -384,14 +386,17 @@ serialise(#plop_entry{
data = Data
}) ->
EntryType = entry_type(TypeAtom),
- DataVector = serialise_tls_vector(Data, 3),
+ DataVector = serialise_tls_vector(Data, 3), % FIXME: Use fun in #plop_entry{}.
<<EntryType:16, DataVector/binary>>;
serialise(#timestamped_entry{
timestamp = Timestamp,
entry = PlopEntry
}) ->
Extensions = <<>>,
- list_to_binary([<<Timestamp:64>>, serialise(PlopEntry), serialise_tls_vector(Extensions, 2)]);
+ list_to_binary([<<Timestamp:64>>,
+ serialise(PlopEntry),
+ serialise_tls_vector(Extensions, 2)]); % FIXME: Use fun in #plop_entry{} instead.
+
serialise(#spt{
version = Version,
logid = LogID,
@@ -448,6 +453,7 @@ serialise(#signature{
%% Encode a DSS signature according to RFC5246 section 4.7 and
%% don't forget that the signature is a vector as specified in
%% section 4.3 and has a length field.
+ %% FIXME: This is serialise_tls_vector() and should move out of plop.
SigLen = size(Signature),
list_to_binary([serialise(Algorithm),
<<SigLen:16, Signature/binary>>]).