From c45062d40bc370a99870fa306f2474c758154c92 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 30 Apr 2017 23:57:40 +0200 Subject: ... --- sig/sig.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sig') 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 -- cgit v1.2.3