From 7a78271211d96624c9c59f5c4f2b0ef750295f14 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Fri, 3 Sep 2021 13:45:19 +0200 Subject: [PATCH] Rename decrypt() to decipher(), to correspond with naming in spec. Add a note to investigate PKCS#1 formatting of the command input. --- openpgp-card-sequoia/src/decryptor.rs | 4 ++-- openpgp-card-sequoia/src/lib.rs | 4 ++-- openpgp-card/src/card_app.rs | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/openpgp-card-sequoia/src/decryptor.rs b/openpgp-card-sequoia/src/decryptor.rs index 90a6176..13b9082 100644 --- a/openpgp-card-sequoia/src/decryptor.rs +++ b/openpgp-card-sequoia/src/decryptor.rs @@ -93,7 +93,7 @@ impl<'a> crypto::Decryptor for CardDecryptor<'a> { match (ciphertext, self.public.mpis()) { (mpi::Ciphertext::RSA { c: ct }, mpi::PublicKey::RSA { .. }) => { let dm = Cryptogram::RSA(ct.value()); - let dec = self.ca.decrypt(dm)?; + let dec = self.ca.decipher(dm)?; let sk = openpgp::crypto::SessionKey::from(&dec[..]); Ok(sk) @@ -111,7 +111,7 @@ impl<'a> crypto::Decryptor for CardDecryptor<'a> { }; // Decryption operation on the card - let mut dec = self.ca.decrypt(dm)?; + let mut dec = self.ca.decipher(dm)?; // Specifically handle return value format like Gnuk's // (Gnuk returns a leading '0x04' byte and diff --git a/openpgp-card-sequoia/src/lib.rs b/openpgp-card-sequoia/src/lib.rs index 4a5196f..6ffa2fb 100644 --- a/openpgp-card-sequoia/src/lib.rs +++ b/openpgp-card-sequoia/src/lib.rs @@ -779,8 +779,8 @@ impl DerefMut for CardUser { impl CardUser { /// Decrypt the ciphertext in `dm`, on the card. - pub fn decrypt(&mut self, dm: Cryptogram) -> Result, Error> { - self.card_app.decrypt(dm) + pub fn decipher(&mut self, dm: Cryptogram) -> Result, Error> { + self.card_app.decipher(dm) } } diff --git a/openpgp-card/src/card_app.rs b/openpgp-card/src/card_app.rs index 9839d36..54ec2fc 100644 --- a/openpgp-card/src/card_app.rs +++ b/openpgp-card/src/card_app.rs @@ -374,10 +374,13 @@ impl CardApp { /// /// (This is a wrapper around the low-level pso_decipher /// operation, it builds the required `data` field from `dm`) - pub fn decrypt(&mut self, dm: Cryptogram) -> Result, Error> { + pub fn decipher(&mut self, dm: Cryptogram) -> Result, Error> { match dm { Cryptogram::RSA(message) => { let mut data = vec![0x0]; + + // FIXME: The spec says we should "format according to PKCS#1" + data.extend_from_slice(message); // Call the card to decrypt `data`