summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-08-24 09:57:13 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-08-24 11:28:56 +0200
commitd90bba28da377df9ae6b1b03c3e34f5b87c784f1 (patch)
treeae241211284f4ce69f0c85f7fb5dbe95fc1b0e36
parent161d6aa9afe5d3bcd95b735c4fe80092fb6c3915 (diff)
ipc: Use the new crypto::ecdh::decrypt_unwrap2.
-rw-r--r--ipc/src/gnupg.rs12
-rw-r--r--ipc/src/sexp.rs5
-rw-r--r--ipc/tests/gpg-agent.rs4
3 files changed, 13 insertions, 8 deletions
diff --git a/ipc/src/gnupg.rs b/ipc/src/gnupg.rs
index be2290f9..629e19e1 100644
--- a/ipc/src/gnupg.rs
+++ b/ipc/src/gnupg.rs
@@ -395,8 +395,9 @@ impl Agent {
/// Decrypts `ciphertext` using `key` with the secret bits managed
/// by the agent.
pub async fn decrypt<'a>(&'a mut self,
- key: &'a KeyPair,
- ciphertext: &'a crypto::mpi::Ciphertext)
+ key: &'a KeyPair,
+ ciphertext: &'a crypto::mpi::Ciphertext,
+ plaintext_len: Option<usize>)
-> Result<crypto::SessionKey>
{
for option in Self::options() {
@@ -456,7 +457,7 @@ impl Agent {
}
Sexp::from_bytes(&data)?.finish_decryption(
- &key.public, ciphertext, padding)
+ &key.public, ciphertext, plaintext_len, padding)
}
/// Computes options that we want to communicate.
@@ -691,7 +692,7 @@ impl crypto::Decryptor for KeyPair {
}
fn decrypt(&mut self, ciphertext: &crypto::mpi::Ciphertext,
- _plaintext_len: Option<usize>)
+ plaintext_len: Option<usize>)
-> openpgp::Result<crypto::SessionKey>
{
use crate::openpgp::crypto::mpi::{PublicKey, Ciphertext};
@@ -707,7 +708,8 @@ impl crypto::Decryptor for KeyPair {
let do_it = async move {
let mut a =
Agent::connect_to(&self.agent_socket).await?;
- let sk = a.decrypt(self, ciphertext).await?;
+ let sk =
+ a.decrypt(self, ciphertext, plaintext_len).await?;
Ok(sk)
};
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index 69c9e151..51c771f0 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -53,6 +53,7 @@ impl Sexp {
recipient: &openpgp::packet::Key<
openpgp::packet::key::PublicParts, R>,
ciphertext: &mpi::Ciphertext,
+ plaintext_len: Option<usize>,
padding: bool)
-> Result<SessionKey>
where R: openpgp::packet::key::KeyRole
@@ -127,7 +128,9 @@ impl Sexp {
let S: Protected = s_.decode_point(curve)?.0.into();
// Now finish the decryption.
- openpgp::crypto::ecdh::decrypt_unwrap(recipient, &S, ciphertext)
+ openpgp::crypto::ecdh::decrypt_unwrap2(
+ recipient.role_as_unspecified(), &S, ciphertext,
+ plaintext_len)
},
_ => {
diff --git a/ipc/tests/gpg-agent.rs b/ipc/tests/gpg-agent.rs
index e5c7858a..bc875641 100644
--- a/ipc/tests/gpg-agent.rs
+++ b/ipc/tests/gpg-agent.rs
@@ -331,7 +331,7 @@ fn decrypt(also_try_explicit_async: bool) -> openpgp::Result<()> {
other.keys().with_policy(p, None)
.for_storage_encryption().for_transport_encryption()
.take(1).next().unwrap().key())?;
- assert!(rt.block_on(agent.decrypt(&keypair, pkesk_1.esk()))
+ assert!(rt.block_on(agent.decrypt(&keypair, pkesk_1.esk(), None))
.is_err());
// Now try "our" key.
@@ -344,7 +344,7 @@ fn decrypt(also_try_explicit_async: bool) -> openpgp::Result<()> {
keypair = keypair.with_password(p);
}
- assert!(rt.block_on(agent.decrypt(&keypair, pkesk_0.esk()))
+ assert!(rt.block_on(agent.decrypt(&keypair, pkesk_0.esk(), None))
.is_ok());
// Close connection.