@ -1,15 +1,18 @@
use crate ::authenticator ::client_pin ::AuthProtocolVersion ;
use crate ::authenticator ::client_pin ::auth_protocol ;
use crate ::authenticator ::Transport ;
use crate ::authenticator ::Transport ;
use crate ::extensions ;
use crate ::extensions ;
use bounded_vec ::BoundedVec ;
use fido_common ::credential ::public_key ;
use fido_common ::credential ::public_key ;
use fido_common ::registry ;
use fido_common ::{ attestation , registry } ;
use std ::collections ::{ BTreeMap , BTreeSet } ;
use std ::collections ::{ BTreeMap , BTreeSet } ;
use std ::num ::NonZeroUsize ;
use std ::num ::NonZeroUsize ;
use std ::usize ;
use std ::usize ;
#[ cfg(feature = " serde " ) ]
use serde ::{ Deserialize , Serialize } ;
/// A usize with a minimum value of N
/// A usize with a minimum value of N
#[ derive(PartialEq, Eq) ]
#[ derive(Debug, PartialEq, Eq) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
pub struct UsizeN < const N : usize > ( bounded_integer ::BoundedUsize < N , { usize ::MAX } > ) ;
pub struct UsizeN < const N : usize > ( bounded_integer ::BoundedUsize < N , { usize ::MAX } > ) ;
/// > data type byte string and identifying the authenticator model, i.e.
/// > data type byte string and identifying the authenticator model, i.e.
@ -18,10 +21,15 @@ pub struct UsizeN<const N: usize>(bounded_integer::BoundedUsize<N, { usize::MAX
pub type Aaguid = [ u8 ; 16 ] ;
pub type Aaguid = [ u8 ; 16 ] ;
#[ derive(Debug, Hash, PartialEq, Eq, Clone, Copy, PartialOrd, Ord) ]
#[ derive(Debug, Hash, PartialEq, Eq, Clone, Copy, PartialOrd, Ord) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
pub enum Version {
pub enum Version {
#[ cfg_attr(feature = " serde " , serde(rename = " FIDO_2_1 " )) ]
Fido2_1 ,
Fido2_1 ,
#[ cfg_attr(feature = " serde " , serde(rename = " FIDO_2_0 " )) ]
Fido2_0 ,
Fido2_0 ,
#[ cfg_attr(feature = " serde " , serde(rename = " FIDO_2_1_PRE " )) ]
Fido2_1Preview ,
Fido2_1Preview ,
#[ cfg_attr(feature = " serde " , serde(rename = " U2F_V2 " )) ]
U2fV2 ,
U2fV2 ,
}
}
@ -32,6 +40,8 @@ pub enum Version {
/// > `AAGUID` via appropriate methods. Platforms may alter their behaviour
/// > `AAGUID` via appropriate methods. Platforms may alter their behaviour
/// > based on these hints such as selecting a PIN protocol or `credProtect`
/// > based on these hints such as selecting a PIN protocol or `credProtect`
/// > level.
/// > level.
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum Certification {
pub enum Certification {
/// > The [FIPS140-2] Cryptographic-Module-Validation-Program overall
/// > The [FIPS140-2] Cryptographic-Module-Validation-Program overall
/// > certification level.
/// > certification level.
@ -44,6 +54,8 @@ pub enum Certification {
}
}
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum FipsCryptoValidation2Level {
pub enum FipsCryptoValidation2Level {
Level1 = 1 ,
Level1 = 1 ,
Level2 = 2 ,
Level2 = 2 ,
@ -52,6 +64,8 @@ pub enum FipsCryptoValidation2Level {
}
}
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum FipsCryptoValidation3Level {
pub enum FipsCryptoValidation3Level {
Level1 = 1 ,
Level1 = 1 ,
Level2 = 2 ,
Level2 = 2 ,
@ -60,6 +74,8 @@ pub enum FipsCryptoValidation3Level {
}
}
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum FipsPhysicalCryptoValidation2Level {
pub enum FipsPhysicalCryptoValidation2Level {
Level1 = 1 ,
Level1 = 1 ,
Level2 = 2 ,
Level2 = 2 ,
@ -68,6 +84,8 @@ pub enum FipsPhysicalCryptoValidation2Level {
}
}
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum FipsPhysicalCryptoValidation3Level {
pub enum FipsPhysicalCryptoValidation3Level {
Level1 = 1 ,
Level1 = 1 ,
Level2 = 2 ,
Level2 = 2 ,
@ -78,6 +96,8 @@ pub enum FipsPhysicalCryptoValidation3Level {
/// > Common Criteria Evaluation Assurance Level [CC1V3-1R5]. This is a integer
/// > Common Criteria Evaluation Assurance Level [CC1V3-1R5]. This is a integer
/// > from 1 to 7. The intermediate-plus levels are not represented.
/// > from 1 to 7. The intermediate-plus levels are not represented.
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum CommonCriterialLevel {
pub enum CommonCriterialLevel {
EAL1 = 1 ,
EAL1 = 1 ,
EAL2 = 2 ,
EAL2 = 2 ,
@ -92,6 +112,8 @@ pub enum CommonCriterialLevel {
/// > numbered levels are mapped to the odd numbers, with the plus levels mapped
/// > numbered levels are mapped to the odd numbers, with the plus levels mapped
/// > to the even numbers e.g., level 3+ is mapped to 6.
/// > to the even numbers e.g., level 3+ is mapped to 6.
#[ repr(usize) ]
#[ repr(usize) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug, PartialEq, Eq, PartialOrd, Ord) ]
pub enum FidoLevel {
pub enum FidoLevel {
L1 = 1 ,
L1 = 1 ,
L1Plus = 2 ,
L1Plus = 2 ,
@ -103,13 +125,16 @@ pub enum FidoLevel {
/// These options describe properties of a CTAP device.
/// These options describe properties of a CTAP device.
#[ derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash) ]
#[ derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash) ]
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
pub enum OptionId {
pub enum OptionId {
/// > Indicates that the device is attached to the client and therefore
/// > Indicates that the device is attached to the client and therefore
/// > can’ t be removed and used on another client.
/// > can’ t be removed and used on another client.
#[ cfg_attr(feature = " serde " , serde(rename = " plat " )) ]
PlatformDevice ,
PlatformDevice ,
/// > Specifies whether this authenticator can create discoverable
/// > Specifies whether this authenticator can create discoverable
/// > credentials, and therefore can satisfy `authenticatorGetAssertion`
/// > credentials, and therefore can satisfy `authenticatorGetAssertion`
/// > requests with the `allowList` parameter omitted.
/// > requests with the `allowList` parameter omitted.
#[ cfg_attr(feature = " serde " , serde(rename = " rk " )) ]
DiscoverableCredentials ,
DiscoverableCredentials ,
/// > ClientPIN feature support:
/// > ClientPIN feature support:
/// > If present and set to true, it indicates that the device is capable of
/// > If present and set to true, it indicates that the device is capable of
@ -120,8 +145,10 @@ pub enum OptionId {
/// >
/// >
/// > If absent, it indicates that the device is not capable of accepting a
/// > If absent, it indicates that the device is not capable of accepting a
/// > PIN from the client.
/// > PIN from the client.
#[ cfg_attr(feature = " serde " , serde(rename = " clientPin " )) ]
ClientPin ,
ClientPin ,
/// > Indicates that the device is capable of testing user presence.
/// > Indicates that the device is capable of testing user presence.
#[ cfg_attr(feature = " serde " , serde(rename = " up " )) ]
UserPresence ,
UserPresence ,
/// > Indicates that the authenticator supports a built-in user verification
/// > Indicates that the authenticator supports a built-in user verification
/// > method. For example, devices with UI, biometrics fall into this
/// > method. For example, devices with UI, biometrics fall into this
@ -146,7 +173,9 @@ pub enum OptionId {
/// > If a device is capable of both built-in user verification and Client
/// > If a device is capable of both built-in user verification and Client
/// > PIN, the authenticator will return both the "uv" and the "clientPin"
/// > PIN, the authenticator will return both the "uv" and the "clientPin"
/// > option ids.
/// > option ids.
#[ cfg_attr(feature = " serde " , serde(rename = " uv " )) ]
UserVerification ,
UserVerification ,
#[ cfg_attr(feature = " serde " , serde(rename = " pinUvAuthToken " )) ]
PinUvAuthToken ,
PinUvAuthToken ,
/// > If this noMcGaPermissionsWithClientPin is:
/// > If this noMcGaPermissionsWithClientPin is:
/// > - present and set to true: A `pinUvAuthToken` obtained via
/// > - present and set to true: A `pinUvAuthToken` obtained via
@ -164,17 +193,31 @@ pub enum OptionId {
/// >
/// >
/// > Note: `noMcGaPermissionsWithClientPin` MUST only be present if the
/// > Note: `noMcGaPermissionsWithClientPin` MUST only be present if the
/// > `clientPin` option ID is present.
/// > `clientPin` option ID is present.
#[ cfg_attr(feature = " serde " , serde(rename = " noMcGaPermissionsWithClientPin " )) ]
NoMcGaPermissionsWithClientPin ,
NoMcGaPermissionsWithClientPin ,
#[ cfg_attr(feature = " serde " , serde(rename = " largeBlobs " )) ]
LargeBlobs ,
LargeBlobs ,
#[ cfg_attr(feature = " serde " , serde(rename = " ep " )) ]
EnterpriseAttestation ,
EnterpriseAttestation ,
#[ cfg_attr(feature = " serde " , serde(rename = " bioEnroll " )) ]
BiometricEnroll ,
BiometricEnroll ,
#[ cfg_attr(feature = " serde " , serde(rename = " userVerificationMgmtPreview " )) ]
UvManagementPreview ,
UvManagementPreview ,
#[ cfg_attr(feature = " serde " , serde(rename = " uvBioEnroll " )) ]
UvBiometricEnroll ,
UvBiometricEnroll ,
#[ cfg_attr(feature = " serde " , serde(rename = " authnrCfg " )) ]
AuthenticatorConfig ,
AuthenticatorConfig ,
#[ cfg_attr(feature = " serde " , serde(rename = " uvAcfg " )) ]
UvAuthenticatorConfig ,
UvAuthenticatorConfig ,
#[ cfg_attr(feature = " serde " , serde(rename = " credMgmt " )) ]
CredentialManagement ,
CredentialManagement ,
#[ cfg_attr(feature = " serde " , serde(rename = " credentialMgmtPreview " )) ]
CredentialManagementPreview ,
#[ cfg_attr(feature = " serde " , serde(rename = " setMinPINLength " )) ]
SetMinPinLength ,
SetMinPinLength ,
#[ cfg_attr(feature = " serde " , serde(rename = " makeCredUvNotRqd " )) ]
MakeCredentialUvNotRequired ,
MakeCredentialUvNotRequired ,
#[ cfg_attr(feature = " serde " , serde(rename = " alwaysUv " )) ]
AlwaysRequireUv ,
AlwaysRequireUv ,
}
}
@ -182,53 +225,72 @@ pub enum OptionId {
/// > list of its supported protocol versions and extensions, its AAGUID, and
/// > list of its supported protocol versions and extensions, its AAGUID, and
/// > other aspects of its overall capabilities. Platforms should use this
/// > other aspects of its overall capabilities. Platforms should use this
/// > information to tailor their command parameters choices.
/// > information to tailor their command parameters choices.
#[ cfg_attr(feature = " serde " , derive(Serialize, Deserialize)) ]
#[ derive(Debug) ]
pub struct Info {
pub struct Info {
/// > List of supported CTAP versions.
/// > List of supported CTAP versions.
#[ cfg_attr(feature = " serde " , serde(rename = 0x01)) ]
pub versions : BTreeSet < Version > ,
pub versions : BTreeSet < Version > ,
/// > List of supported extensions.
/// > List of supported extensions.
#[ cfg_attr(feature = " serde " , serde(rename = 0x02)) ]
pub extensions : Option < BTreeSet < extensions ::Identifier > > ,
pub extensions : Option < BTreeSet < extensions ::Identifier > > ,
/// > The claimed AAGUID.
/// > The claimed AAGUID.
#[ cfg_attr(feature = " serde " , serde(rename = 0x03)) ]
pub aaguid : Aaguid ,
pub aaguid : Aaguid ,
/// > List of supported options.
/// > List of supported options.
#[ cfg_attr(feature = " serde " , serde(rename = 0x04)) ]
pub options : Option < BTreeMap < OptionId , bool > > ,
pub options : Option < BTreeMap < OptionId , bool > > ,
/// > Maximum message size supported by the authenticator.
/// > Maximum message size supported by the authenticator.
#[ cfg_attr(feature = " serde " , serde(rename = 0x05)) ]
pub max_message_size : Option < usize > ,
pub max_message_size : Option < usize > ,
/// > List of supported PIN/UV auth protocols in order of decreasing
/// > List of supported PIN/UV auth protocols in order of decreasing
/// > authenticator preference. MUST NOT contain duplicate values...
/// > authenticator preference. MUST NOT contain duplicate values...
pub pin_uv_auth_protocols : Option < BoundedVec < AuthProtocolVersion , 1 , { usize ::MAX } > > ,
// Cannot be empty if present
#[ cfg_attr(feature = " serde " , serde(rename = 0x06)) ]
pub pin_uv_auth_protocols : Option < Vec < auth_protocol ::Version > > ,
/// > Maximum number of credentials supported in credentialID list at a time
/// > Maximum number of credentials supported in credentialID list at a time
/// > by the authenticator.
/// > by the authenticator.
#[ cfg_attr(feature = " serde " , serde(rename = 0x07)) ]
pub max_credential_count_in_list : Option < NonZeroUsize > ,
pub max_credential_count_in_list : Option < NonZeroUsize > ,
/// > Maximum Credential ID Length supported by the authenticator.
/// > Maximum Credential ID Length supported by the authenticator.
#[ cfg_attr(feature = " serde " , serde(rename = 0x08)) ]
pub max_credential_id_length : Option < NonZeroUsize > ,
pub max_credential_id_length : Option < NonZeroUsize > ,
/// > List of supported transports.
/// > List of supported transports.
#[ cfg_attr(feature = " serde " , serde(rename = 0x09)) ]
pub transports : Option < BTreeSet < Transport > > ,
pub transports : Option < BTreeSet < Transport > > ,
/// > List of supported algorithms for credential generation... The array is
/// > List of supported algorithms for credential generation... The array is
/// > ordered from most preferred to least preferred and MUST NOT include
/// > ordered from most preferred to least preferred and MUST NOT include
/// > duplicate entries...
/// > duplicate entries...
pub algorithms : Option < BoundedVec < public_key ::Parameters , 1 , { usize ::MAX } > > ,
#[ cfg_attr(feature = " serde " , serde(rename = 0x0A)) ]
// Cannot be empty if present
pub algorithms : Option < Vec < public_key ::Parameters > > ,
/// > The maximum size, in bytes, of the serialized large-blob array that
/// > The maximum size, in bytes, of the serialized large-blob array that
/// > this authenticator can store. If the `authenticatorLargeBlobs` command
/// > this authenticator can store. If the `authenticatorLargeBlobs` command
/// > is supported, this MUST be specified. Otherwise it MUST NOT be.
/// > is supported, this MUST be specified. Otherwise it MUST NOT be.
#[ cfg_attr(feature = " serde " , serde(rename = 0x0B)) ]
pub max_serialized_large_blob_array_size : Option < UsizeN < 1024 > > ,
pub max_serialized_large_blob_array_size : Option < UsizeN < 1024 > > ,
/// > If this member is:
/// > If this member is:
/// > - present and set to true: `getPinToken` and
/// > - present and set to true: `getPinToken` and
/// > `getPinUvAuthTokenUsingPinWithPermissions` will return errors until
/// > `getPinUvAuthTokenUsingPinWithPermissions` will return errors until
/// > after a successful PIN Change.
/// > after a successful PIN Change.
/// > - present and set to false, or absent: no PIN Change is required.
/// > - present and set to false, or absent: no PIN Change is required.
#[ cfg_attr(feature = " serde " , serde(rename = 0x0C)) ]
pub force_pin_change : Option < bool > ,
pub force_pin_change : Option < bool > ,
/// > This specifies the current minimum PIN length, in Unicode code points,
/// > This specifies the current minimum PIN length, in Unicode code points,
/// > the authenticator enforces for ClientPIN. This is applicable for
/// > the authenticator enforces for ClientPIN. This is applicable for
/// > ClientPIN only: the minPINLength member MUST be absent if the
/// > ClientPIN only: the minPINLength member MUST be absent if the
/// > clientPin option ID is absent; it MUST be present if the authenticator
/// > clientPin option ID is absent; it MUST be present if the authenticator
/// > supports authenticatorClientPIN.
/// > supports authenticatorClientPIN.
#[ cfg_attr(feature = " serde " , serde(rename = 0x0D)) ]
pub min_pin_length : Option < usize > ,
pub min_pin_length : Option < usize > ,
/// > Indicates the firmware version of the authenticator model identified
/// > Indicates the firmware version of the authenticator model identified
/// > by AAGUID.
/// > by AAGUID.
#[ cfg_attr(feature = " serde " , serde(rename = 0x0E)) ]
pub firmware_version : Option < usize > ,
pub firmware_version : Option < usize > ,
/// > Maximum credBlob length in bytes supported by the authenticator. Must
/// > Maximum credBlob length in bytes supported by the authenticator. Must
/// > be present if, and only if, credBlob is included in the supported
/// > be present if, and only if, credBlob is included in the supported
/// > extensions list.
/// > extensions list.
#[ cfg_attr(feature = " serde " , serde(rename = 0x0F)) ]
pub max_cred_blob_length : Option < UsizeN < 32 > > ,
pub max_cred_blob_length : Option < UsizeN < 32 > > ,
/// > This specifies the max number of RP IDs that authenticator can set via
/// > This specifies the max number of RP IDs that authenticator can set via
/// > `setMinPINLength` subcommand. This is in addition to pre-configured
/// > `setMinPINLength` subcommand. This is in addition to pre-configured
@ -236,12 +298,14 @@ pub struct Info {
/// > adding additional RP IDs, its value is 0. This MUST ONLY be present
/// > adding additional RP IDs, its value is 0. This MUST ONLY be present
/// > if, and only if, the authenticator supports the `setMinPINLength`
/// > if, and only if, the authenticator supports the `setMinPINLength`
/// > subcommand.
/// > subcommand.
#[ cfg_attr(feature = " serde " , serde(rename = 0x10)) ]
pub max_rpids_for_set_min_pin_length : Option < usize > ,
pub max_rpids_for_set_min_pin_length : Option < usize > ,
/// > This specifies the preferred number of invocations of the
/// > This specifies the preferred number of invocations of the
/// > `getPinUvAuthTokenUsingUvWithPermissions` subCommand the platform may
/// > `getPinUvAuthTokenUsingUvWithPermissions` subCommand the platform may
/// > attempt before falling back to the
/// > attempt before falling back to the
/// > `getPinUvAuthTokenUsingPinWithPermissions` subCommand or displaying an
/// > `getPinUvAuthTokenUsingPinWithPermissions` subCommand or displaying an
/// > error.
/// > error.
#[ cfg_attr(feature = " serde " , serde(rename = 0x11)) ]
pub preferred_platform_uv_attempts : Option < NonZeroUsize > ,
pub preferred_platform_uv_attempts : Option < NonZeroUsize > ,
/// > This specifies the user verification modality supported by the
/// > This specifies the user verification modality supported by the
/// > authenticator via `authenticatorClientPIN`'s
/// > authenticator via `authenticatorClientPIN`'s
@ -249,8 +313,10 @@ pub struct Info {
/// > to help the platform construct user dialogs. If `clientPin`
/// > to help the platform construct user dialogs. If `clientPin`
/// > is supported it MUST NOT be included in the bit-flags, as `clientPIN`
/// > is supported it MUST NOT be included in the bit-flags, as `clientPIN`
/// > is not a built-in user verification method.
/// > is not a built-in user verification method.
#[ cfg_attr(feature = " serde " , serde(rename = 0x12)) ]
pub uv_modality : Option < BTreeSet < registry ::UserVerify > > ,
pub uv_modality : Option < BTreeSet < registry ::UserVerify > > ,
/// > This specifies a list of authenticator certifications.
/// > This specifies a list of authenticator certifications.
#[ cfg_attr(feature = " serde " , serde(rename = 0x13)) ]
pub certifications : Option < BTreeSet < Certification > > ,
pub certifications : Option < BTreeSet < Certification > > ,
/// > If this member is present it indicates the estimated number of
/// > If this member is present it indicates the estimated number of
/// > additional discoverable credentials that can be stored. If this value
/// > additional discoverable credentials that can be stored. If this value
@ -268,10 +334,22 @@ pub struct Info {
/// > user.id that match an existing discoverable credential and thus
/// > user.id that match an existing discoverable credential and thus
/// > overwrite it, but this value should be set assuming that will not
/// > overwrite it, but this value should be set assuming that will not
/// > happen.
/// > happen.
#[ cfg_attr(feature = " serde " , serde(rename = 0x14)) ]
pub remaining_discoverable_credentials : Option < usize > ,
pub remaining_discoverable_credentials : Option < usize > ,
/// > If present the authenticator supports the `authenticatorConfig`
/// > If present the authenticator supports the `authenticatorConfig`
/// > `vendorPrototype` subcommand, and its value is a list of
/// > `vendorPrototype` subcommand, and its value is a list of
/// > `authenticatorConfig` `vendorCommandId` values supported, which MAY be
/// > `authenticatorConfig` `vendorCommandId` values supported, which MAY be
/// > empty.
/// > empty.
#[ cfg_attr(feature = " serde " , serde(rename = 0x15)) ]
pub vendor_prototype_config_commands : Option < BTreeSet < usize > > ,
pub vendor_prototype_config_commands : Option < BTreeSet < usize > > ,
/// > List of supported attestation formats.
#[ cfg_attr(feature = " serde " , serde(rename = 0x16)) ]
pub attestation_formats : Option < BTreeSet < attestation ::FormatIdentifier > > ,
/// > If present the number of internal User Verification operations since
/// > the last pin entry including all failed attempts.
#[ cfg_attr(feature = " serde " , serde(rename = 0x17)) ]
pub uv_count_since_last_pin_entry : Option < usize > ,
/// > If present the authenticator requires a 10 second touch for reset.
#[ cfg_attr(feature = " serde " , serde(rename = 0x18)) ]
pub long_touch_for_reset : Option < bool > ,
}
}