From 889eedbb795d85e137402ea209c031a58d15ae3c Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Tue, 15 Feb 2022 16:07:05 +0100 Subject: [PATCH] Remove cardholder_certificate from the public CardClient API, for now (until we learn of actual use cases for this part of the spec). --- card-functionality/src/tests.rs | 118 ++++++++++++++++---------------- openpgp-card/src/lib.rs | 3 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index dcc4b9b..4a9613e 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -391,65 +391,65 @@ pub fn test_private_data( Ok(out) } -pub fn test_cardholder_cert( - card_client: &mut (dyn CardClient + Send + Sync), - _param: &[&str], -) -> Result { - let mut out = vec![]; - - println!(); - - match card_client.cardholder_certificate() { - Ok(res) => { - out.push(TestResult::Text(format!("got cert {:x?}", res.data()))) - } - Err(e) => { - out.push(TestResult::Text(format!( - "get_cardholder_certificate failed: {:?}", - e - ))); - return Ok(out); - } - }; - - card_client.verify_pw3("12345678")?; - - let data = "Foo bar baz!".as_bytes(); - - match card_client.set_cardholder_certificate(data.to_vec()) { - Ok(_resp) => out.push(TestResult::Text("set cert ok".to_string())), - Err(e) => { - out.push(TestResult::Text(format!( - "set_cardholder_certificate: {:?}", - e - ))); - return Ok(out); - } - } - - let res = card_client.cardholder_certificate()?; - out.push(TestResult::Text("get cert ok".to_string())); - - if res.data() != data { - out.push(TestResult::Text(format!( - "get after set doesn't match original data: {:x?}", - data - ))); - return Ok(out); - }; - - // try using slot 2 - - match card_client.select_data(2, &[0x7F, 0x21]) { - Ok(_res) => out.push(TestResult::Text("select_data ok".to_string())), - Err(e) => { - out.push(TestResult::Text(format!("select_data: {:?}", e))); - return Ok(out); - } - } - - Ok(out) -} +// pub fn test_cardholder_cert( +// card_client: &mut (dyn CardClient + Send + Sync), +// _param: &[&str], +// ) -> Result { +// let mut out = vec![]; +// +// println!(); +// +// match card_client.cardholder_certificate() { +// Ok(res) => { +// out.push(TestResult::Text(format!("got cert {:x?}", res.data()))) +// } +// Err(e) => { +// out.push(TestResult::Text(format!( +// "get_cardholder_certificate failed: {:?}", +// e +// ))); +// return Ok(out); +// } +// }; +// +// card_client.verify_pw3("12345678")?; +// +// let data = "Foo bar baz!".as_bytes(); +// +// match card_client.set_cardholder_certificate(data.to_vec()) { +// Ok(_resp) => out.push(TestResult::Text("set cert ok".to_string())), +// Err(e) => { +// out.push(TestResult::Text(format!( +// "set_cardholder_certificate: {:?}", +// e +// ))); +// return Ok(out); +// } +// } +// +// let res = card_client.cardholder_certificate()?; +// out.push(TestResult::Text("get cert ok".to_string())); +// +// if res.data() != data { +// out.push(TestResult::Text(format!( +// "get after set doesn't match original data: {:x?}", +// data +// ))); +// return Ok(out); +// }; +// +// // try using slot 2 +// +// match card_client.select_data(2, &[0x7F, 0x21]) { +// Ok(_res) => out.push(TestResult::Text("select_data ok".to_string())), +// Err(e) => { +// out.push(TestResult::Text(format!("select_data: {:?}", e))); +// return Ok(out); +// } +// } +// +// Ok(out) +// } pub fn test_pw_status( card_client: &mut (dyn CardClient + Send + Sync), diff --git a/openpgp-card/src/lib.rs b/openpgp-card/src/lib.rs index 6d994a8..cfbf14b 100644 --- a/openpgp-card/src/lib.rs +++ b/openpgp-card/src/lib.rs @@ -295,7 +295,8 @@ impl<'a> dyn CardClient + 'a { /// /// Call select_data() before calling this fn, to select a particular /// certificate (if the card supports multiple certificates). - pub fn cardholder_certificate(&mut self) -> Result { + #[allow(dead_code)] + fn cardholder_certificate(&mut self) -> Result { let cmd = commands::cardholder_certificate(); apdu::send_command(self, cmd, true)?.try_into() }