diff options
-rw-r--r-- | b64file/file.go | 9 | ||||
-rw-r--r-- | generate.go | 6 | ||||
-rw-r--r-- | names.go (renamed from b64file/names.go) | 4 | ||||
-rw-r--r-- | names_test.go (renamed from b64file/names_test.go) | 4 | ||||
-rw-r--r-- | perm.go | 9 | ||||
-rw-r--r-- | sign.go | 10 | ||||
-rw-r--r-- | verify.go | 4 |
7 files changed, 25 insertions, 21 deletions
diff --git a/b64file/file.go b/b64file/file.go index ebca8fe..9254303 100644 --- a/b64file/file.go +++ b/b64file/file.go @@ -1,4 +1,4 @@ -// Package file implements signify file format +// Package b64file implements signify file format package b64file import ( @@ -14,12 +14,7 @@ import ( "strings" ) -const ( - ModeSec os.FileMode = 0600 - ModePub os.FileMode = 0644 - ModeSig os.FileMode = 0644 - untrusted = "untrusted comment: " -) +const untrusted = "untrusted comment: " // Original Error: "invalid comment in %s; must start with 'untrusted comment: '" var ErrUntrusted = errors.New("comment must start with 'untrusted comment: '") diff --git a/generate.go b/generate.go index 607b566..f067b8b 100644 --- a/generate.go +++ b/generate.go @@ -23,7 +23,7 @@ func generate(args []string) error { opts.Usage() return nil } - if err := b64file.ValidateNames(*pubFile, *secFile); err != nil { + if err := ValidateNames(*pubFile, *secFile); err != nil { return err } @@ -37,10 +37,10 @@ func generate(args []string) error { return err } - if err := b64file.EncodeFile(*secFile, b64file.ModeSec, secKey, *comment+" secret key", nil); err != nil { + if err := b64file.EncodeFile(*secFile, ModeSec, secKey, *comment+" secret key", nil); err != nil { return err } - if err := b64file.EncodeFile(*pubFile, b64file.ModePub, pubKey, *comment+" public key", nil); err != nil { + if err := b64file.EncodeFile(*pubFile, ModePub, pubKey, *comment+" public key", nil); err != nil { return err } return nil diff --git a/b64file/names.go b/names.go index 83d73d2..278f54e 100644 --- a/b64file/names.go +++ b/names.go @@ -1,4 +1,4 @@ -package b64file +package main import ( "errors" @@ -41,7 +41,7 @@ func SigName(msgFile string) string { return msgFile + extSig } -func PubFile(comment string) string { +func CommentPubFile(comment string) string { if strings.HasPrefix(comment, verifyWith) { file := comment[len(verifyWith):] if strings.HasSuffix(file, extPub) { diff --git a/b64file/names_test.go b/names_test.go index 0acabed..3fee0d0 100644 --- a/b64file/names_test.go +++ b/names_test.go @@ -1,4 +1,4 @@ -package b64file +package main import "testing" @@ -35,7 +35,7 @@ func TestVerify(t *testing.T) { } for _, tc := range testCases { t.Run(tc.comment, func(t *testing.T) { - file := PubFile(tc.comment) + file := CommentPubFile(tc.comment) if file != tc.file { t.Errorf("got %v, want %v", file, tc.file) } @@ -0,0 +1,9 @@ +package main + +import "os" + +const ( + ModeSec os.FileMode = 0600 + ModePub os.FileMode = 0644 + ModeSig os.FileMode = 0644 +) @@ -29,7 +29,7 @@ func sign(args []string) error { return nil } if *sigFile == "" { - *sigFile = b64file.SigName(*msgFile) + *sigFile = SigName(*msgFile) } switch { @@ -62,8 +62,8 @@ func signPlain(secFile, msgFile, sigFile string) error { return err } sig := sec.Sign(msg) - comment := b64file.VerifyWith(secFile) - return b64file.EncodeFile(sigFile, b64file.ModeSig, sig, comment, nil) + comment := VerifyWith(secFile) + return b64file.EncodeFile(sigFile, ModeSig, sig, comment, nil) } func signEmbedded(secFile, msgFile, sigFile string) error { @@ -76,8 +76,8 @@ func signEmbedded(secFile, msgFile, sigFile string) error { return err } sig := sec.Sign(msg) - comment := b64file.VerifyWith(secFile) - return b64file.EncodeFile(sigFile, b64file.ModeSig, sig, comment, msg) + comment := VerifyWith(secFile) + return b64file.EncodeFile(sigFile, ModeSig, sig, comment, msg) } // TODO @@ -30,7 +30,7 @@ func verify(args []string) error { return nil } if *sigFile == "" { - *sigFile = b64file.SigName(*msgFile) + *sigFile = SigName(*msgFile) } _ = keyType // TODO @@ -147,6 +147,6 @@ func openSig(fname string) (*key.Sig, []byte, string, error) { if err := sig.Validate(); err != nil { return nil, nil, "", err } - pubKey := b64file.PubFile(comment) + pubKey := CommentPubFile(comment) return sig, msg, pubKey, nil } |