Rename decrypt() to decipher(), to correspond with naming in spec.

Add a note to investigate PKCS#1 formatting of the command input.
This commit is contained in:
Heiko Schaefer 2021-09-03 13:45:19 +02:00
parent 17ee12566f
commit 7a78271211
3 changed files with 8 additions and 5 deletions

View file

@ -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

View file

@ -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<Vec<u8>, Error> {
self.card_app.decrypt(dm)
pub fn decipher(&mut self, dm: Cryptogram) -> Result<Vec<u8>, Error> {
self.card_app.decipher(dm)
}
}

View file

@ -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<Vec<u8>, Error> {
pub fn decipher(&mut self, dm: Cryptogram) -> Result<Vec<u8>, 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`