summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-03-18 14:04:23 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-03-18 14:47:44 +0100
commit97cdc3062d88401dcc849c3f4e093a4f7b1b1226 (patch)
tree0859e06007b25e9cabbf4e9bfd7a2487ea2e8585 /openpgp-ffi
parent01db33b99244294702f0f58f06c6736becee28db (diff)
openpgp: Make cipher algorithm configurable in streaming Encryptor.
- Fixes #208.
Diffstat (limited to 'openpgp-ffi')
-rw-r--r--openpgp-ffi/examples/encrypt-for.c9
-rw-r--r--openpgp-ffi/include/sequoia/openpgp.h16
-rw-r--r--openpgp-ffi/src/serialize.rs10
3 files changed, 18 insertions, 17 deletions
diff --git a/openpgp-ffi/examples/encrypt-for.c b/openpgp-ffi/examples/encrypt-for.c
index 16295678..32106319 100644
--- a/openpgp-ffi/examples/encrypt-for.c
+++ b/openpgp-ffi/examples/encrypt-for.c
@@ -56,10 +56,11 @@ main (int argc, char **argv)
writer = pgp_writer_stack_message (sink);
writer = pgp_encryptor_new (&err,
- writer,
- NULL, 0, /* no passwords */
- &tpk, 1,
- PGP_ENCRYPTION_MODE_FOR_TRANSPORT);
+ writer,
+ NULL, 0, /* no passwords */
+ &tpk, 1,
+ PGP_ENCRYPTION_MODE_FOR_TRANSPORT,
+ 9 /* AES256 */);
if (writer == NULL)
error (1, 0, "pgp_encryptor_new: %s", pgp_error_to_string (err));
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h
index b00cce91..7063d214 100644
--- a/openpgp-ffi/include/sequoia/openpgp.h
+++ b/openpgp-ffi/include/sequoia/openpgp.h
@@ -1378,17 +1378,15 @@ pgp_writer_stack_t pgp_literal_writer_new (pgp_error_t *errp,
/// The stream will be encrypted using a generated session key,
/// which will be encrypted using the given passwords, and all
/// encryption-capable subkeys of the given TPKs.
-///
-/// The stream is encrypted using AES256, regardless of any key
-/// preferences.
/*/
pgp_writer_stack_t pgp_encryptor_new (pgp_error_t *errp,
- pgp_writer_stack_t inner,
- char **passwords,
- size_t passwords_len,
- pgp_tpk_t *recipients,
- size_t recipients_len,
- pgp_encryption_mode_t mode);
+ pgp_writer_stack_t inner,
+ char **passwords,
+ size_t passwords_len,
+ pgp_tpk_t *recipients,
+ size_t recipients_len,
+ pgp_encryption_mode_t mode,
+ uint8_t cipher_algo);
/*/
/// Creates an pgp_secret_t from a decrypted session key.
diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs
index 61e69a98..f39a069d 100644
--- a/openpgp-ffi/src/serialize.rs
+++ b/openpgp-ffi/src/serialize.rs
@@ -221,7 +221,8 @@ pub extern "system" fn pgp_encryptor_new
inner: *mut writer::Stack<'static, Cookie>,
passwords: Option<&*const c_char>, passwords_len: size_t,
recipients: Option<&*const TPK>, recipients_len: size_t,
- encryption_mode: uint8_t)
+ encryption_mode: uint8_t,
+ cipher_algo: uint8_t)
-> *mut writer::Stack<'static, Cookie>
{
ffi_make_fry_from_errp!(errp);
@@ -253,7 +254,8 @@ pub extern "system" fn pgp_encryptor_new
_ => panic!("Bad encryption mode: {}", encryption_mode),
};
ffi_try_box!(Encryptor::new(*inner,
- &passwords_.iter().collect::<Vec<&Password>>(),
- &recipients[..],
- encryption_mode))
+ &passwords_.iter().collect::<Vec<&Password>>(),
+ &recipients[..],
+ encryption_mode,
+ Some(cipher_algo.into())))
}