diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-11-27 13:22:37 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-11-27 13:52:35 +0100 |
commit | dc50161c51d5b479a54d3dc912574f9ed208892a (patch) | |
tree | a1afa74a6ea92fa55225daaf0b39751a04af9a50 /openpgp-ffi/src/cert.rs | |
parent | e59df6db99bc13a6b5b1d1f6ee9e622c60591c00 (diff) |
openpgp: Add Cert::merge_public and Cert::merge_public_and_secret.
- Secret key material is not authenticated by OpenPGP, so care must
be taken when merging certificates.
- Rename Cert::merge to Cert::merge_public_and_secret.
- Add new function Cert::merge_public. This function can be used to
merge certificates from untrusted sources as it ignores secret key
material that cannot be authenticated by OpenPGP.
- Fixes #584.
Diffstat (limited to 'openpgp-ffi/src/cert.rs')
-rw-r--r-- | openpgp-ffi/src/cert.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index 6eecd3d3..37b17472 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -85,20 +85,36 @@ fn pgp_cert_from_packet_parser(errp: Option<&mut *mut crate::error::Error>, openpgp::Cert::try_from(*ppr).move_into_raw(errp) } -/// Merges `other` into `cert`. +/// Merges `other` into `cert`, ignoring secret key material in `other`. /// /// If `other` is a different key, then nothing is merged into /// `cert`, but `cert` is still canonicalized. /// /// Consumes `cert` and `other`. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_cert_merge(errp: Option<&mut *mut crate::error::Error>, +fn pgp_cert_merge_public(errp: Option<&mut *mut crate::error::Error>, cert: *mut Cert, other: *mut Cert) -> Maybe<Cert> { let cert = cert.move_from_raw(); let other = other.move_from_raw(); - cert.merge(other).move_into_raw(errp) + cert.merge_public(other).move_into_raw(errp) +} + +/// Merges `other` into `cert`, including secret key material in `other`. +/// +/// If `other` is a different key, then nothing is merged into +/// `cert`, but `cert` is still canonicalized. +/// +/// Consumes `cert` and `other`. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" +fn pgp_cert_merge_public_and_secret(errp: Option<&mut *mut crate::error::Error>, + cert: *mut Cert, + other: *mut Cert) + -> Maybe<Cert> { + let cert = cert.move_from_raw(); + let other = other.move_from_raw(); + cert.merge_public_and_secret(other).move_into_raw(errp) } /// Adds packets to the Cert. |