Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions openpgp/key_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ func NewEntity(name, comment, email string, config *packet.Config) (*Entity, err
return nil, err
}

// NOTE: No key expiry here, but we will not return this subkey in EncryptionKey()
// if the primary/master key has expired.
err = e.addEncryptionSubkey(config, creationTime, 0)
if err != nil {
return nil, err
if !config.NoEncryptionSubkey() {
// NOTE: No key expiry here, but we will not return this subkey in EncryptionKey()
// if the primary/master key has expired.
err = e.addEncryptionSubkey(config, creationTime, 0)
if err != nil {
return nil, err
}
}

return e, nil
Expand Down
11 changes: 11 additions & 0 deletions openpgp/packet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@
// read from a compressed packet. This serves as an upper limit to prevent
// excessively large decompressed messages.
MaxDecompressedMessageSize *int64

// NoEncryptionSubkey configures key generation. true results in an
// OpenPGP key that has no encryption-capable subkey
NoEncryptionSubkey bool

Check failure on line 201 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / test

other declaration of NoEncryptionSubkey

Check failure on line 201 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v1-api

other declaration of NoEncryptionSubkey

Check failure on line 201 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v2-api

other declaration of NoEncryptionSubkey
}

func (c *Config) Random() io.Reader {
Expand Down Expand Up @@ -453,6 +457,13 @@
return c.MaxDecompressedMessageSize
}

func (c *Config) NoEncryptionSubkey() bool {

Check failure on line 460 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / test

field and method with the same name NoEncryptionSubkey

Check failure on line 460 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v1-api

field and method with the same name NoEncryptionSubkey

Check failure on line 460 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v2-api

field and method with the same name NoEncryptionSubkey
if c == nil {
return false
}
return c.NoEncryptionSubkey

Check failure on line 464 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / test

cannot use c.NoEncryptionSubkey (value of type func() bool) as bool value in return statement

Check failure on line 464 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v1-api

cannot use c.NoEncryptionSubkey (value of type func() bool) as bool value in return statement

Check failure on line 464 in openpgp/packet/config.go

View workflow job for this annotation

GitHub Actions / Build gosop from branch v2-api

cannot use c.NoEncryptionSubkey (value of type func() bool) as bool value in return statement
}

// BoolPointer is a helper function to set a boolean pointer in the Config.
// e.g., config.CheckPacketSequence = BoolPointer(true)
func BoolPointer(value bool) *bool {
Expand Down
12 changes: 7 additions & 5 deletions openpgp/v2/key_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ func newEntity(uid *userIdData, config *packet.Config) (*Entity, error) {
}
}

// NOTE: No key expiry here, but we will not return this subkey in EncryptionKey()
// if the primary/master key has expired.
err = e.addEncryptionSubkey(config, creationTime, 0)
if err != nil {
return nil, err
if !config.NoEncryptionSubkey() {
// NOTE: No key expiry here, but we will not return this subkey in EncryptionKey()
// if the primary/master key has expired.
err = e.addEncryptionSubkey(config, creationTime, 0)
if err != nil {
return nil, err
}
}

return e, nil
Expand Down
Loading