keyfork-shard: better error handling
This commit is contained in:
parent
f91ca2f709
commit
5cf8e9bb0c
|
@ -974,6 +974,7 @@ dependencies = [
|
|||
"keyfork-mnemonic-util",
|
||||
"keyfork-plumbing",
|
||||
"keyfork-shard",
|
||||
"serde",
|
||||
"smex",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -1956,18 +1957,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.190"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
|
||||
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.190"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
|
||||
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -79,7 +79,7 @@ pub struct EncryptedMessage {
|
|||
}
|
||||
|
||||
impl EncryptedMessage {
|
||||
pub fn with_swap(pkesks: &mut Vec<PKESK>, seip: SEIP) -> Self {
|
||||
pub fn new(pkesks: &mut Vec<PKESK>, seip: SEIP) -> Self {
|
||||
Self {
|
||||
pkesks: std::mem::take(pkesks),
|
||||
message: seip,
|
||||
|
@ -156,7 +156,7 @@ pub fn parse_messages(reader: impl Read + Send + Sync) -> Result<VecDeque<Encryp
|
|||
match packet {
|
||||
Packet::PKESK(p) => pkesks.push(p),
|
||||
Packet::SEIP(s) => {
|
||||
encrypted_messages.push_back(EncryptedMessage::with_swap(&mut pkesks, s));
|
||||
encrypted_messages.push_back(EncryptedMessage::new(&mut pkesks, s));
|
||||
}
|
||||
s => {
|
||||
panic!("Invalid variant found: {}", s.tag());
|
||||
|
|
|
@ -18,6 +18,9 @@ use openpgp_card_sequoia::{state::Open, types::Error as SequoiaCardError, Card};
|
|||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Smart card could not decrypt any matching PKESK packets")]
|
||||
SmartCardCouldNotDecrypt,
|
||||
|
||||
#[error("No smart card backend was stored")]
|
||||
SmartCardNotFound,
|
||||
|
||||
|
@ -264,6 +267,6 @@ impl DecryptionHelper for &mut SmartcardManager {
|
|||
}
|
||||
}
|
||||
|
||||
Err(Error::SmartCardNotFound.into())
|
||||
Err(Error::SmartCardCouldNotDecrypt.into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue