aboutsummaryrefslogtreecommitdiff
path: root/reqres.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-27 19:16:10 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-27 19:16:10 +0100
commite7801b268c97c6b72bfcd76549ce5fd50ab0b1b5 (patch)
tree1eecf16a6b263750b0d480c3d966dff2f3072cfd /reqres.go
parent13dd306e69b26ab8b7aedcd6ed915df4b6672a01 (diff)
added ed25519 signing and SDIs
Diffstat (limited to 'reqres.go')
-rw-r--r--reqres.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/reqres.go b/reqres.go
index e1f97ee..fe79d51 100644
--- a/reqres.go
+++ b/reqres.go
@@ -33,6 +33,11 @@ type GetProofByHashRequest struct {
TreeSize int64 `json:"tree_size"` // Tree head size to base proof on
}
+// AddEntryResponse is an assembled add-entry response
+type AddEntryResponse struct {
+ SignedDebugInfo string `json:"sdi"`
+}
+
// GetEntryResponse is an assembled log entry and its associated appendix
type GetEntryResponse struct {
Leaf string `json:"leaf"` // base64-encoded StItem
@@ -118,6 +123,17 @@ func NewGetProofByHashRequest(httpRequest *http.Request) (GetProofByHashRequest,
return GetProofByHashRequest{TreeSize: treeSize, Hash: hash}, nil
}
+// NewAddEntryResponse assembles an add-entry response from an SDI
+func NewAddEntryResponse(sdi StItem) (AddEntryResponse, error) {
+ b, err := tls.Marshal(sdi)
+ if err != nil {
+ return AddEntryResponse{}, fmt.Errorf("tls marshal failed: %v", err)
+ }
+ return AddEntryResponse{
+ SignedDebugInfo: base64.StdEncoding.EncodeToString(b),
+ }, nil
+}
+
// NewGetEntryResponse assembles a log entry and its appendix
func NewGetEntryResponse(leaf, appendix []byte) (GetEntryResponse, error) {
var app Appendix