From 5f49c73febb104213fb2b84906d1c7d0d8a2f547 Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter Date: Thu, 5 Oct 2023 10:28:46 +0200 Subject: [PATCH] fix(v2): Adapt NewForwardingEntity to refactored NewEntity --- openpgp/v2/forwarding.go | 8 ++++---- openpgp/v2/keys.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openpgp/v2/forwarding.go b/openpgp/v2/forwarding.go index 6d6498c61..1306c510c 100644 --- a/openpgp/v2/forwarding.go +++ b/openpgp/v2/forwarding.go @@ -26,14 +26,13 @@ func (e *Entity) NewForwardingEntity( now := config.Now() - if _, err = e.VerifyPrimaryKey(now); err != nil { + if _, err = e.VerifyPrimaryKey(now, config); err != nil { return nil, nil, err } // Generate a new Primary key for the forwardee config.Algorithm = packet.PubKeyAlgoEdDSA config.Curve = packet.Curve25519 - keyLifetimeSecs := config.KeyLifetime() forwardeePrimaryPrivRaw, err := newSigner(config) if err != nil { @@ -49,7 +48,8 @@ func (e *Entity) NewForwardingEntity( Subkeys: []Subkey{}, } - err = forwardeeKey.addUserId(userIdData{name, comment, email}, config, now, keyLifetimeSecs, true) + keyProperties := selectKeyProperties(now, config, primary) + err = forwardeeKey.addUserId(userIdData{name, comment, email}, config, keyProperties) if err != nil { return nil, nil, err } @@ -64,7 +64,7 @@ func (e *Entity) NewForwardingEntity( continue } - forwarderSubKeySelfSig, err := forwarderSubKey.Verify(now) + forwarderSubKeySelfSig, err := forwarderSubKey.Verify(now, config) // Filter expiration & revokal if err != nil { continue diff --git a/openpgp/v2/keys.go b/openpgp/v2/keys.go index 40832ed69..192ebbafc 100644 --- a/openpgp/v2/keys.go +++ b/openpgp/v2/keys.go @@ -636,7 +636,7 @@ func (e *Entity) Serialize(w io.Writer) error { // public key packets contain no meaningful information and do not need // to be serialized. // Prevent public key export for forwarding keys, see forwarding section 4.1. - subKeySelfSig, err := subkey.LatestValidBindingSignature(time.Time{}) + subKeySelfSig, err := subkey.LatestValidBindingSignature(time.Time{}, nil) if subkey.PublicKey.PubKeyAlgo == packet.ExperimentalPubKeyAlgoHMAC || subkey.PublicKey.PubKeyAlgo == packet.ExperimentalPubKeyAlgoAEAD || (err == nil && subKeySelfSig.FlagForward) {