summaryrefslogtreecommitdiff
path: root/src/plop.hrl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2014-04-29 13:32:37 +0200
committerLinus Nordberg <linus@nordu.net>2014-04-29 13:32:37 +0200
commit73a6c28e22991f2f6dc0ab303c1c5274f083de77 (patch)
tree27a0ad4d584eecbb628b222f35d337ea980f7d5f /src/plop.hrl
parent9660a220392beb26b17a003a5d3f6ba0a73bb6b0 (diff)
First cut at adding DB support.
Including half crazy rewrite of most of the data structures.
Diffstat (limited to 'src/plop.hrl')
-rw-r--r--src/plop.hrl86
1 files changed, 68 insertions, 18 deletions
diff --git a/src/plop.hrl b/src/plop.hrl
index 7275f5a..5492024 100644
--- a/src/plop.hrl
+++ b/src/plop.hrl
@@ -1,29 +1,79 @@
--type signature_type() :: certificate_timestamp | tree_hash | test.
--type entry_type() :: x509 | precert | test.
+%%% plop data structures. Heavily based on RFC 6962. Some are for
+%%% database storage, some for interfacing with consumers and some are
+%%% for serialisation.
-%% @doc The parts of an SPT which is to be signed.
--record(spt, {
- version = 1 :: integer(),
+-type signature_type() :: certificate_timestamp | tree_hash | test. % uint8
+-type entry_type() :: x509 | precert | test. % uint16
+-type leaf_type() :: timestamped_entry | test. % uint8
+
+%% @doc What's stored in the database.
+-record(plop, {
+ index :: non_neg_integer(), % Primary key.
+ hash :: binary(), % SHA-256 over #FIXME.entry. Indexed in db.
+ spt :: binary() % serialise(#spt_on_wire{})
+ }).
+
+%% @doc Merkle Tree Leaf -- input to hash function for leaf hashes.
+-record(mtl, {
+ version = 1 :: pos_integer(),
+ leaf_type = timestamped_entry :: leaf_type(),
+ entry :: timestamped_entry()
+ }).
+-type mtl() :: #mtl{}.
+
+%% @doc Parts of what goes in an SPT. Used for FIXME.
+%% -record(spt, {
+%% version = 1 :: pos_integer(),
+%% signature_type :: signature_type(),
+%% entry :: timestamped_entry()
+%% }).
+%%-type spt() :: #spt{}.
+
+-record(spt_on_wire, {
+ version :: pos_integer(), % uint8
+ logid :: binary(), % SHA-256 over DER encoded public log key
+ timestamp :: integer(), % uint64
+ signature :: binary()
+ }).
+-type spt_on_wire() :: #spt_on_wire{}.
+
+%% @doc What's signed in an SPT. Used for serialisation before hasning
+%% and signing. FIXME: Overlapping #spt{} -- merge somehow.
+-record(spt_signed, {
+ version :: pos_integer(),
signature_type :: signature_type(),
- timestamp = now :: 'now' | integer(),
- entry :: plop_entry()
- }).
--type spt() :: #spt{}.
+ timestamp :: integer(),
+ entry_type :: entry_type(),
+ signed_entry :: binary()
+ }).
+-type spt_signed() :: #spt_signed{}.
+
+%% Internal representation of a data entry.
+-record(timestamped_entry, {
+ timestamp = now :: now | integer(),
+ entry_type :: entry_type(),
+ entry :: binary()
+ }).
+-type timestamped_entry() :: #timestamped_entry{}.
+
+%% %% Part of interface to plop:add/1.
+%% -record(plop_entry, {
+%% type :: entry_type(),
+%% data :: binary()
+%% }).
+%% -type plop_entry() :: #plop_entry{}.
--record(plop_entry, {
- type :: entry_type(),
- data = <<>> :: binary()
- }).
--type plop_entry() :: #plop_entry{}.
-%% @doc The parts of an STH which is to be signed.
+%% @doc The parts of an STH which is to be signed. Used as the
+%% interface to plop:sth/1, for testing. Should probably be internal
+%% to plop, if that can be arranged wrt testing.
-record(sth, {
- version = 1 :: integer(),
+ version = 1 :: pos_integer(),
signature_type :: signature_type(),
timestamp = now :: 'now' | integer(),
tree_size :: integer(),
- root_hash :: binary() % sha256
+ root_hash :: binary() % SHA-256
}).
-type sth() :: #sth{}.
--export_type([plop_entry/0, entry_type/0]).
+-export_type([timestamped_entry/0, mtl/0, entry_type/0]).