Rename get_app_data() to get_application_related_data() to correspond with naming in spec.

This commit is contained in:
Heiko Schaefer 2021-09-02 22:09:46 +02:00
parent f5b31aac26
commit 8b5894e961
9 changed files with 22 additions and 20 deletions

View file

@ -101,7 +101,7 @@ impl TestCard {
let mut ca = CardApp::from(card_client); let mut ca = CardApp::from(card_client);
// Set Card Capabilities (chaining, command length, ..) // Set Card Capabilities (chaining, command length, ..)
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let app_id = ard.get_application_id()?; let app_id = ard.get_application_id()?;
if app_id.ident().as_str() == ident { if app_id.ident().as_str() == ident {
@ -120,7 +120,7 @@ impl TestCard {
let mut ca = CardApp::from(card_client); let mut ca = CardApp::from(card_client);
// Set Card Capabilities (chaining, command length, ..) // Set Card Capabilities (chaining, command length, ..)
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
ca.init_caps(&ard)?; ca.init_caps(&ard)?;
// println!("opened scdc card {}", serial); // println!("opened scdc card {}", serial);

View file

@ -96,7 +96,7 @@ fn check_key_upload_metadata(
ca: &mut CardApp, ca: &mut CardApp,
meta: &[(String, KeyGenerationTime)], meta: &[(String, KeyGenerationTime)],
) -> Result<()> { ) -> Result<()> {
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
// check fingerprints // check fingerprints
let card_fp = ard.get_fingerprints()?; let card_fp = ard.get_fingerprints()?;
@ -140,7 +140,7 @@ pub fn test_print_caps(
ca: &mut CardApp, ca: &mut CardApp,
_param: &[&str], _param: &[&str],
) -> Result<TestOutput, TestError> { ) -> Result<TestOutput, TestError> {
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let aid = ard.get_application_id()?; let aid = ard.get_application_id()?;
println!("aid: {:#x?}", aid); println!("aid: {:#x?}", aid);
@ -161,7 +161,7 @@ pub fn test_print_algo_info(
ca: &mut CardApp, ca: &mut CardApp,
_param: &[&str], _param: &[&str],
) -> Result<TestOutput, TestError> { ) -> Result<TestOutput, TestError> {
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let dec = ard.get_algorithm_attributes(KeyType::Decryption)?; let dec = ard.get_algorithm_attributes(KeyType::Decryption)?;
println!("Current algorithm for the decrypt slot: {}", dec); println!("Current algorithm for the decrypt slot: {}", dec);
@ -250,7 +250,7 @@ pub fn test_get_pub(
ca: &mut CardApp, ca: &mut CardApp,
_param: &[&str], _param: &[&str],
) -> Result<TestOutput, TestError> { ) -> Result<TestOutput, TestError> {
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let key_gen = ard.get_key_generation_times()?; let key_gen = ard.get_key_generation_times()?;
// -- // --
@ -442,7 +442,7 @@ pub fn test_pw_status(
) -> Result<TestOutput, TestError> { ) -> Result<TestOutput, TestError> {
let mut out = vec![]; let mut out = vec![];
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let mut pws = ard.get_pw_status_bytes()?; let mut pws = ard.get_pw_status_bytes()?;
println!("pws {:?}", pws); println!("pws {:?}", pws);
@ -454,7 +454,7 @@ pub fn test_pw_status(
ca.set_pw_status_bytes(&pws, false)?; ca.set_pw_status_bytes(&pws, false)?;
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let pws = ard.get_pw_status_bytes()?; let pws = ard.get_pw_status_bytes()?;
println!("pws {:?}", pws); println!("pws {:?}", pws);
@ -536,7 +536,7 @@ pub fn run_test(
param: &[&str], param: &[&str],
) -> Result<TestOutput, TestError> { ) -> Result<TestOutput, TestError> {
let mut ca = card.get_card_app()?; let mut ca = card.get_card_app()?;
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let _app_id = ard.get_application_id()?; let _app_id = ard.get_application_id()?;
t(&mut ca, param) t(&mut ca, param)

View file

@ -39,7 +39,7 @@ impl<'a> CardDecryptor<'a> {
policy: &dyn Policy, policy: &dyn Policy,
) -> Result<CardDecryptor<'a>, Error> { ) -> Result<CardDecryptor<'a>, Error> {
// Get the fingerprint for the decryption key from the card. // Get the fingerprint for the decryption key from the card.
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let fps = ard.get_fingerprints()?; let fps = ard.get_fingerprints()?;
let fp = fps.decryption(); let fp = fps.decryption();

View file

@ -583,7 +583,7 @@ impl CardBase {
// read and cache "application related data" // read and cache "application related data"
let mut card_app = CardApp::from(ccb); let mut card_app = CardApp::from(ccb);
let ard = card_app.get_app_data()?; let ard = card_app.get_application_related_data()?;
card_app.init_caps(&ard)?; card_app.init_caps(&ard)?;
@ -597,7 +597,7 @@ impl CardBase {
/// This is done once, after opening the OpenPGP card applet /// This is done once, after opening the OpenPGP card applet
/// (the data is stored in the OpenPGPCard object). /// (the data is stored in the OpenPGPCard object).
fn get_app_data(&mut self) -> Result<ApplicationRelatedData> { fn get_app_data(&mut self) -> Result<ApplicationRelatedData> {
self.card_app.get_app_data() self.card_app.get_application_related_data()
} }
pub fn get_application_id(&self) -> Result<ApplicationIdentifier, Error> { pub fn get_application_id(&self) -> Result<ApplicationIdentifier, Error> {

View file

@ -242,7 +242,7 @@ fn main() -> Result<(), Box<dyn Error>> {
for c in cards { for c in cards {
let mut ca = CardApp::from(c); let mut ca = CardApp::from(c);
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let app_id = ard.get_application_id()?; let app_id = ard.get_application_id()?;
let ident = app_id.ident(); let ident = app_id.ident();

View file

@ -34,7 +34,7 @@ impl<'a> CardSigner<'a> {
policy: &dyn Policy, policy: &dyn Policy,
) -> Result<CardSigner<'a>, Error> { ) -> Result<CardSigner<'a>, Error> {
// Get the fingerprint for the signing key from the card. // Get the fingerprint for the signing key from the card.
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let fps = ard.get_fingerprints()?; let fps = ard.get_fingerprints()?;
let fp = fps.signature(); let fp = fps.signature();

View file

@ -105,7 +105,9 @@ impl CardApp {
/// (This data should probably be cached in a higher layer. Some parts of /// (This data should probably be cached in a higher layer. Some parts of
/// it are needed regularly, and it does not usually change during /// it are needed regularly, and it does not usually change during
/// normal use of a card.) /// normal use of a card.)
pub fn get_app_data(&mut self) -> Result<ApplicationRelatedData> { pub fn get_application_related_data(
&mut self,
) -> Result<ApplicationRelatedData> {
let ad = commands::get_application_data(); let ad = commands::get_application_data();
let resp = apdu::send_command(&mut self.card_client, ad, true)?; let resp = apdu::send_command(&mut self.card_client, ad, true)?;
let value = Value::from(resp.data()?, true)?; let value = Value::from(resp.data()?, true)?;
@ -577,7 +579,7 @@ impl CardApp {
algo: &Algo, algo: &Algo,
) -> Result<Response, Error> { ) -> Result<Response, Error> {
// FIXME: caching? // FIXME: caching?
let ard = self.get_app_data()?; let ard = self.get_application_related_data()?;
// FIXME: Only write algo attributes to the card if "extended // FIXME: Only write algo attributes to the card if "extended
// capabilities" show that they are changeable! // capabilities" show that they are changeable!

View file

@ -46,7 +46,7 @@ pub(crate) fn gen_key_with_metadata(
} }
// algo // algo
let ard = card_app.get_app_data()?; // no caching, here! let ard = card_app.get_application_related_data()?; // no caching, here!
let algo = ard.get_algorithm_attributes(key_type)?; let algo = ard.get_algorithm_attributes(key_type)?;
// generate key // generate key
@ -137,7 +137,7 @@ pub(crate) fn get_pub_key(
key_type: KeyType, key_type: KeyType,
) -> Result<PublicKeyMaterial, Error> { ) -> Result<PublicKeyMaterial, Error> {
// algo // algo
let ard = card_app.get_app_data()?; // FIXME: caching let ard = card_app.get_application_related_data()?; // FIXME: caching
let algo = ard.get_algorithm_attributes(key_type)?; let algo = ard.get_algorithm_attributes(key_type)?;
// get public key // get public key
@ -181,7 +181,7 @@ pub(crate) fn key_import(
// No -> Get the current algorithm attributes for key_type. // No -> Get the current algorithm attributes for key_type.
// FIXME: caching? // FIXME: caching?
let ard = card_app.get_app_data()?; let ard = card_app.get_application_related_data()?;
let algo = ard.get_algorithm_attributes(key_type)?; let algo = ard.get_algorithm_attributes(key_type)?;
// Is the algorithm on the card currently set to RSA? // Is the algorithm on the card currently set to RSA?

View file

@ -128,7 +128,7 @@ impl PcscClient {
mut ca: CardApp, mut ca: CardApp,
ident: &str, ident: &str,
) -> Result<Option<CardClientBox>, Error> { ) -> Result<Option<CardClientBox>, Error> {
let ard = ca.get_app_data()?; let ard = ca.get_application_related_data()?;
let aid = ard.get_application_id()?; let aid = ard.get_application_id()?;
if aid.ident() == ident { if aid.ident() == ident {