From 536bcf788bf1fce603750541cd8674a14f9d69bb Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Tue, 5 Sep 2023 14:58:28 +0200 Subject: [PATCH] openpgp-card: ExtendedCapabilities, add getters for capabilities --- openpgp-card/src/card_do/extended_cap.rs | 78 +++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/openpgp-card/src/card_do/extended_cap.rs b/openpgp-card/src/card_do/extended_cap.rs index d5a4c9a..cb4510c 100644 --- a/openpgp-card/src/card_do/extended_cap.rs +++ b/openpgp-card/src/card_do/extended_cap.rs @@ -9,12 +9,86 @@ use crate::card_do::ExtendedCapabilities; use crate::Error; impl ExtendedCapabilities { + /// Secure Messaging supported. + /// + /// (This feature is currently only available in the SmartPGP implementation) + pub fn secure_messaging(&self) -> bool { + self.secure_messaging + } + + /// Support for GET CHALLENGE. + /// + /// (GET CHALLENGE generates a random number of a specified length on the smart card) + pub fn get_challenge(&self) -> bool { + self.get_challenge + } + + /// Maximum length of random number that can be requested from the card + /// (if GET CHALLENGE is supported). + /// + /// If GET CHALLENGE is not supported, the coding is 0 + pub fn max_len_challenge(&self) -> u16 { + self.max_len_challenge + } + + /// Support for Key Import + pub fn key_import(&self) -> bool { + self.key_import + } + + /// PW Status changeable + /// (also see [`crate::card_do::PWStatusBytes`]) + pub fn pw_status_change(&self) -> bool { + self.pw_status_change + } + + /// Support for Private use DOs + pub fn private_use_dos(&self) -> bool { + self.private_use_dos + } + + /// Algorithm attributes changeable + /// (also see [`crate::algorithm::AlgorithmAttributes`]) + pub fn algo_attrs_changeable(&self) -> bool { + self.algo_attrs_changeable + } + + /// Support for encryption/decryption with AES + pub fn aes(&self) -> bool { + self.aes + } + + /// KDF-related functionality available + pub fn kdf_do(&self) -> bool { + self.kdf_do + } + + /// Maximum length of Cardholder Certificates + pub fn max_len_cardholder_cert(&self) -> u16 { + self.max_len_cardholder_cert + } + + /// Maximum length of "special DOs" + /// (Private Use, Login data, URL, Algorithm attributes, KDF etc.) + /// + /// (OpenPGP card version 3.x only) pub fn max_len_special_do(&self) -> Option { self.max_len_special_do } - pub fn algo_attrs_changeable(&self) -> bool { - self.algo_attrs_changeable + /// (Private Use, Login data, URL, Algorithm attributes, KDF etc.) + /// + /// (OpenPGP card version 3.x only) + pub fn pin_block_2_format_support(&self) -> Option { + self.pin_block_2_format_support + } + + /// MANAGE SECURITY ENVIRONMENT supported (for DEC and AUT keys). + /// (See [`crate::Transaction::manage_security_environment`]) + /// + /// (OpenPGP card version 3.x only) + pub fn mse_command_support(&self) -> Option { + self.mse_command_support } /// Only available in OpenPGP card version 2.x