Skip to content
Open
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 src/pgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ pub(crate) fn create_keypair(addr: EmailAddress) -> Result<SignedSecretKey> {
/// Selects a subkey of the public key to use for encryption.
///
/// Returns `None` if the public key cannot be used for encryption.
///
/// TODO: take key flags and expiration dates into account
fn select_pk_for_encryption(key: &SignedPublicKey) -> Option<&SignedPublicSubKey> {
key.public_subkeys
.iter()
.find(|subkey| subkey.algorithm().can_encrypt())
key.public_subkeys.iter().find(|subkey| {
subkey.algorithm().can_encrypt()
&& subkey
.signatures
.iter()
.any(|signature| signature.key_flags().encrypt_comms())
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, if all the subkeys are expired, will this mean that the receiver is not able to decrypt messages anymore all of a sudden?

For many years, we were on the position of "if the key is expired, just use it anyways, there is nothing better we can do". Maybe we should extend the logic to use expired subkeys if there is no non-expired subkey?

}

/// Version of SEIPD packet to use.
Expand Down
Loading