aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-09-18 14:14:27 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-09-18 14:14:27 +0200
commitf24d0f7933e6df09fb33bd65e2af85e6c2a23031 (patch)
treee0e24e0bcf62fe514097095e00b7b1de4bb7d2f7 /main.go
parent2f32015f940aa421eafbac41c6d8bdc5e227f190 (diff)
Split File
Diffstat (limited to 'main.go')
-rw-r--r--main.go50
1 files changed, 3 insertions, 47 deletions
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
-}