Add a "test" fn that prints algorithm information for cards.

This commit is contained in:
Heiko Schaefer 2021-08-09 19:21:33 +02:00
parent 608e6533a6
commit 3edadb8607

View file

@ -36,7 +36,9 @@ use sequoia_openpgp::Cert;
use openpgp_card::card_app::CardApp; use openpgp_card::card_app::CardApp;
use openpgp_card::errors::{OcErrorStatus, OpenpgpCardError}; use openpgp_card::errors::{OcErrorStatus, OpenpgpCardError};
use openpgp_card::{KeyType, PublicKeyMaterial, Sex}; use openpgp_card::{
Algo, Curve, EccAttrs, EccType, KeyType, PublicKeyMaterial, RsaAttrs, Sex,
};
use crate::cards::{TestCard, TestConfig}; use crate::cards::{TestCard, TestConfig};
@ -180,6 +182,25 @@ fn test_print_caps(
Ok(vec![]) Ok(vec![])
} }
fn test_print_algo_info(
ca: &mut CardApp,
_param: &[&str],
) -> Result<TestOutput, TestError> {
let ard = ca.get_app_data()?;
let dec = CardApp::get_algorithm_attributes(&ard, KeyType::Decryption)?;
println!("Current algorithm for the decrypt slot: {}", dec);
println!();
let algo = ca.list_supported_algo();
if let Ok(Some(algo)) = algo {
println!("Card algorithm list:\n{}", algo);
}
Ok(vec![])
}
fn test_upload_keys( fn test_upload_keys(
ca: &mut CardApp, ca: &mut CardApp,
param: &[&str], param: &[&str],
@ -411,6 +432,9 @@ fn main() -> Result<()> {
println!("Reset"); println!("Reset");
let _ = run_test(&mut card, test_reset, &[])?; let _ = run_test(&mut card, test_reset, &[])?;
// println!("Algo info");
// let _ = run_test(&mut card, test_print_algo_info, &[])?;
println!("Generate key"); println!("Generate key");
let _ = run_test(&mut card, test_keygen, &[])?; let _ = run_test(&mut card, test_keygen, &[])?;