projects
/
epoint
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use keyring in verify, add beneficiary to debitcerts
[epoint]
/
document
/
document.go
diff --git
a/document/document.go
b/document/document.go
index
1b87bf6
..
e2a0859
100644
(file)
--- a/
document/document.go
+++ b/
document/document.go
@@
-38,6
+38,7
@@
import (
"crypto/openpgp"
"crypto/openpgp/armor"
"crypto/openpgp/packet"
"crypto/openpgp"
"crypto/openpgp/armor"
"crypto/openpgp/packet"
+ "crypto/sha1"
"encoding/hex"
"fmt"
"reflect"
"encoding/hex"
"fmt"
"reflect"
@@
-147,6
+148,7
@@
type DebitCert struct {
Date int64
Difference int64
Draft string
Date int64
Difference int64
Draft string
+ Beneficiary string
AuthorizedBy string
Notes *string // optional
LastDebitSerial int64 // 0 if none
AuthorizedBy string
Notes *string // optional
LastDebitSerial int64 // 0 if none
@@
-185,6
+187,13
@@
type BounceCert struct {
References []string
}
References []string
}
+// sha1 sum of the (cleaned) document as uppercase hex string
+func Id(d []byte) string {
+ h := sha1.New()
+ h.Write(d)
+ return fmt.Sprintf("%040X", h.Sum())
+}
+
// parse an epoint document without checking the signature and format details
func Parse(s []byte) (iv interface{}, c *Signed, err error) {
c, err = ParseSigned(s)
// parse an epoint document without checking the signature and format details
func Parse(s []byte) (iv interface{}, c *Signed, err error) {
c, err = ParseSigned(s)
@@
-217,7
+226,7
@@
func Format(iv interface{}, key *openpgp.Entity) (s []byte, err error) {
}
// verify an epoint document, return the cleaned version as well
}
// verify an epoint document, return the cleaned version as well
-func Verify(c *Signed, key
*openpgp.Entity
) (cleaned []byte, err error) {
+func Verify(c *Signed, key
openpgp.KeyRing
) (cleaned []byte, err error) {
err = CleanSigned(c)
if err != nil {
return
err = CleanSigned(c)
if err != nil {
return
@@
-230,11
+239,10
@@
func Verify(c *Signed, key *openpgp.Entity) (cleaned []byte, err error) {
}
// verify signature of body with given key
}
// verify signature of body with given key
-func VerifyCleaned(c *Signed, key *openpgp.Entity) (err error) {
- kr := openpgp.EntityList{key}
+func VerifyCleaned(c *Signed, key openpgp.KeyRing) (err error) {
msg := bytes.NewBuffer(c.Body)
sig := bytes.NewBuffer(c.Signature)
msg := bytes.NewBuffer(c.Body)
sig := bytes.NewBuffer(c.Signature)
- _, err = openpgp.CheckArmoredDetachedSignature(k
r
, msg, sig)
+ _, err = openpgp.CheckArmoredDetachedSignature(k
ey
, msg, sig)
return
}
return
}