From 3edadb86072d706a2b8bd64e214f61e018cd5423 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 9 Aug 2021 19:21:33 +0200 Subject: [PATCH] Add a "test" fn that prints algorithm information for cards. --- card-functionality/src/main.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/card-functionality/src/main.rs b/card-functionality/src/main.rs index 6efa63c..9e541b1 100644 --- a/card-functionality/src/main.rs +++ b/card-functionality/src/main.rs @@ -36,7 +36,9 @@ use sequoia_openpgp::Cert; use openpgp_card::card_app::CardApp; 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}; @@ -180,6 +182,25 @@ fn test_print_caps( Ok(vec![]) } +fn test_print_algo_info( + ca: &mut CardApp, + _param: &[&str], +) -> Result { + 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( ca: &mut CardApp, param: &[&str], @@ -411,6 +432,9 @@ fn main() -> Result<()> { println!("Reset"); let _ = run_test(&mut card, test_reset, &[])?; + // println!("Algo info"); + // let _ = run_test(&mut card, test_print_algo_info, &[])?; + println!("Generate key"); let _ = run_test(&mut card, test_keygen, &[])?;