From 55542cce03a088e41e11b8ca5524a534ca4dcd61 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Tue, 21 Oct 2014 17:17:36 +0200 Subject: Break include dependency on plop.hrl --- include/plop.hrl | 37 ------------------------------------- src/db.erl | 1 - src/ht.erl | 1 - src/plop.erl | 8 ++------ src/plop.hrl | 27 +++++++++++++++++++++++++++ 5 files changed, 29 insertions(+), 45 deletions(-) delete mode 100644 include/plop.hrl create mode 100644 src/plop.hrl diff --git a/include/plop.hrl b/include/plop.hrl deleted file mode 100644 index b04af0d..0000000 --- a/include/plop.hrl +++ /dev/null @@ -1,37 +0,0 @@ -%%% Copyright (c) 2014, NORDUnet A/S. -%%% See LICENSE for licensing information. - -%%% Plop data structures. Heavily based on RFC 6962. Some are for -%%% database storage, some for interfacing with consumers and some are -%%% for serialisation. - -%% @doc Merkle Tree Leaf -- what's sent as 'leaf_input' in response to -%% get-entries requests and also the input to the hash function for -%% leaf hashes in the tree. RFC 6962 sect 3.4. - -%% An entry, without the timestamp. This is what we hash over and -%% store in the the database for finding duplicated submissions. --record(sth, { - treesize :: integer(), - timestamp :: integer(), - roothash :: binary(), - signature :: signature() - }). --type sth() :: #sth{}. - -%% RFC 5246 7.4.1.4.1 --type hash_alg_type() :: none | md5 | sha1 | sha224 | sha256 | sha384 | - sha512. % uint8 --type signature_alg_type() :: anonymous | rsa | dsa | ecdsa. % uint8 --record(sig_and_hash_alg, { - hash_alg :: hash_alg_type(), - signature_alg :: signature_alg_type() - }). --type sig_and_hash_alg() :: #sig_and_hash_alg{}. - -%% RFC 5246 4.7 --record(signature, { - algorithm :: sig_and_hash_alg(), - signature :: binary() - }). --type signature() :: #signature{}. diff --git a/src/db.erl b/src/db.erl index e22aab4..413f4b9 100644 --- a/src/db.erl +++ b/src/db.erl @@ -14,7 +14,6 @@ -include_lib("stdlib/include/qlc.hrl"). -include("db.hrl"). --include("$CTROOT/plop/include/plop.hrl"). size() -> binary_to_integer(atomic:readfile(treesize_path())). diff --git a/src/ht.erl b/src/ht.erl index cd4e57c..15a5b2f 100644 --- a/src/ht.erl +++ b/src/ht.erl @@ -29,7 +29,6 @@ code_change/3]). -export([testing_get_state/0, print_tree/0, print_tree/1]). --include("$CTROOT/plop/include/plop.hrl"). -include_lib("eunit/include/eunit.hrl"). -import(lists, [foreach/2, foldl/3, reverse/1]). diff --git a/src/plop.erl b/src/plop.erl index e19603f..84d0920 100644 --- a/src/plop.erl +++ b/src/plop.erl @@ -35,7 +35,7 @@ -export([init/1, handle_call/3, terminate/2, handle_cast/2, handle_info/2, code_change/3]). --include("$CTROOT/plop/include/plop.hrl"). +-include("plop.hrl"). %%-include("db.hrl"). -include_lib("public_key/include/public_key.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -331,11 +331,7 @@ sth(PrivKey, #sth_signed{version = Version, timestamp = Timestamp_in}) -> hash_alg = sha256, signature_alg = ecdsa}, signature = signhash(BinToSign, PrivKey)}, - STH = #sth{ - treesize = Treesize, - timestamp = Timestamp, - roothash = Roothash, - signature = Signature}, + STH = {Treesize, Timestamp, Roothash, Signature}, %%io:format("STH: ~p~nBinToSign: ~p~nSignature: ~p~nTimestamp: ~p~n", %% [STH, BinToSign, Signature, Timestamp]), STH. diff --git a/src/plop.hrl b/src/plop.hrl new file mode 100644 index 0000000..2e0d436 --- /dev/null +++ b/src/plop.hrl @@ -0,0 +1,27 @@ +%%% Copyright (c) 2014, NORDUnet A/S. +%%% See LICENSE for licensing information. + +%%% Plop data structures. Heavily based on RFC 6962. Some are for +%%% database storage, some for interfacing with consumers and some are +%%% for serialisation. + +%% Signed tree head +%% {Treesize, Timestamp, Roothash, Signature} +-type sth() :: tuple(integer(), integer(), binary(), signature()). + +%% RFC 5246 7.4.1.4.1 +-type hash_alg_type() :: none | md5 | sha1 | sha224 | sha256 | sha384 | + sha512. % uint8 +-type signature_alg_type() :: anonymous | rsa | dsa | ecdsa. % uint8 +-record(sig_and_hash_alg, { + hash_alg :: hash_alg_type(), + signature_alg :: signature_alg_type() + }). +-type sig_and_hash_alg() :: #sig_and_hash_alg{}. + +%% RFC 5246 4.7 +-record(signature, { + algorithm :: sig_and_hash_alg(), + signature :: binary() + }). +-type signature() :: #signature{}. -- cgit v1.1