aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-01 17:28:38 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-01 17:28:38 +0200
commita3e526f9b89aa52c21cf8da02a5ddf6682795b1b (patch)
tree476fc4aa6c1e32cbd7c6e1454b9d1edffd099ac2 /main.go
parent6d570db777f841f23e6aef96a96992d20811cd44 (diff)
Names
Diffstat (limited to 'main.go')
-rw-r--r--main.go25
1 files changed, 3 insertions, 22 deletions
diff --git a/main.go b/main.go
index 6d57343..4471418 100644
--- a/main.go
+++ b/main.go
@@ -1,12 +1,10 @@
package main
import (
- "errors"
"flag"
"fmt"
"io/ioutil"
"log"
- "path/filepath"
"dim13.org/signify/ask"
"dim13.org/signify/file"
@@ -38,10 +36,6 @@ var (
gzip = flag.Bool("z", false, "Sign and verify gzip archives")
)
-var (
- ErrNamingScheme = errors.New("please use naming scheme of keyname.pub and keyname.sec")
-)
-
func main() {
flag.Parse()
@@ -64,8 +58,8 @@ func main() {
}
func Generate(pubFile, secFile, comment string, nopass bool) error {
- if !NamingScheme(pubFile, secFile) {
- return ErrNamingScheme
+ if err := file.Names(pubFile, secFile); err != nil {
+ return err
}
pubKey, encKey, err := signify.NewKey()
@@ -174,7 +168,7 @@ func Sign(msgFile, secFile string, embed bool) error {
return err
}
sigfile := &file.Block{
- Comment: fmt.Sprintf("verify with %s", ToPub(secFile)), // TODO replace .sec with .pub
+ Comment: fmt.Sprintf("verify with %s", file.PubName(secFile)),
Bytes: sigRaw,
}
if embed {
@@ -201,16 +195,3 @@ func Verify(msgFile, pubFile string) error {
log.Println("Signature Verfied")
return nil
}
-
-func NamingScheme(pubFile, secFile string) bool {
- pubFile = filepath.Base(pubFile)
- secFile = filepath.Base(secFile)
- pubExt := filepath.Ext(pubFile)
- secExt := filepath.Ext(secFile)
- return pubExt == ".pub" && secExt == ".sec" && pubFile[:len(pubExt)-1] == secFile[:len(secExt)-1]
-}
-
-func ToPub(secFile string) string {
- ext := filepath.Ext(secFile)
- return filepath.Base(secFile[:len(ext)-1] + ".pub")
-}