projects
/
epoint
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
726f6af
)
clean body in document.Sign
author
nsz
<nsz@port70.net>
Mon, 28 Nov 2011 19:11:00 +0000
(20:11 +0100)
committer
nsz
<nsz@port70.net>
Mon, 28 Nov 2011 19:11:00 +0000
(20:11 +0100)
document/document.go
patch
|
blob
|
history
diff --git
a/document/document.go
b/document/document.go
index
0ac99b6
..
1e26d28
100644
(file)
--- a/
document/document.go
+++ b/
document/document.go
@@
-32,7
+32,7
@@
package document
// TODO: fields of notice (last notice, serial, failure notice,..)
// TODO: limits and cert type specific input validation
// TODO: fix Cert mess
// TODO: fields of notice (last notice, serial, failure notice,..)
// TODO: limits and cert type specific input validation
// TODO: fix Cert mess
-// TODO: nonce is id, id is even number of hex digits
+// TODO: nonce is id, id is even number of hex digits
(require only draftid.nonce to be uniq)
// TODO: denom, issuer from key (key representation: armor?)
import (
// TODO: denom, issuer from key (key representation: armor?)
import (
@@
-258,6
+258,15
@@
func ToCert(v interface{}) (cert *Cert, err error) {
return
}
return
}
+func cleanBody(s []byte) []byte {
+ nl := []byte{'\n'}
+ a := bytes.Split(s, nl)
+ for i := range a {
+ a[i] = bytes.TrimRight(a[i], " \t")
+ }
+ return bytes.Join(a, nl)
+}
+
// sha1 sum of the (cleaned) document body as uppercase hex string
func Id(c *Signed) string {
h := sha1.New()
// sha1 sum of the (cleaned) document body as uppercase hex string
func Id(c *Signed) string {
h := sha1.New()
@@
-311,7
+320,7
@@
func Verify(c *Signed, key openpgp.KeyRing) (err error) {
func Sign(body []byte, key *openpgp.Entity) (c *Signed, err error) {
c = new(Signed)
c.Hash = "SHA256"
func Sign(body []byte, key *openpgp.Entity) (c *Signed, err error) {
c = new(Signed)
c.Hash = "SHA256"
- c.Body =
body
+ c.Body =
cleanBody(body)
w := new(bytes.Buffer)
err = openpgp.ArmoredDetachSignText(w, key, bytes.NewBuffer(c.Body))
if err != nil {
w := new(bytes.Buffer)
err = openpgp.ArmoredDetachSignText(w, key, bytes.NewBuffer(c.Body))
if err != nil {