summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/serialize.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-08-20 14:12:44 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-08-20 14:18:06 +0200
commitc59bb02c794294e62da3259561e439ab78e04560 (patch)
treeedb06817e9bdea49456c1aeaf7edef1a7cf0e546 /openpgp-ffi/src/serialize.rs
parentf39af0ed274f85fab408000d68a9395f40b392c2 (diff)
openpgp: Make choice of AEAD algorithm explicit.
- Automatically using AEAD if all recipients claim support is a policy decision, which we'd rather avoid in the openpgp crate. - Fixes #293.
Diffstat (limited to 'openpgp-ffi/src/serialize.rs')
-rw-r--r--openpgp-ffi/src/serialize.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs
index 7c463fc4..1f0a7639 100644
--- a/openpgp-ffi/src/serialize.rs
+++ b/openpgp-ffi/src/serialize.rs
@@ -17,6 +17,7 @@ use self::openpgp::{
crypto::Password,
};
use self::openpgp::constants::{
+ AEADAlgorithm,
DataFormat,
HashAlgorithm,
SymmetricAlgorithm,
@@ -240,7 +241,8 @@ pub extern "C" fn pgp_encryptor_new
passwords: Option<&*const c_char>, passwords_len: size_t,
recipients: Option<&*const TPK>, recipients_len: size_t,
encryption_mode: u8,
- cipher_algo: u8)
+ cipher_algo: u8,
+ aead_algo: u8)
-> *mut writer::Stack<'static, Cookie>
{
ffi_make_fry_from_errp!(errp);
@@ -276,9 +278,15 @@ pub extern "C" fn pgp_encryptor_new
} else {
Some(cipher_algo.into())
};
+ let aead_algo : Option<AEADAlgorithm> = if aead_algo == 0 {
+ None
+ } else {
+ Some(aead_algo.into())
+ };
ffi_try_box!(Encryptor::new(*inner,
&passwords_.iter().collect::<Vec<&Password>>(),
&recipients[..],
encryption_mode,
- cipher_algo))
+ cipher_algo,
+ aead_algo))
}