X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=pkg%2Fdocument%2Fdocument.go;h=3deaef21ea333621bc1ac0158631640b4757d8a6;hb=f1ab5079added604c2d1f8a043a75613755e3dec;hp=eecd68abd60429c1e705317702424c7b2dcb9aa9;hpb=d7cd50d491a484d2f5b499e6b02fbc4d34b50e71;p=epoint diff --git a/pkg/document/document.go b/pkg/document/document.go index eecd68a..3deaef2 100644 --- a/pkg/document/document.go +++ b/pkg/document/document.go @@ -207,7 +207,7 @@ func cleanBody(s []byte) []byte { func Id(c *Signed) string { h := sha1.New() h.Write(c.Body) - return fmt.Sprintf("%040X", h.Sum()) + return fmt.Sprintf("%040X", h.Sum(nil)) } // Parse an epoint document without checking the signature and format details @@ -243,12 +243,10 @@ func Format(iv interface{}, key *openpgp.Entity) (s []byte, c *Signed, err error } // Verify an epoint document, return the cleaned version as well -func Verify(c *Signed, key openpgp.KeyRing) (err error) { +func Verify(c *Signed, keys openpgp.KeyRing) (err error) { msg := bytes.NewBuffer(c.Body) sig := bytes.NewBuffer(c.Signature) - // TODO: verify signature - _, _ = msg, sig - // _, err = openpgp.CheckArmoredDetachedSignature(key, msg, sig) + _, err = openpgp.CheckArmoredDetachedSignature(keys, msg, sig) return } @@ -471,7 +469,7 @@ func parseStruct(v reflect.Value, fields map[string]string, seen map[string]bool fv.SetString(val) case "int": var val int64 - val, err = strconv.Atoi64(s) + val, err = strconv.ParseInt(s, 10, 64) fv.SetInt(val) case "date": var val int64 @@ -561,7 +559,7 @@ func formatStruct(v reflect.Value, doc *Document) (err error) { case "text": val = formatString(fv.String()) case "int": - val = strconv.Itoa64(fv.Int()) + val = strconv.FormatInt(fv.Int(), 10) case "date": val = formatDate(fv.Int()) case "ids": @@ -677,11 +675,11 @@ func parseDate(s string) (int64, error) { if err != nil { return 0, err } - return t.Seconds(), nil + return t.Unix(), nil } func formatDate(i int64) string { - return time.SecondsToUTC(i).Format(time.RFC3339) + return time.Unix(i,0).Format(time.RFC3339) } func getLine(data []byte) (line, rest []byte) {