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:
Adam Langley
2014-05-12 11:23:48 -07:00
parent 2dfe547928
commit 84ca184138
6 changed files with 48 additions and 12 deletions
+2 -2
View File
@@ -364,7 +364,7 @@ EachPacket:
}
if (sig.SigType == packet.SigTypePositiveCert || sig.SigType == packet.SigTypeGenericCert) && sig.IssuerKeyId != nil && *sig.IssuerKeyId == e.PrimaryKey.KeyId {
if err = e.PrimaryKey.VerifyUserIdSignature(pkt.Id, sig); err != nil {
if err = e.PrimaryKey.VerifyUserIdSignature(pkt.Id, e.PrimaryKey, sig); err != nil {
return nil, errors.StructuralError("user ID self-signature invalid: " + err.Error())
}
current.SelfSignature = sig
@@ -616,7 +616,7 @@ func (e *Entity) SignIdentity(identity string, signer *Entity, config *packet.Co
CreationTime: config.Now(),
IssuerKeyId: &signer.PrivateKey.KeyId,
}
if err := sig.SignKey(e.PrimaryKey, signer.PrivateKey, config); err != nil {
if err := sig.SignUserId(identity, e.PrimaryKey, signer.PrivateKey, config); err != nil {
return err
}
ident.Signatures = append(ident.Signatures, sig)