aboutsummaryrefslogtreecommitdiff
path: root/type.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-22 16:32:15 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-22 16:32:15 +0200
commitee3e12f3228b876b9fff8466b6d9ad3b7ea81816 (patch)
treee1fc1c66eecc70605ed9765c4d504e96c9b94799 /type.go
parent2793442e21f19fc3f764e1f848b83d96076dcfb0 (diff)
added start on get-entries code path
If the provided range is (mostly) valid the corresponding log entries are fetched from the Trillian back-end and returned as a JSON object.
Diffstat (limited to 'type.go')
-rw-r--r--type.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/type.go b/type.go
index dcb2a9a..11fafe1 100644
--- a/type.go
+++ b/type.go
@@ -8,6 +8,7 @@ import (
"net/http"
"github.com/google/certificate-transparency-go/tls"
+ "github.com/google/trillian"
)
// StFormat defines a particular StItem type that is versioned
@@ -104,7 +105,7 @@ type AddEntryRequest struct {
// GetEntriesRequest is a collection of get-entry input parameters
type GetEntriesRequest struct {
Start int64
- End int64
+ End int64
}
func (r *GetEntriesRequest) Unpack(httpRequest *http.Request) error {
@@ -129,3 +130,28 @@ func (r *GetEntriesRequest) Unpack(httpRequest *http.Request) error {
// TODO: check that end is not past the most recent STH. Yes -> truncate
return nil
}
+
+type GetEntryResponse struct {
+ Leaf string `json:"leaf"`
+ Signature string `json:"signature"`
+ Chain []string `json:chain`
+}
+
+func NewGetEntryResponse(leaf []byte) GetEntryResponse {
+ return GetEntryResponse{
+ Leaf: base64.StdEncoding.EncodeToString(leaf),
+ // TODO: add signature and chain
+ }
+}
+
+type GetEntriesResponse struct {
+ Entries []GetEntryResponse `json:"entries"`
+}
+
+func NewGetEntriesResponse(leaves []*trillian.LogLeaf) (GetEntriesResponse, error) {
+ entries := make([]GetEntryResponse, 0, len(leaves))
+ for _, leaf := range leaves {
+ entries = append(entries, NewGetEntryResponse(leaf.GetLeafValue())) // TODO: add signature and chain
+ }
+ return GetEntriesResponse{entries}, nil
+}