Merge pull request #278 from kaczmarczyck/no-cfg-derive

Remove derive_debug feature
This commit is contained in:
kaczmarczyck
2021-02-02 09:56:29 +01:00
committed by GitHub
15 changed files with 57 additions and 101 deletions

View File

@@ -33,10 +33,10 @@ jobs:
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: test command: test
args: --manifest-path libraries/crypto/Cargo.toml --release --features std,derive_debug args: --manifest-path libraries/crypto/Cargo.toml --release --features std
- name: Unit testing of crypto library (debug mode) - name: Unit testing of crypto library (debug mode)
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: test command: test
args: --manifest-path libraries/crypto/Cargo.toml --features std,derive_debug args: --manifest-path libraries/crypto/Cargo.toml --features std

View File

@@ -22,9 +22,9 @@ subtle = { version = "2.2", default-features = false, features = ["nightly"] }
[features] [features]
debug_allocations = ["lang_items/debug_allocations"] debug_allocations = ["lang_items/debug_allocations"]
debug_ctap = ["crypto/derive_debug", "libtock_drivers/debug_ctap"] debug_ctap = ["libtock_drivers/debug_ctap"]
panic_console = ["lang_items/panic_console"] panic_console = ["lang_items/panic_console"]
std = ["cbor/std", "crypto/std", "crypto/derive_debug", "lang_items/std", "persistent_store/std"] std = ["cbor/std", "crypto/std", "lang_items/std", "persistent_store/std"]
verbose = ["debug_ctap", "libtock_drivers/verbose_usb"] verbose = ["debug_ctap", "libtock_drivers/verbose_usb"]
with_ctap1 = ["crypto/with_ctap1"] with_ctap1 = ["crypto/with_ctap1"]
with_nfc = ["libtock_drivers/with_nfc"] with_nfc = ["libtock_drivers/with_nfc"]

View File

@@ -25,5 +25,4 @@ regex = { version = "1", optional = true }
[features] [features]
std = ["cbor/std", "hex", "rand", "ring", "untrusted", "serde", "serde_json", "regex"] std = ["cbor/std", "hex", "rand", "ring", "untrusted", "serde", "serde_json", "regex"]
derive_debug = []
with_ctap1 = [] with_ctap1 = []

View File

@@ -18,11 +18,10 @@ use core::ops::Mul;
use subtle::{self, Choice, ConditionallySelectable, CtOption}; use subtle::{self, Choice, ConditionallySelectable, CtOption};
// An exponent on the elliptic curve, that is an element modulo the curve order N. // An exponent on the elliptic curve, that is an element modulo the curve order N.
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
// TODO: remove this Default once https://github.com/dalek-cryptography/subtle/issues/63 is // TODO: remove this Default once https://github.com/dalek-cryptography/subtle/issues/63 is
// resolved. // resolved.
#[derive(Default)] #[derive(Default)]
#[cfg_attr(feature = "derive_debug", derive(Debug))]
pub struct ExponentP256 { pub struct ExponentP256 {
int: Int256, int: Int256,
} }
@@ -92,11 +91,10 @@ impl Mul for &ExponentP256 {
} }
// A non-zero exponent on the elliptic curve. // A non-zero exponent on the elliptic curve.
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
// TODO: remove this Default once https://github.com/dalek-cryptography/subtle/issues/63 is // TODO: remove this Default once https://github.com/dalek-cryptography/subtle/issues/63 is
// resolved. // resolved.
#[derive(Default)] #[derive(Default)]
#[cfg_attr(feature = "derive_debug", derive(Debug))]
pub struct NonZeroExponentP256 { pub struct NonZeroExponentP256 {
e: ExponentP256, e: ExponentP256,
} }

View File

@@ -111,7 +111,6 @@ impl Mul for &GFP256 {
} }
} }
#[cfg(feature = "derive_debug")]
impl core::fmt::Debug for GFP256 { impl core::fmt::Debug for GFP256 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "GFP256::{:?}", self.int) write!(f, "GFP256::{:?}", self.int)

View File

@@ -636,7 +636,6 @@ impl SubAssign<&Int256> for Int256 {
} }
} }
#[cfg(feature = "derive_debug")]
impl core::fmt::Debug for Int256 { impl core::fmt::Debug for Int256 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "Int256 {{ digits: {:08x?} }}", self.digits) write!(f, "Int256 {{ digits: {:08x?} }}", self.digits)

View File

@@ -542,7 +542,6 @@ impl Add for &PointProjective {
} }
} }
#[cfg(feature = "derive_debug")]
impl core::fmt::Debug for PointP256 { impl core::fmt::Debug for PointP256 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PointP256") f.debug_struct("PointP256")
@@ -552,7 +551,6 @@ impl core::fmt::Debug for PointP256 {
} }
} }
#[cfg(feature = "derive_debug")]
impl PartialEq for PointP256 { impl PartialEq for PointP256 {
fn eq(&self, other: &PointP256) -> bool { fn eq(&self, other: &PointP256) -> bool {
self.x == other.x && self.y == other.y self.x == other.x && self.y == other.y

View File

@@ -26,7 +26,7 @@ pub struct SecKey {
a: NonZeroExponentP256, a: NonZeroExponentP256,
} }
#[cfg_attr(feature = "derive_debug", derive(Clone, PartialEq, Debug))] #[derive(Clone, Debug, PartialEq)]
pub struct PubKey { pub struct PubKey {
p: PointP256, p: PointP256,
} }

View File

@@ -30,8 +30,7 @@ use core::marker::PhantomData;
pub const NBYTES: usize = int256::NBYTES; pub const NBYTES: usize = int256::NBYTES;
#[derive(Clone, PartialEq)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "derive_debug", derive(Debug))]
pub struct SecKey { pub struct SecKey {
k: NonZeroExponentP256, k: NonZeroExponentP256,
} }
@@ -41,7 +40,7 @@ pub struct Signature {
s: NonZeroExponentP256, s: NonZeroExponentP256,
} }
#[cfg_attr(feature = "derive_debug", derive(Clone))] #[derive(Clone)]
pub struct PubKey { pub struct PubKey {
p: PointP256, p: PointP256,
} }

View File

@@ -91,7 +91,7 @@ then
cargo test --release --features std cargo test --release --features std
cd ../.. cd ../..
cd libraries/crypto cd libraries/crypto
RUSTFLAGS='-C target-feature=+aes' cargo test --release --features std,derive_debug RUSTFLAGS='-C target-feature=+aes' cargo test --release --features std
cd ../.. cd ../..
cd libraries/persistent_store cd libraries/persistent_store
cargo test --release --features std cargo test --release --features std
@@ -103,7 +103,7 @@ then
cargo test --features std cargo test --features std
cd ../.. cd ../..
cd libraries/crypto cd libraries/crypto
RUSTFLAGS='-C target-feature=+aes' cargo test --features std,derive_debug RUSTFLAGS='-C target-feature=+aes' cargo test --features std
cd ../.. cd ../..
cd libraries/persistent_store cd libraries/persistent_store
cargo test --features std cargo test --features std

View File

@@ -18,9 +18,8 @@ use core::convert::TryFrom;
const APDU_HEADER_LEN: usize = 4; const APDU_HEADER_LEN: usize = 4;
#[cfg_attr(test, derive(Clone, Debug))] #[derive(Clone, Debug, PartialEq)]
#[allow(non_camel_case_types, dead_code)] #[allow(non_camel_case_types, dead_code)]
#[derive(PartialEq)]
pub enum ApduStatusCode { pub enum ApduStatusCode {
SW_SUCCESS = 0x90_00, SW_SUCCESS = 0x90_00,
/// Command successfully executed; 'XX' bytes of data are /// Command successfully executed; 'XX' bytes of data are
@@ -51,9 +50,8 @@ pub enum ApduInstructions {
GetResponse = 0xC0, GetResponse = 0xC0,
} }
#[cfg_attr(test, derive(Clone, Debug))] #[derive(Clone, Debug, Default, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Default, PartialEq)]
pub struct ApduHeader { pub struct ApduHeader {
pub cla: u8, pub cla: u8,
pub ins: u8, pub ins: u8,
@@ -72,8 +70,7 @@ impl From<&[u8; APDU_HEADER_LEN]> for ApduHeader {
} }
} }
#[cfg_attr(test, derive(Clone, Debug))] #[derive(Clone, Debug, PartialEq)]
#[derive(PartialEq)]
/// The APDU cases /// The APDU cases
pub enum Case { pub enum Case {
Le1, Le1,
@@ -85,18 +82,16 @@ pub enum Case {
Le3, Le3,
} }
#[cfg_attr(test, derive(Clone, Debug))] #[derive(Clone, Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
#[derive(PartialEq)]
pub enum ApduType { pub enum ApduType {
Instruction, Instruction,
Short(Case), Short(Case),
Extended(Case), Extended(Case),
} }
#[cfg_attr(test, derive(Clone, Debug))] #[derive(Clone, Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
#[derive(PartialEq)]
pub struct APDU { pub struct APDU {
pub header: ApduHeader, pub header: ApduHeader,
pub lc: u16, pub lc: u16,

View File

@@ -38,7 +38,7 @@ pub const MAX_CREDENTIAL_COUNT_IN_LIST: Option<usize> = None;
const MIN_LARGE_BLOB_LEN: usize = 17; const MIN_LARGE_BLOB_LEN: usize = 17;
// CTAP specification (version 20190130) section 6.1 // CTAP specification (version 20190130) section 6.1
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub enum Command { pub enum Command {
AuthenticatorMakeCredential(AuthenticatorMakeCredentialParameters), AuthenticatorMakeCredential(AuthenticatorMakeCredentialParameters),
AuthenticatorGetAssertion(AuthenticatorGetAssertionParameters), AuthenticatorGetAssertion(AuthenticatorGetAssertionParameters),
@@ -148,7 +148,7 @@ impl Command {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorMakeCredentialParameters { pub struct AuthenticatorMakeCredentialParameters {
pub client_data_hash: Vec<u8>, pub client_data_hash: Vec<u8>,
pub rp: PublicKeyCredentialRpEntity, pub rp: PublicKeyCredentialRpEntity,
@@ -236,7 +236,7 @@ impl TryFrom<cbor::Value> for AuthenticatorMakeCredentialParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorGetAssertionParameters { pub struct AuthenticatorGetAssertionParameters {
pub rp_id: String, pub rp_id: String,
pub client_data_hash: Vec<u8>, pub client_data_hash: Vec<u8>,
@@ -307,7 +307,7 @@ impl TryFrom<cbor::Value> for AuthenticatorGetAssertionParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorClientPinParameters { pub struct AuthenticatorClientPinParameters {
pub pin_protocol: u64, pub pin_protocol: u64,
pub sub_command: ClientPinSubCommand, pub sub_command: ClientPinSubCommand,
@@ -363,7 +363,7 @@ impl TryFrom<cbor::Value> for AuthenticatorClientPinParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorLargeBlobsParameters { pub struct AuthenticatorLargeBlobsParameters {
pub get: Option<usize>, pub get: Option<usize>,
pub set: Option<Vec<u8>>, pub set: Option<Vec<u8>>,
@@ -438,7 +438,7 @@ impl TryFrom<cbor::Value> for AuthenticatorLargeBlobsParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorConfigParameters { pub struct AuthenticatorConfigParameters {
pub sub_command: ConfigSubCommand, pub sub_command: ConfigSubCommand,
pub sub_command_params: Option<ConfigSubCommandParams>, pub sub_command_params: Option<ConfigSubCommandParams>,
@@ -478,7 +478,7 @@ impl TryFrom<cbor::Value> for AuthenticatorConfigParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorAttestationMaterial { pub struct AuthenticatorAttestationMaterial {
pub certificate: Vec<u8>, pub certificate: Vec<u8>,
pub private_key: [u8; key_material::ATTESTATION_PRIVATE_KEY_LENGTH], pub private_key: [u8; key_material::ATTESTATION_PRIVATE_KEY_LENGTH],
@@ -507,7 +507,7 @@ impl TryFrom<cbor::Value> for AuthenticatorAttestationMaterial {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorCredentialManagementParameters { pub struct AuthenticatorCredentialManagementParameters {
pub sub_command: CredentialManagementSubCommand, pub sub_command: CredentialManagementSubCommand,
pub sub_command_params: Option<CredentialManagementSubCommandParameters>, pub sub_command_params: Option<CredentialManagementSubCommandParameters>,
@@ -544,7 +544,7 @@ impl TryFrom<cbor::Value> for AuthenticatorCredentialManagementParameters {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct AuthenticatorVendorConfigureParameters { pub struct AuthenticatorVendorConfigureParameters {
pub lockdown: bool, pub lockdown: bool,
pub attestation_material: Option<AuthenticatorAttestationMaterial>, pub attestation_material: Option<AuthenticatorAttestationMaterial>,

View File

@@ -29,8 +29,7 @@ pub type Ctap1StatusCode = ApduStatusCode;
// The specification referenced in this file is at: // The specification referenced in this file is at:
// https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.pdf // https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.pdf
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Clone, Debug))] #[derive(Clone, Debug, PartialEq)]
#[derive(PartialEq)]
pub enum Ctap1Flags { pub enum Ctap1Flags {
CheckOnly = 0x07, CheckOnly = 0x07,
EnforceUpAndSign = 0x03, EnforceUpAndSign = 0x03,
@@ -56,7 +55,7 @@ impl Into<u8> for Ctap1Flags {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
// TODO: remove #allow when https://github.com/rust-lang/rust/issues/64362 is fixed // TODO: remove #allow when https://github.com/rust-lang/rust/issues/64362 is fixed
enum U2fCommand { enum U2fCommand {
#[allow(dead_code)] #[allow(dead_code)]

View File

@@ -27,8 +27,7 @@ use enum_iterator::IntoEnumIterator;
const ES256_ALGORITHM: i64 = -7; const ES256_ALGORITHM: i64 = -7;
// https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialrpentity // https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialrpentity
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct PublicKeyCredentialRpEntity { pub struct PublicKeyCredentialRpEntity {
pub rp_id: String, pub rp_id: String,
pub rp_name: Option<String>, pub rp_name: Option<String>,
@@ -70,8 +69,7 @@ impl From<PublicKeyCredentialRpEntity> for cbor::Value {
} }
// https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialuserentity // https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialuserentity
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct PublicKeyCredentialUserEntity { pub struct PublicKeyCredentialUserEntity {
pub user_id: Vec<u8>, pub user_id: Vec<u8>,
pub user_name: Option<String>, pub user_name: Option<String>,
@@ -118,8 +116,7 @@ impl From<PublicKeyCredentialUserEntity> for cbor::Value {
} }
// https://www.w3.org/TR/webauthn/#enumdef-publickeycredentialtype // https://www.w3.org/TR/webauthn/#enumdef-publickeycredentialtype
#[derive(Clone, PartialEq)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub enum PublicKeyCredentialType { pub enum PublicKeyCredentialType {
PublicKey, PublicKey,
// This is the default for all strings not covered above. // This is the default for all strings not covered above.
@@ -151,8 +148,7 @@ impl TryFrom<cbor::Value> for PublicKeyCredentialType {
} }
// https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialparameters // https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialparameters
#[derive(PartialEq)] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct PublicKeyCredentialParameter { pub struct PublicKeyCredentialParameter {
pub cred_type: PublicKeyCredentialType, pub cred_type: PublicKeyCredentialType,
pub alg: SignatureAlgorithm, pub alg: SignatureAlgorithm,
@@ -185,8 +181,7 @@ impl From<PublicKeyCredentialParameter> for cbor::Value {
} }
// https://www.w3.org/TR/webauthn/#enumdef-authenticatortransport // https://www.w3.org/TR/webauthn/#enumdef-authenticatortransport
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
#[cfg_attr(test, derive(IntoEnumIterator))] #[cfg_attr(test, derive(IntoEnumIterator))]
pub enum AuthenticatorTransport { pub enum AuthenticatorTransport {
Usb, Usb,
@@ -223,8 +218,7 @@ impl TryFrom<cbor::Value> for AuthenticatorTransport {
} }
// https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialdescriptor // https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialdescriptor
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct PublicKeyCredentialDescriptor { pub struct PublicKeyCredentialDescriptor {
pub key_type: PublicKeyCredentialType, pub key_type: PublicKeyCredentialType,
pub key_id: Vec<u8>, pub key_id: Vec<u8>,
@@ -275,8 +269,7 @@ impl From<PublicKeyCredentialDescriptor> for cbor::Value {
} }
} }
#[derive(Default)] #[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Clone, Debug, PartialEq))]
pub struct MakeCredentialExtensions { pub struct MakeCredentialExtensions {
pub hmac_secret: bool, pub hmac_secret: bool,
pub cred_protect: Option<CredentialProtectionPolicy>, pub cred_protect: Option<CredentialProtectionPolicy>,
@@ -321,8 +314,7 @@ impl TryFrom<cbor::Value> for MakeCredentialExtensions {
} }
} }
#[derive(Clone, Default)] #[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct GetAssertionExtensions { pub struct GetAssertionExtensions {
pub hmac_secret: Option<GetAssertionHmacSecretInput>, pub hmac_secret: Option<GetAssertionHmacSecretInput>,
pub cred_blob: bool, pub cred_blob: bool,
@@ -359,8 +351,7 @@ impl TryFrom<cbor::Value> for GetAssertionExtensions {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct GetAssertionHmacSecretInput { pub struct GetAssertionHmacSecretInput {
pub key_agreement: CoseKey, pub key_agreement: CoseKey,
pub salt_enc: Vec<u8>, pub salt_enc: Vec<u8>,
@@ -391,8 +382,7 @@ impl TryFrom<cbor::Value> for GetAssertionHmacSecretInput {
} }
// Even though options are optional, we can use the default if not present. // Even though options are optional, we can use the default if not present.
#[derive(Default)] #[derive(Debug, Default, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct MakeCredentialOptions { pub struct MakeCredentialOptions {
pub rk: bool, pub rk: bool,
pub uv: bool, pub uv: bool,
@@ -425,7 +415,7 @@ impl TryFrom<cbor::Value> for MakeCredentialOptions {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))] #[derive(Debug, PartialEq)]
pub struct GetAssertionOptions { pub struct GetAssertionOptions {
pub up: bool, pub up: bool,
pub uv: bool, pub uv: bool,
@@ -470,8 +460,7 @@ impl TryFrom<cbor::Value> for GetAssertionOptions {
} }
// https://www.w3.org/TR/webauthn/#packed-attestation // https://www.w3.org/TR/webauthn/#packed-attestation
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct PackedAttestationStatement { pub struct PackedAttestationStatement {
pub alg: i64, pub alg: i64,
pub sig: Vec<u8>, pub sig: Vec<u8>,
@@ -490,8 +479,7 @@ impl From<PackedAttestationStatement> for cbor::Value {
} }
} }
#[derive(PartialEq)] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub enum SignatureAlgorithm { pub enum SignatureAlgorithm {
ES256 = ES256_ALGORITHM as isize, ES256 = ES256_ALGORITHM as isize,
// This is the default for all numbers not covered above. // This is the default for all numbers not covered above.
@@ -516,8 +504,7 @@ impl TryFrom<cbor::Value> for SignatureAlgorithm {
} }
} }
#[derive(Clone, Copy, PartialEq, PartialOrd)] #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
#[cfg_attr(test, derive(IntoEnumIterator))] #[cfg_attr(test, derive(IntoEnumIterator))]
pub enum CredentialProtectionPolicy { pub enum CredentialProtectionPolicy {
UserVerificationOptional = 0x01, UserVerificationOptional = 0x01,
@@ -548,9 +535,7 @@ impl TryFrom<cbor::Value> for CredentialProtectionPolicy {
// //
// Note that we only use the WebAuthn definition as an example. This data-structure is not specified // Note that we only use the WebAuthn definition as an example. This data-structure is not specified
// by FIDO. In particular we may choose how we serialize and deserialize it. // by FIDO. In particular we may choose how we serialize and deserialize it.
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct PublicKeyCredentialSource { pub struct PublicKeyCredentialSource {
// TODO function to convert to / from Vec<u8> // TODO function to convert to / from Vec<u8>
pub key_type: PublicKeyCredentialType, pub key_type: PublicKeyCredentialType,
@@ -688,8 +673,7 @@ impl PublicKeyCredentialSource {
} }
// The COSE key is used for both ECDH and ECDSA public keys for transmission. // The COSE key is used for both ECDH and ECDSA public keys for transmission.
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct CoseKey { pub struct CoseKey {
x_bytes: [u8; ecdh::NBYTES], x_bytes: [u8; ecdh::NBYTES],
y_bytes: [u8; ecdh::NBYTES], y_bytes: [u8; ecdh::NBYTES],
@@ -818,7 +802,7 @@ impl TryFrom<CoseKey> for ecdh::PubKey {
} }
} }
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Clone, Debug, PartialEq))] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(test, derive(IntoEnumIterator))] #[cfg_attr(test, derive(IntoEnumIterator))]
pub enum ClientPinSubCommand { pub enum ClientPinSubCommand {
GetPinRetries = 0x01, GetPinRetries = 0x01,
@@ -856,8 +840,7 @@ impl TryFrom<cbor::Value> for ClientPinSubCommand {
} }
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
#[cfg_attr(test, derive(IntoEnumIterator))] #[cfg_attr(test, derive(IntoEnumIterator))]
pub enum ConfigSubCommand { pub enum ConfigSubCommand {
EnableEnterpriseAttestation = 0x01, EnableEnterpriseAttestation = 0x01,
@@ -887,8 +870,7 @@ impl TryFrom<cbor::Value> for ConfigSubCommand {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub enum ConfigSubCommandParams { pub enum ConfigSubCommandParams {
SetMinPinLength(SetMinPinLengthParams), SetMinPinLength(SetMinPinLengthParams),
} }
@@ -903,8 +885,7 @@ impl From<ConfigSubCommandParams> for cbor::Value {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct SetMinPinLengthParams { pub struct SetMinPinLengthParams {
pub new_min_pin_length: Option<u8>, pub new_min_pin_length: Option<u8>,
pub min_pin_length_rp_ids: Option<Vec<String>>, pub min_pin_length_rp_ids: Option<Vec<String>>,
@@ -958,8 +939,7 @@ impl From<SetMinPinLengthParams> for cbor::Value {
} }
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
#[cfg_attr(test, derive(IntoEnumIterator))] #[cfg_attr(test, derive(IntoEnumIterator))]
pub enum CredentialManagementSubCommand { pub enum CredentialManagementSubCommand {
GetCredsMetadata = 0x01, GetCredsMetadata = 0x01,
@@ -995,8 +975,7 @@ impl TryFrom<cbor::Value> for CredentialManagementSubCommand {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug, PartialEq))]
pub struct CredentialManagementSubCommandParameters { pub struct CredentialManagementSubCommandParameters {
pub rp_id_hash: Option<Vec<u8>>, pub rp_id_hash: Option<Vec<u8>>,
pub credential_id: Option<PublicKeyCredentialDescriptor>, pub credential_id: Option<PublicKeyCredentialDescriptor>,

View File

@@ -22,8 +22,7 @@ use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use cbor::{cbor_array_vec, cbor_bool, cbor_map_btree, cbor_map_options, cbor_text}; use cbor::{cbor_array_vec, cbor_bool, cbor_map_btree, cbor_map_options, cbor_text};
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub enum ResponseData { pub enum ResponseData {
AuthenticatorMakeCredential(AuthenticatorMakeCredentialResponse), AuthenticatorMakeCredential(AuthenticatorMakeCredentialResponse),
AuthenticatorGetAssertion(AuthenticatorGetAssertionResponse), AuthenticatorGetAssertion(AuthenticatorGetAssertionResponse),
@@ -57,8 +56,7 @@ impl From<ResponseData> for Option<cbor::Value> {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorMakeCredentialResponse { pub struct AuthenticatorMakeCredentialResponse {
pub fmt: String, pub fmt: String,
pub auth_data: Vec<u8>, pub auth_data: Vec<u8>,
@@ -84,8 +82,7 @@ impl From<AuthenticatorMakeCredentialResponse> for cbor::Value {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorGetAssertionResponse { pub struct AuthenticatorGetAssertionResponse {
pub credential: Option<PublicKeyCredentialDescriptor>, pub credential: Option<PublicKeyCredentialDescriptor>,
pub auth_data: Vec<u8>, pub auth_data: Vec<u8>,
@@ -117,8 +114,7 @@ impl From<AuthenticatorGetAssertionResponse> for cbor::Value {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorGetInfoResponse { pub struct AuthenticatorGetInfoResponse {
pub versions: Vec<String>, pub versions: Vec<String>,
pub extensions: Option<Vec<String>>, pub extensions: Option<Vec<String>>,
@@ -191,8 +187,7 @@ impl From<AuthenticatorGetInfoResponse> for cbor::Value {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorClientPinResponse { pub struct AuthenticatorClientPinResponse {
pub key_agreement: Option<CoseKey>, pub key_agreement: Option<CoseKey>,
pub pin_token: Option<Vec<u8>>, pub pin_token: Option<Vec<u8>>,
@@ -215,8 +210,7 @@ impl From<AuthenticatorClientPinResponse> for cbor::Value {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorLargeBlobsResponse { pub struct AuthenticatorLargeBlobsResponse {
pub config: Vec<u8>, pub config: Vec<u8>,
} }
@@ -231,9 +225,7 @@ impl From<AuthenticatorLargeBlobsResponse> for cbor::Value {
} }
} }
#[derive(Default)] #[derive(Debug, Default, PartialEq)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorCredentialManagementResponse { pub struct AuthenticatorCredentialManagementResponse {
pub existing_resident_credentials_count: Option<u64>, pub existing_resident_credentials_count: Option<u64>,
pub max_possible_remaining_resident_credentials_count: Option<u64>, pub max_possible_remaining_resident_credentials_count: Option<u64>,
@@ -280,8 +272,7 @@ impl From<AuthenticatorCredentialManagementResponse> for cbor::Value {
} }
} }
#[cfg_attr(test, derive(PartialEq))] #[derive(Debug, PartialEq)]
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
pub struct AuthenticatorVendorResponse { pub struct AuthenticatorVendorResponse {
pub cert_programmed: bool, pub cert_programmed: bool,
pub pkey_programmed: bool, pub pkey_programmed: bool,