diff -r 7ec969250bfc src/pkg/crypto/openpgp/packet/private_key.go
--- a/src/pkg/crypto/openpgp/packet/private_key.go Tue Dec 27 09:49:19 2011 -0500
-+++ b/src/pkg/crypto/openpgp/packet/private_key.go Sat Dec 31 02:23:50 2011 +0100
++++ b/src/pkg/crypto/openpgp/packet/private_key.go Sat Dec 31 02:32:45 2011 +0100
@@ -28,7 +28,7 @@
encryptedData []byte
cipher CipherFunction
if !pk.Encrypted {
diff -r 7ec969250bfc src/pkg/crypto/openpgp/packet/public_key.go
--- a/src/pkg/crypto/openpgp/packet/public_key.go Tue Dec 27 09:49:19 2011 -0500
-+++ b/src/pkg/crypto/openpgp/packet/public_key.go Sat Dec 31 02:23:50 2011 +0100
++++ b/src/pkg/crypto/openpgp/packet/public_key.go Sat Dec 31 02:32:45 2011 +0100
@@ -53,6 +53,23 @@
return pk
}
func (pk *PublicKey) parse(r io.Reader) (err error) {
// RFC 4880, section 5.5.2
var buf [6]byte
-@@ -291,7 +308,13 @@
+@@ -291,7 +308,14 @@
return nil
case PubKeyAlgoDSA:
dsaPublicKey, _ := pk.PublicKey.(*dsa.PublicKey)
- if !dsa.Verify(dsaPublicKey, hashBytes, new(big.Int).SetBytes(sig.DSASigR.bytes), new(big.Int).SetBytes(sig.DSASigS.bytes)) {
-+ // hash truncation according to FIPS 186-3 section 4.6
++ // Hash truncation according to FIPS 186-3 section 4.6
++ // Assuming Q.BitLen() is a multiple of 8
+ n := len(hashBytes)
-+ k := (dsaPublicKey.Q.BitLen() + 7) / 8
++ k := dsaPublicKey.Q.BitLen() / 8
+ if n > k {
+ n = k
+ }
diff -r 7ec969250bfc src/pkg/crypto/openpgp/packet/signature.go
--- a/src/pkg/crypto/openpgp/packet/signature.go Tue Dec 27 09:49:19 2011 -0500
-+++ b/src/pkg/crypto/openpgp/packet/signature.go Sat Dec 31 02:23:37 2011 +0100
++++ b/src/pkg/crypto/openpgp/packet/signature.go Sat Dec 31 02:32:41 2011 +0100
@@ -164,7 +164,7 @@
const (
creationTimeSubpacket signatureSubpacketType = 2
// Key expiration time, section 5.2.3.6
if !isHashed {
return
-@@ -443,7 +439,14 @@
+@@ -443,7 +439,15 @@
sig.RSASignature.bytes, err = rsa.SignPKCS1v15(rand.Reader, priv.PrivateKey.(*rsa.PrivateKey), sig.Hash, digest)
sig.RSASignature.bitLength = uint16(8 * len(sig.RSASignature.bytes))
case PubKeyAlgoDSA:
- r, s, err := dsa.Sign(rand.Reader, priv.PrivateKey.(*dsa.PrivateKey), digest)
+ dsaPrivateKey := priv.PrivateKey.(*dsa.PrivateKey)
-+ // hash truncation according to FIPS 186-3 section 4.6
++ // Hash truncation according to FIPS 186-3 section 4.6
++ // Assuming Q.BitLen() is a multiple of 8
+ n := len(digest)
-+ k := (dsaPrivateKey.Q.BitLen() + 7) / 8
++ k := dsaPrivateKey.Q.BitLen() / 8
+ if n > k {
+ n = k
+ }
if err == nil {
sig.DSASigR.bytes = r.Bytes()
sig.DSASigR.bitLength = uint16(8 * len(sig.DSASigR.bytes))
-@@ -556,5 +559,59 @@
+@@ -556,5 +560,59 @@
subpackets = append(subpackets, outputSubpacket{true, issuerSubpacket, false, keyId})
}