aboutsummaryrefslogtreecommitdiff
path: root/types/ascii.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-05-31 23:56:49 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-05-31 23:56:49 +0200
commit1ac7f1bad7596bc0cc489d85de8bdf5d195b99a3 (patch)
tree4cea78430493f8819abb70efc71262407a860ce7 /types/ascii.go
parent4a9eddf4d45391c060a67f4464e4c0136aeaad21 (diff)
added types and fixed an error
- The wrong signature header was used for leaves - Added SigIdent marshalling - Added a wrapper that uses the log's hash function
Diffstat (limited to 'types/ascii.go')
-rw-r--r--types/ascii.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/types/ascii.go b/types/ascii.go
index 88b372e..565e52d 100644
--- a/types/ascii.go
+++ b/types/ascii.go
@@ -200,7 +200,7 @@ func (l *Leaf) MarshalASCII(w io.Writer) error {
if err := writeASCII(w, Checksum, hex.EncodeToString(l.Checksum[:])); err != nil {
return fmt.Errorf("writeASCII: %v", err)
}
- if err := writeASCII(w, Signature, hex.EncodeToString(l.Signature[:])); err != nil {
+ if err := writeASCII(w, SignatureOverMessage, hex.EncodeToString(l.Signature[:])); err != nil {
return fmt.Errorf("writeASCII: %v", err)
}
if err := writeASCII(w, KeyHash, hex.EncodeToString(l.KeyHash[:])); err != nil {
@@ -220,16 +220,23 @@ func (sth *SignedTreeHead) MarshalASCII(w io.Writer) error {
return fmt.Errorf("writeASCII: %v", err)
}
for _, sigident := range sth.SigIdent {
- if err := writeASCII(w, Signature, hex.EncodeToString(sigident.Signature[:])); err != nil {
- return fmt.Errorf("writeASCII: %v", err)
- }
- if err := writeASCII(w, KeyHash, hex.EncodeToString(sigident.KeyHash[:])); err != nil {
- return fmt.Errorf("writeASCII: %v", err)
+ if err := sigident.MarshalASCII(w); err != nil {
+ return fmt.Errorf("MarshalASCII: %v", err)
}
}
return nil
}
+func (si *SigIdent) MarshalASCII(w io.Writer) error {
+ if err := writeASCII(w, Signature, hex.EncodeToString(si.Signature[:])); err != nil {
+ return fmt.Errorf("writeASCII: %v", err)
+ }
+ if err := writeASCII(w, KeyHash, hex.EncodeToString(si.KeyHash[:])); err != nil {
+ return fmt.Errorf("writeASCII: %v", err)
+ }
+ return nil
+}
+
func (p *ConsistencyProof) MarshalASCII(w io.Writer) error {
if err := writeASCII(w, NewSize, strconv.FormatUint(p.NewSize, 10)); err != nil {
return fmt.Errorf("writeASCII: %v", err)
@@ -385,7 +392,7 @@ func (req *LeafRequest) UnmarshalASCII(r io.Reader) error {
if req.Checksum, err = msg.GetHash(Checksum); err != nil {
return fmt.Errorf("GetHash(Checksum): %v", err)
}
- if req.Signature, err = msg.GetSignature(Signature); err != nil {
+ if req.Signature, err = msg.GetSignature(SignatureOverMessage); err != nil {
return fmt.Errorf("GetSignature: %v", err)
}
if req.VerificationKey, err = msg.GetVerificationKey(VerificationKey); err != nil {