feat: pgp decrypt

This commit is contained in:
2021-07-18 10:56:48 +08:00
parent 1d1e0ada87
commit 24449711e9
11 changed files with 131 additions and 14 deletions

View File

@@ -18,3 +18,20 @@ pub fn get_card_user_sw1_81(pass: &str) -> XResult<OpenPGPCardUser> {
}
}
pub fn get_card_user_sw1_82(pass: &str) -> XResult<OpenPGPCardUser> {
match OpenPGPCard::list_cards() {
Ok(list) => {
// pw1_82 for decrypt
// PKCSv1.5
if list.is_empty() {
return simple_error!("Cannot find any card");
}
match list.into_iter().next().unwrap().verify_pw1_82(pass) {
Result::Ok(user) => Ok(user),
Result::Err(_) => simple_error!("Verify pw1_82 OpenPGP card failed"),
}
}
Err(e) => simple_error!("Read OpenPGP card failed: {}", e),
}
}