Panic with NFC connection lost
thread '<unnamed>' panicked at /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openpgp-card-sequoia-0.2.1/src/lib.rs:923:14:
Couldn't get decryption pubkey from card
stack backtrace:
0: rust_begin_unwind
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/std/src/panicking.rs:647:5
1: core::panicking::panic_fmt
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/core/src/panicking.rs:72:14
2: core::panicking::panic_display
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/core/src/panicking.rs:196:5
3: core::panicking::panic_str
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/core/src/panicking.rs:171:5
4: core::option::expect_failed
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/core/src/option.rs:1988:5
5: core::option::Option<T>::expect
at /rustc/8ace7ea1f7cbba7b4f031e66c54ca237a0d65de6/library/core/src/option.rs:894:21
6: openpgp_card_sequoia::Card<openpgp_card_sequoia::state::User>::decryptor
at /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openpgp-card-sequoia-0.2.1/src/lib.rs:919:18
Basically what happens is if I move the key away from the reader before it's done, depending on where it is within the NFC transaction, I get a panic instead of a recoverable error.
Looking at the code it's failing at
pub fn decryptor(
&mut self,
touch_prompt: &'open (dyn Fn() + Send + Sync),
) -> Result<CardDecryptor<'_, 'app>, Error> {
let pk = self
.state
.tx
.public_key(KeyType::Decryption)?
.expect("Couldn't get decryption pubkey from card");
Ok(CardDecryptor::with_pubkey(self.card(), pk, touch_prompt))
}
I think (.expect(...)).
Would it be reasonable to ? these instead of expect them? I see similar in a number of other functions, I'm not sure which ones are actually implicated in external circumstances though, or if maybe some of them should be kept as expect.