Skip to content

Commit

Permalink
fix(v2): Adapt NewForwardingEntity to refactored NewEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Oct 1, 2024
1 parent 9aa010a commit 5f49c73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions openpgp/v2/forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openpgp/v2/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5f49c73

Please sign in to comment.