// 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 (
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()
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 {