From 071e0769e443391ac807b8ff6960a2de9c52f629 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Fri, 9 Oct 2020 14:19:42 +0200 Subject: ffi: Add key flag accessors for ValidKeyAmalgamation. - Add pgp_valid_key_amalgamation_for_certification, pgp_valid_key_amalgamation_for_signing, pgp_valid_key_amalgamation_for_authentication, pgp_valid_key_amalgamation_for_storage_encryption, and pgp_valid_key_amalgamation_for_transport_encryption. --- openpgp-ffi/include/sequoia/openpgp.h | 25 ++++++++++++++++++++++ openpgp-ffi/src/key_amalgamation.rs | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 75b6098b..104dede6 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -1183,6 +1183,31 @@ pgp_revocation_status_t pgp_valid_key_amalgamation_revocation_status (pgp_valid_ /*/ pgp_signature_t pgp_valid_key_amalgamation_binding_signature (pgp_valid_key_amalgamation_t ka); +/*/ +/// Returns whether the key is certification capable. +/*/ +bool pgp_valid_key_amalgamation_for_certification (pgp_valid_key_amalgamation_t ka); + +/*/ +/// Returns whether the key is signing capable. +/*/ +bool pgp_valid_key_amalgamation_for_signing (pgp_valid_key_amalgamation_t ka); + +/*/ +/// Returns whether the key is authentication capable. +/*/ +bool pgp_valid_key_amalgamation_for_authentication (pgp_valid_key_amalgamation_t ka); + +/*/ +/// Returns whether the key is intended for encrypting data at rest. +/*/ +bool pgp_valid_key_amalgamation_for_storage_encryption (pgp_valid_key_amalgamation_t ka); + +/*/ +/// Returns whether the key is intended for encrypting data in transit. +/*/ +bool pgp_valid_key_amalgamation_for_transport_encryption (pgp_valid_key_amalgamation_t ka); + /*/ /// Creates one or more self-signatures that when merged with the /// certificate cause the key to expire at the specified time. diff --git a/openpgp-ffi/src/key_amalgamation.rs b/openpgp-ffi/src/key_amalgamation.rs index f44ad04f..26a67d20 100644 --- a/openpgp-ffi/src/key_amalgamation.rs +++ b/openpgp-ffi/src/key_amalgamation.rs @@ -96,6 +96,46 @@ pub extern "C" fn pgp_valid_key_amalgamation_binding_signature<'a>(ka: *const Va .move_into_raw() } +/// Returns whether the key is certification capable. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_valid_key_amalgamation_for_certification<'a>(ka: *const ValidKeyAmalgamation<'a>) + -> bool +{ + ka.ref_raw().for_certification() +} + +/// Returns whether the key is signing capable. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_valid_key_amalgamation_for_signing<'a>(ka: *const ValidKeyAmalgamation<'a>) + -> bool +{ + ka.ref_raw().for_signing() +} + +/// Returns whether the key is authentication capable. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_valid_key_amalgamation_for_authentication<'a>(ka: *const ValidKeyAmalgamation<'a>) + -> bool +{ + ka.ref_raw().for_authentication() +} + +/// Returns whether the key is intended for encrypting data at rest. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_valid_key_amalgamation_for_storage_encryption<'a>(ka: *const ValidKeyAmalgamation<'a>) + -> bool +{ + ka.ref_raw().for_storage_encryption() +} + +/// Returns whether the key is intended for encrypting data in transit. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_valid_key_amalgamation_for_transport_encryption<'a>(ka: *const ValidKeyAmalgamation<'a>) + -> bool +{ + ka.ref_raw().for_transport_encryption() +} + /// Creates one or more self-signatures that when merged with the /// certificate cause the key to expire at the specified time. /// -- cgit v1.2.3