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 | |
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')
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp.h | 2 | ||||
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp/types.h | 1 | ||||
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 24 |
3 files changed, 27 insertions, 0 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 66309c03..9eaa2d07 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -1609,6 +1609,8 @@ bool pgp_verification_result_good_checksum (pgp_verification_result_t, pgp_key_t *, pgp_signature_t *, pgp_revocation_status_t *); +bool pgp_verification_result_not_alive (pgp_verification_result_t, + pgp_signature_t *); bool pgp_verification_result_missing_key (pgp_verification_result_t, pgp_signature_t *); bool pgp_verification_result_bad_checksum (pgp_verification_result_t, diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h index d7a8271e..8dbd890b 100644 --- a/openpgp-ffi/include/sequoia/openpgp/types.h +++ b/openpgp-ffi/include/sequoia/openpgp/types.h @@ -480,6 +480,7 @@ typedef enum pgp_verification_result_variant { PGP_VERIFICATION_RESULT_GOOD_CHECKSUM = 1, PGP_VERIFICATION_RESULT_MISSING_KEY = 2, PGP_VERIFICATION_RESULT_BAD_CHECKSUM = 3, + PGP_VERIFICATION_RESULT_NOT_ALIVE = 4, /* Dummy value to make sure the enumeration has a defined size. Do not use this value. */ 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 |