summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2022-10-03 11:49:32 +0200
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2022-12-21 10:50:46 +0100
commit459d8b20054f554fd47bc7184cf2dd4a2a658595 (patch)
treedc54ef3c7b8f8e403708069075bb0c38b1c07abc
parent88f9a613baa2bd844b1ef9a3caea82562418725e (diff)
openpgp: Adjust error messages on decryption failures.
-rw-r--r--openpgp/src/packet/key.rs3
-rw-r--r--openpgp/src/packet/pkesk.rs9
2 files changed, 8 insertions, 4 deletions
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs
index 305e4ba2..593b4fe6 100644
--- a/openpgp/src/packet/key.rs
+++ b/openpgp/src/packet/key.rs
@@ -1924,7 +1924,8 @@ mod tests {
let sk = SessionKey::new(cipher.key_size().unwrap());
let pkesk = PKESK3::for_recipient(cipher, &sk, &key).unwrap();
- let (cipher_, sk_) = pkesk.decrypt(&mut keypair, None).unwrap();
+ let (cipher_, sk_) = pkesk.decrypt(&mut keypair, None)
+ .expect("keypair should be able to decrypt PKESK");
assert_eq!(cipher, cipher_);
assert_eq!(sk, sk_);
diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs
index ac0b7932..ff29ca65 100644
--- a/openpgp/src/packet/pkesk.rs
+++ b/openpgp/src/packet/pkesk.rs
@@ -309,7 +309,8 @@ mod tests {
let pkesk: &PKESK =
pile.descendants().next().unwrap().downcast_ref().unwrap();
- let plain = pkesk.decrypt(&mut keypair, None).unwrap();
+ let plain = pkesk.decrypt(&mut keypair, None)
+ .expect("ECDH decryption using P-256 key should work");
let plain_ =
pkesk.decrypt(&mut keypair, Some(SymmetricAlgorithm::AES256))
.unwrap();
@@ -338,7 +339,8 @@ mod tests {
let pkesk: &PKESK =
pile.descendants().next().unwrap().downcast_ref().unwrap();
- let plain = pkesk.decrypt(&mut keypair, None).unwrap();
+ let plain = pkesk.decrypt(&mut keypair, None)
+ .expect("ECDH decryption using P-384 key should work");
let plain_ =
pkesk.decrypt(&mut keypair, Some(SymmetricAlgorithm::AES256))
.unwrap();
@@ -367,7 +369,8 @@ mod tests {
let pkesk: &PKESK =
pile.descendants().next().unwrap().downcast_ref().unwrap();
- let plain = pkesk.decrypt(&mut keypair, None).unwrap();
+ let plain = pkesk.decrypt(&mut keypair, None)
+ .expect("ECDH decryption using P-521 key should work");
let plain_ =
pkesk.decrypt(&mut keypair, Some(SymmetricAlgorithm::AES256))
.unwrap();