go.crypto/openpgp: fix user id signing.
Entity.SignIdentity used the wrong signature function and produced invalid certification signatures. Fixed. VerifyUserIdSignature was used for checking the self-signature on an identity, but didn't support anything but a self-signature. This change alters the low-level API so that checking cross-signatures is possible. Fixes golang/go#7371. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/96240043
This commit is contained in:
@@ -620,9 +620,9 @@ func userIdSignatureHash(id string, pk *PublicKey, hashFunc crypto.Hash) (h hash
|
||||
}
|
||||
|
||||
// VerifyUserIdSignature returns nil iff sig is a valid signature, made by this
|
||||
// public key, of id.
|
||||
func (pk *PublicKey) VerifyUserIdSignature(id string, sig *Signature) (err error) {
|
||||
h, err := userIdSignatureHash(id, pk, sig.Hash)
|
||||
// public key, that id is the identity of pub.
|
||||
func (pk *PublicKey) VerifyUserIdSignature(id string, pub *PublicKey, sig *Signature) (err error) {
|
||||
h, err := userIdSignatureHash(id, pub, sig.Hash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -630,9 +630,9 @@ func (pk *PublicKey) VerifyUserIdSignature(id string, sig *Signature) (err error
|
||||
}
|
||||
|
||||
// VerifyUserIdSignatureV3 returns nil iff sig is a valid signature, made by this
|
||||
// public key, of id.
|
||||
func (pk *PublicKey) VerifyUserIdSignatureV3(id string, sig *SignatureV3) (err error) {
|
||||
h, err := userIdSignatureV3Hash(id, pk, sig.Hash)
|
||||
// public key, that id is the identity of pub.
|
||||
func (pk *PublicKey) VerifyUserIdSignatureV3(id string, pub *PublicKey, sig *SignatureV3) (err error) {
|
||||
h, err := userIdSignatureV3Hash(id, pub, sig.Hash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestEcc384Serialize(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
uidSig := p.(*Signature)
|
||||
err = pubkey.VerifyUserIdSignature(uid.Id, uidSig)
|
||||
err = pubkey.VerifyUserIdSignature(uid.Id, pubkey, uidSig)
|
||||
if err != nil {
|
||||
t.Error(err, ": UID")
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ func (pk *PublicKeyV3) VerifySignatureV3(signed hash.Hash, sig *SignatureV3) (er
|
||||
}
|
||||
|
||||
// VerifyUserIdSignatureV3 returns nil iff sig is a valid signature, made by this
|
||||
// public key, of id.
|
||||
func (pk *PublicKeyV3) VerifyUserIdSignatureV3(id string, sig *SignatureV3) (err error) {
|
||||
// public key, that id is the identity of pub.
|
||||
func (pk *PublicKeyV3) VerifyUserIdSignatureV3(id string, pub *PublicKeyV3, sig *SignatureV3) (err error) {
|
||||
h, err := userIdSignatureV3Hash(id, pk, sig.Hash)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -515,7 +515,7 @@ func (sig *Signature) SignUserId(id string, pub *PublicKey, priv *PrivateKey, co
|
||||
return sig.Sign(h, priv, config)
|
||||
}
|
||||
|
||||
// SignKey computes a signature from priv, asserting that pub is a subkey. On
|
||||
// SignKey computes a signature from priv, asserting that pub is a subkey. On
|
||||
// success, the signature is stored in sig. Call Serialize to write it out.
|
||||
// If config is nil, sensible defaults will be used.
|
||||
func (sig *Signature) SignKey(pub *PublicKey, priv *PrivateKey, config *Config) error {
|
||||
|
||||
Reference in New Issue
Block a user