|
@@ -465,7 +465,8 @@ func addSubkey(e *Entity, packets *packet.Reader, pub *packet.PublicKey, priv *p
|
|
|
case packet.SigTypeSubkeyRevocation:
|
|
case packet.SigTypeSubkeyRevocation:
|
|
|
subKey.Sig = sig
|
|
subKey.Sig = sig
|
|
|
case packet.SigTypeSubkeyBinding:
|
|
case packet.SigTypeSubkeyBinding:
|
|
|
- if subKey.Sig == nil {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if shouldReplaceSubkeySig(subKey.Sig, sig) {
|
|
|
subKey.Sig = sig
|
|
subKey.Sig = sig
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -480,6 +481,22 @@ func addSubkey(e *Entity, packets *packet.Reader, pub *packet.PublicKey, priv *p
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func shouldReplaceSubkeySig(existingSig, potentialNewSig *packet.Signature) bool {
|
|
|
|
|
+ if potentialNewSig == nil {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if existingSig == nil {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if existingSig.SigType == packet.SigTypeSubkeyRevocation {
|
|
|
|
|
+ return false // never override a revocation signature
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return potentialNewSig.CreationTime.After(existingSig.CreationTime)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const defaultRSAKeyBits = 2048
|
|
const defaultRSAKeyBits = 2048
|
|
|
|
|
|
|
|
// NewEntity returns an Entity that contains a fresh RSA/RSA keypair with a
|
|
// NewEntity returns an Entity that contains a fresh RSA/RSA keypair with a
|