aboutsummaryrefslogtreecommitdiff
path: root/type.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-21 18:18:43 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-21 18:18:43 +0200
commitec4741e374beeb085579ba896fdee2cd6f0f8848 (patch)
treea2c3b971469e8a1d2230a4bc220a1e0a602aa128 /type.go
parent3296d1013c54ff336ce43fab835489305f23cb01 (diff)
added start on addEntry code path
If the POSTed StItem can be parsed without errors it is handed over to the Trillian back-end.
Diffstat (limited to 'type.go')
-rw-r--r--type.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/type.go b/type.go
index e9b5ef2..031ae8d 100644
--- a/type.go
+++ b/type.go
@@ -55,6 +55,22 @@ func (i StItem) String() string {
}
}
+func StItemFromB64(s string) (*StItem, error) {
+ b, err := base64.StdEncoding.DecodeString(s)
+ if err != nil {
+ return nil, fmt.Errorf("base64 decoding failed: %v", err)
+ }
+
+ var item StItem
+ extra, err := tls.Unmarshal(b, &item)
+ if err != nil {
+ return nil, fmt.Errorf("tls unmarshal failed: %v", err)
+ } else if len(extra) > 0 {
+ return nil, fmt.Errorf("tls unmarshal found extra data: %v", extra)
+ }
+ return &item, nil
+}
+
// ChecksumV1 associates a package name with an arbitrary checksum value
type ChecksumV1 struct {
Package []byte `tls:"minlen:0,maxlen:255"`
@@ -75,3 +91,10 @@ func NewChecksumV1(name string, checksum []byte) (StItem, error) {
func (i ChecksumV1) String() string {
return fmt.Sprintf("%v %v", string(i.Package), base64.StdEncoding.EncodeToString(i.Checksum))
}
+
+// AddEntryRequest is a collection of add-entry input parameters
+type AddEntryRequest struct {
+ Item string `json:"item"`
+ Signature string `json:"signature"`
+ Certificate string `json:"certificate"`
+}