aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-29 16:57:13 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-29 16:57:13 +0100
commitcf16cc04f72f477cdc7a99f17b00314a2f2fe922 (patch)
tree2601da309ee2923df4de7a44a43dbb2d4217f84f
parent7d186fff4f0d510581207b0603ea1c946286d7ae (diff)
fixed tls length specifiers
-rw-r--r--handler.go2
-rw-r--r--reqres.go4
-rw-r--r--type.go23
3 files changed, 14 insertions, 15 deletions
diff --git a/handler.go b/handler.go
index 0bc5a53..47151c8 100644
--- a/handler.go
+++ b/handler.go
@@ -160,7 +160,7 @@ func getProofByHash(ctx context.Context, i *Instance, w http.ResponseWriter, r *
}
// TODO: verify that proof is valid?
- response, err := NewGetProofByHashResponse(uint64(request.TreeSize), trillianResponse.Proof[0])
+ response, err := NewGetProofByHashResponse(i.LogParameters.LogId, uint64(request.TreeSize), trillianResponse.Proof[0])
if err != nil {
return http.StatusInternalServerError, fmt.Errorf("failed creating get-proof-by-hash response: %v", err)
}
diff --git a/reqres.go b/reqres.go
index d66ca4b..0c14d89 100644
--- a/reqres.go
+++ b/reqres.go
@@ -206,8 +206,8 @@ func NewGetEntriesResponse(leaves []*trillian.LogLeaf) (GetEntriesResponse, erro
}
// NewGetProofByHashResponse assembles a get-proof-by-hash response
-func NewGetProofByHashResponse(treeSize uint64, inclusionProof *trillian.Proof) (*GetProofByHashResponse, error) {
- item := NewInclusionProofV1([]byte("TODO: add log ID"), treeSize, inclusionProof)
+func NewGetProofByHashResponse(logId []byte, treeSize uint64, inclusionProof *trillian.Proof) (*GetProofByHashResponse, error) {
+ item := NewInclusionProofV1(logId, treeSize, inclusionProof)
b, err := tls.Marshal(item)
if err != nil {
return nil, fmt.Errorf("tls marshal failed: %v", err)
diff --git a/type.go b/type.go
index cee52bf..7d505c7 100644
--- a/type.go
+++ b/type.go
@@ -35,34 +35,34 @@ type StItem struct {
}
type ConsistencyProofV1 struct {
- LogId []byte `tls:"minlen:2,maxlen:127"`
+ LogId []byte `tls:"minlen:32,maxlen:32"`
TreeSize1 uint64
TreeSize2 uint64
ConsistencyPath []NodeHash `tls:"minlen:1,maxlen:65535"`
}
type SignedTreeHeadV1 struct {
- LogId []byte `tls:"minlen:2,maxlen:127"`
- TreeHead TreeHeadV1 `tls:minlen:0, maxlen:65535` // what should maxlen be?
- Signature []byte `tls:"minlen:0,maxlen:65535"`
+ LogId []byte `tls:"minlen:32,maxlen:32"`
+ TreeHead TreeHeadV1
+ Signature []byte `tls:"minlen:1,maxlen:65535"`
}
type TreeHeadV1 struct {
Timestamp uint64
TreeSize uint64
- RootHash NodeHash `tls:minlen:32,maxlen:255`
- Extension []byte `tls:"minlen:0,maxlen:65535"`
+ RootHash NodeHash
+ Extension []byte `tls:"minlen:0,maxlen:65535"`
}
// ChecksumV1 associates a package name with an arbitrary checksum value
type ChecksumV1 struct {
- Package []byte `tls:"minlen:0,maxlen:255"`
- Checksum []byte `tls:"minlen:32,maxlen:255"`
+ Package []byte `tls:"minlen:1,maxlen:255"`
+ Checksum []byte `tls:"minlen:1,maxlen:64"`
}
// InclusionProofV1 is a Merkle tree inclusion proof, see RFC 6962/bis (§4.12)
type InclusionProofV1 struct {
- LogID []byte `tls:"minlen:2,maxlen:127"`
+ LogID []byte `tls:"minlen:32,maxlen:32"`
TreeSize uint64
LeafIndex uint64
InclusionPath []NodeHash `tls:"minlen:1,maxlen:65535"`
@@ -71,11 +71,10 @@ type InclusionProofV1 struct {
// SignedDebugInfoV1 is a signed statement that we intend (but do not promise)
// to insert an entry into the log. Only Ed25519 signatures are supported.
// TODO: double-check that crypto/ed25519 encodes signature as in RFC 8032
-// TODO: need to think about signature format, then update markdown/api.md
type SignedDebugInfoV1 struct {
- LogId []byte `tls:"minlen:32,maxlen:127"`
+ LogId []byte `tls:"minlen:32,maxlen:32"`
Message []byte `tls:"minlen:0,maxlen:65535"`
- Signature []byte `tls:"minlen:0,maxlen:65535"` // defined in RFC 8032
+ Signature []byte `tls:"minlen:1,maxlen:65535"`
}
// NodeHash is a hashed Merkle tree node, see RFC 6962/bis (§4.9)