diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-21 16:35:30 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-09-30 08:31:03 +0300 |
commit | 75b5b3fbbf8c33d10fd30e21f645b8ef1513363a (patch) | |
tree | 733b695659c128cae980c8ebbdc05966038e5707 /openpgp/src/packet/pkesk.rs | |
parent | 795b89ae024d3d49a6f08283184b22770e160317 (diff) |
Improve error message for a malformed packet
Suggested by Neal Walfield.
Found by clippy lint useless_format:
https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
Diffstat (limited to 'openpgp/src/packet/pkesk.rs')
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index 40e7bc37..50ec187a 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -161,7 +161,8 @@ impl PKESK3 { if key_rgn.len() != sym_algo.key_size()? { return Err(Error::MalformedPacket( - format!("session key has the wrong size")).into()); + format!("session key has the wrong size (got: {}, expected: {})", + key_rgn.len(), sym_algo.key_size()?)).into()) } key.copy_from_slice(&plain[key_rgn]); @@ -174,7 +175,7 @@ impl PKESK3 { if their_checksum == our_checksum { Ok((sym_algo, key)) } else { - Err(Error::MalformedPacket(format!("key checksum wrong")) + Err(Error::MalformedPacket("key checksum wrong".to_string()) .into()) } } |