aboutsummaryrefslogtreecommitdiff
path: root/type.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 /type.go
parent13dd306e69b26ab8b7aedcd6ed915df4b6672a01 (diff)
added ed25519 signing and SDIs
Diffstat (limited to 'type.go')
-rw-r--r--type.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/type.go b/type.go
index a629259..726b215 100644
--- a/type.go
+++ b/type.go
@@ -25,6 +25,7 @@ const (
// StItem references a versioned item based on a given format specifier.
type StItem struct {
Format StFormat `tls:"maxval:65535"`
+ SignedDebugInfoV1 *SignedDebugInfoV1 `tls:"selector:Format,val:2"`
InclusionProofV1 *InclusionProofV1 `tls:"selector:Format,val:4"`
ChecksumV1 *ChecksumV1 `tls:"selector:Format,val:5"`
// TODO: add more items
@@ -44,11 +45,32 @@ type InclusionProofV1 struct {
InclusionPath []NodeHash `tls:"minlen:1,maxlen:65535"`
}
+// 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"`
+ Message []byte `tls:"minlen:0,maxlen:65535"`
+ Signature []byte `tls:"minlen:0,maxlen:65535"` // defined in RFC 8032
+}
+
// NodeHash is a hashed Merkle tree node, see RFC 6962/bis (ยง4.9)
type NodeHash struct {
Data []byte `tls:"minlen:32,maxlen:255"`
}
+func NewSignedDebugInfoV1(logId, message, signature []byte) StItem {
+ return StItem{
+ Format: StFormatSignedDebugInfoV1,
+ SignedDebugInfoV1: &SignedDebugInfoV1{
+ LogId: logId,
+ Message: message,
+ Signature: signature,
+ },
+ }
+}
+
// NewChecksumV1 creates a new StItem of type checksum_v1
func NewChecksumV1(identifier []byte, checksum []byte) StItem {
return StItem{
@@ -103,11 +125,17 @@ func (i StItem) String() string {
return fmt.Sprintf("Format(%s): %s", i.Format, *i.ChecksumV1)
case StFormatInclusionProofV1:
return fmt.Sprintf("Format(%s): %s", i.Format, *i.InclusionProofV1)
+ case StFormatSignedDebugInfoV1:
+ return fmt.Sprintf("Format(%s): %s", i.Format, *i.SignedDebugInfoV1)
default:
return fmt.Sprintf("unknown StItem: %s", i.Format)
}
}
+func (i SignedDebugInfoV1) String() string {
+ return fmt.Sprintf("LogId(%s) Message(%s) Signature(%s)", base64.StdEncoding.EncodeToString(i.LogId), string(i.Message), base64.StdEncoding.EncodeToString(i.Signature))
+}
+
func (i ChecksumV1) String() string {
return fmt.Sprintf("Package(%v) Checksum(%v)", string(i.Package), base64.StdEncoding.EncodeToString(i.Checksum))
}