projects
/
epoint
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7abbc4c
)
use keyring in verify, add beneficiary to debitcerts
author
nsz
<nsz@port70.net>
Wed, 23 Nov 2011 22:18:34 +0000
(23:18 +0100)
committer
nsz
<nsz@port70.net>
Wed, 23 Nov 2011 22:18:34 +0000
(23:18 +0100)
document/document.go
patch
|
blob
|
history
document/document_test.go
patch
|
blob
|
history
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
}
diff --git
a/document/document_test.go
b/document/document_test.go
index
024b0bd
..
9bd2db1
100644
(file)
--- a/
document/document_test.go
+++ b/
document/document_test.go
@@
-187,6
+187,7
@@
Issuer: 000000000000000000000000000000000000000B
Date: 2011-11-13T12:20:35Z
Difference: 1
Draft: 000000000000000000000000000000000000000D
Date: 2011-11-13T12:20:35Z
Difference: 1
Draft: 000000000000000000000000000000000000000D
+Beneficiary: 000000000000000000000000000000000000000E
Authorized-By: 000000000000000000000000000000000000000A
Notes: -
Last-Debit-Serial: 0
Authorized-By: 000000000000000000000000000000000000000A
Notes: -
Last-Debit-Serial: 0