diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-11-09 23:55:02 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-11-10 00:05:23 +0100 |
commit | b8e5ef908ee211daee84a0782a115ae7fc003ec0 (patch) | |
tree | 360698ced26dc36aad015e11b89137d613b89208 /openpgp-ffi/src | |
parent | 365862ed513057900c0d6c106ec51dff0a09693e (diff) |
openpgp: Distinguish bad signatures from those that are not alive.
- Return a different `VerificationResult` for signatures that are
not alive (BadSignature) from signatures that are actually
bad (BadCheck).
Diffstat (limited to 'openpgp-ffi/src')
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs index 9148b79c..d46f9042 100644 --- a/openpgp-ffi/src/parse/stream.rs +++ b/openpgp-ffi/src/parse/stream.rs @@ -172,6 +172,7 @@ fn pgp_verification_result_variant(result: *const VerificationResult) GoodChecksum(..) => 1, MissingKey(_) => 2, BadChecksum(_) => 3, + NotAlive(_) => 4, } } @@ -220,6 +221,29 @@ fn pgp_verification_result_good_checksum<'a>( } } +/// Decomposes a `VerificationResult::NotAlive`. +/// +/// Returns `true` iff the given value is a +/// `VerificationResult::NotAlive`, and returns the variant's members +/// in `sig_r` and the like iff `sig_r != NULL`. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" +fn pgp_verification_result_not_alive<'a>( + result: *const VerificationResult<'a>, + sig_r: Maybe<*mut Signature>) + -> bool +{ + use self::stream::VerificationResult::*; + if let NotAlive(ref sig) = result.ref_raw() + { + if let Some(mut p) = sig_r { + *unsafe { p.as_mut() } = sig.move_into_raw(); + } + true + } else { + false + } +} + /// Decomposes a `VerificationResult::MissingKey`. /// /// Returns `true` iff the given value is a |