Remove cardholder_certificate from the public CardClient API, for now (until we learn of actual use cases for this part of the spec).

This commit is contained in:
Heiko Schaefer 2022-02-15 16:07:05 +01:00
parent 574d7be765
commit 889eedbb79
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
2 changed files with 61 additions and 60 deletions

View file

@ -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<TestOutput, TestError> {
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<TestOutput, TestError> {
// 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),

View file

@ -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<Response, Error> {
#[allow(dead_code)]
fn cardholder_certificate(&mut self) -> Result<Response, Error> {
let cmd = commands::cardholder_certificate();
apdu::send_command(self, cmd, true)?.try_into()
}