mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 10:56:29 +03:00
feat: use SEIPDv2 if all recipients support it
This commit is contained in:
29
src/pgp.rs
29
src/pgp.rs
@@ -495,6 +495,35 @@ pub(crate) fn addresses_from_public_key(public_key: &SignedPublicKey) -> Option<
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns true if public key advertises SEIPDv2 feature.
|
||||
pub(crate) fn pubkey_supports_seipdv2(public_key: &SignedPublicKey) -> bool {
|
||||
// If any Direct Key Signature or any User ID signature has SEIPDv2 feature,
|
||||
// assume that recipient can handle SEIPDv2.
|
||||
//
|
||||
// Third-party User ID signatures are dropped during certificate merging.
|
||||
// We don't check if the User ID is primary User ID.
|
||||
// Primary User ID is preferred during merging
|
||||
// and if some key has only non-primary User ID
|
||||
// it is acceptable. It is anyway unlikely that SEIPDv2
|
||||
// is advertised in a key without DKS or primary User ID.
|
||||
public_key
|
||||
.details
|
||||
.direct_signatures
|
||||
.iter()
|
||||
.chain(
|
||||
public_key
|
||||
.details
|
||||
.users
|
||||
.iter()
|
||||
.flat_map(|user| user.signatures.iter()),
|
||||
)
|
||||
.any(|signature| {
|
||||
signature
|
||||
.features()
|
||||
.is_some_and(|features| features.seipd_v2())
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::LazyLock;
|
||||
|
||||
Reference in New Issue
Block a user