From f24d0f7933e6df09fb33bd65e2af85e6c2a23031 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 18 Sep 2016 14:14:27 +0200 Subject: Split File --- main.go | 50 +++----------------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 47a636c..7e26857 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,11 @@ package main import ( - "bufio" "crypto/rand" "encoding/base64" "flag" "fmt" - "io/ioutil" - "log" "os" - "strings" "golang.org/x/crypto/ed25519" ) @@ -20,13 +16,9 @@ var ( ) const ( - commentHdr = "untrusted comment: " - verifyWith = "verify with " - pubKey = "%s public key" - secKey = "%s secret key" - sigFrom = "signature from %s" - verFailed = "signature verfication failed" - verOK = "Signature Verfied" + verFailed = "signature verfication failed" + verOK = "Signature Verfied" + KeyNumLen = 8 ) /* @@ -66,7 +58,6 @@ func main() { } */ - log.Println(parseFile("testcases/test.sig")) s, _ := base64.StdEncoding.DecodeString("RWRCSwAAAACzJBN2gC5//jVvDiV76rs4m2aKXkljqDpbOC0bBf7abZhV/Zygr6b0KIbSI56JQutwzsQeouxnnHuVTZp3IW4M9qdpe5Nh8Jrr5g7r0rHLPxEPmcv/dNru6ZjqI7CcGsY=") fmt.Printf("%v\n", s) @@ -78,14 +69,6 @@ func main() { fmt.Println(string(ms)) } -const KeyNumLen = 8 - -type File struct { - Comment string - Key string - Body []byte -} - func Generate(pubFile, secFile, comment string, rounds int) error { pub, sec, err := ed25519.GenerateKey(rand.Reader) if err != nil { @@ -101,30 +84,3 @@ func Generate(pubFile, secFile, comment string, rounds int) error { func Sign() {} func Verify() {} - -func parseFile(fname string) (File, error) { - fd, err := os.Open(fname) - if err != nil { - return File{}, err - } - defer fd.Close() - buf := bufio.NewReader(fd) - comment, err := buf.ReadString('\n') - if err != nil { - return File{}, err - } - comment = strings.TrimRight(comment, "\r\n") - log.Println(comment) - - b64, err := buf.ReadString('\n') - if err != nil { - return File{}, err - } - b64 = strings.TrimRight(b64, "\r\n") - body, err := ioutil.ReadAll(buf) - return File{ - Comment: comment, - Key: b64, - Body: body, - }, nil -} -- cgit v1.2.3