From 5efa1646dfe4080fdbe199c26037292b3ece7dc1 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 7 Mar 2023 14:16:51 +0100 Subject: [PATCH] Add pgp_cipher_suite_is_supported - Add support to query whether the current cryptographic backend supports the specified cipher suite. - Fixes #28 --- src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2b97de6..645628d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -148,6 +148,25 @@ ffi!(fn pgp_config_cipher_suite(session: *mut Session, suite: PepCipherSuite) session.set_cipher_suite(suite) }); +// Given the pEp cipher suite indicator enum, returns whether the +// cipher suite is supported. +// +// Returns `StatusOk` if it is supported, and `CannotConfig` is not +// supported by the current cryptographic backend. +ffi!(fn pgp_cipher_suite_is_supported(session: *mut Session, + suite: PepCipherSuite) + -> Result<()> +{ + let _session = Session::as_mut(session)?; + + let suite: Result = suite.try_into(); + if let Err(_err) = suite { + Err(Error::CannotConfig("cipher suite".into())) + } else { + Ok(()) + } +}); + // Decrypts the key. // // On success, returns the decrypted key. -- GitLab