aboutsummaryrefslogtreecommitdiff
path: root/sig
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-04-30 23:57:40 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-04-30 23:57:40 +0200
commitc45062d40bc370a99870fa306f2474c758154c92 (patch)
tree41fa94fb30c24c1764fc64585dc4210333ec5a1f /sig
parentfb2a33a31f388395379768dfe72b3b83d8a6f02d (diff)
...
Diffstat (limited to 'sig')
-rw-r--r--sig/sig.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/sig/sig.go b/sig/sig.go
index b07a63b..23d1739 100644
--- a/sig/sig.go
+++ b/sig/sig.go
@@ -11,6 +11,8 @@ import (
"strings"
)
+var ErrUntrustedComment = errors.New("expected untrusted comment")
+
// Block represents a encoded signify key or signature
//
// The encoded form is:
@@ -23,12 +25,10 @@ type Block struct {
Message []byte
}
-const commentHdr = "untrusted comment:"
-
-var ErrUntrustedComment = errors.New("expected untrusted comment")
+const untrusted = "untrusted comment:"
func Encode(w io.Writer, b *Block) error {
- fmt.Fprintln(w, commentHdr, b.Comment)
+ fmt.Fprintln(w, untrusted, b.Comment)
fmt.Fprintln(w, base64.StdEncoding.EncodeToString(b.Bytes))
w.Write(b.Message)
return nil
@@ -46,7 +46,7 @@ func Decode(data []byte) (*Block, error) {
if err != nil {
return nil, err
}
- if !strings.HasPrefix(comment, commentHdr) {
+ if !strings.HasPrefix(comment, untrusted) {
return nil, ErrUntrustedComment
}
raw, err := r.ReadString('\n')
@@ -62,7 +62,7 @@ func Decode(data []byte) (*Block, error) {
return nil, err
}
return &Block{
- Comment: strings.TrimSpace(comment[len(commentHdr):]),
+ Comment: strings.TrimSpace(comment[len(untrusted):]),
Bytes: b,
Message: message,
}, nil