Merge branch 'develop' into always-uv
This commit is contained in:
@@ -18,9 +18,21 @@ use super::pin_protocol_v1::PinProtocolV1;
|
||||
use super::response::ResponseData;
|
||||
use super::status_code::Ctap2StatusCode;
|
||||
use super::storage::PersistentStore;
|
||||
use super::{check_pin_uv_auth_protocol, ENFORCE_ALWAYS_UV};
|
||||
use super::{check_pin_uv_auth_protocol, ENFORCE_ALWAYS_UV, ENTERPRISE_ATTESTATION_MODE};
|
||||
use alloc::vec;
|
||||
|
||||
/// Processes the subcommand enableEnterpriseAttestation for AuthenticatorConfig.
|
||||
fn process_enable_enterprise_attestation(
|
||||
persistent_store: &mut PersistentStore,
|
||||
) -> Result<ResponseData, Ctap2StatusCode> {
|
||||
if ENTERPRISE_ATTESTATION_MODE.is_some() {
|
||||
persistent_store.enable_enterprise_attestation()?;
|
||||
Ok(ResponseData::AuthenticatorConfig)
|
||||
} else {
|
||||
Err(Ctap2StatusCode::CTAP1_ERR_INVALID_PARAMETER)
|
||||
}
|
||||
}
|
||||
|
||||
/// Processes the subcommand toggleAlwaysUv for AuthenticatorConfig.
|
||||
fn process_toggle_always_uv(
|
||||
persistent_store: &mut PersistentStore,
|
||||
@@ -100,6 +112,9 @@ pub fn process_config(
|
||||
}
|
||||
|
||||
match sub_command {
|
||||
ConfigSubCommand::EnableEnterpriseAttestation => {
|
||||
process_enable_enterprise_attestation(persistent_store)
|
||||
}
|
||||
ConfigSubCommand::ToggleAlwaysUv => process_toggle_always_uv(persistent_store),
|
||||
ConfigSubCommand::SetMinPinLength => {
|
||||
if let Some(ConfigSubCommandParams::SetMinPinLength(params)) = sub_command_params {
|
||||
@@ -117,6 +132,34 @@ mod test {
|
||||
use super::*;
|
||||
use crypto::rng256::ThreadRng256;
|
||||
|
||||
#[test]
|
||||
fn test_process_enable_enterprise_attestation() {
|
||||
let mut rng = ThreadRng256 {};
|
||||
let mut persistent_store = PersistentStore::new(&mut rng);
|
||||
let key_agreement_key = crypto::ecdh::SecKey::gensk(&mut rng);
|
||||
let pin_uv_auth_token = [0x55; 32];
|
||||
let mut pin_protocol_v1 = PinProtocolV1::new_test(key_agreement_key, pin_uv_auth_token);
|
||||
|
||||
let config_params = AuthenticatorConfigParameters {
|
||||
sub_command: ConfigSubCommand::EnableEnterpriseAttestation,
|
||||
sub_command_params: None,
|
||||
pin_uv_auth_param: None,
|
||||
pin_uv_auth_protocol: None,
|
||||
};
|
||||
let config_response =
|
||||
process_config(&mut persistent_store, &mut pin_protocol_v1, config_params);
|
||||
|
||||
if ENTERPRISE_ATTESTATION_MODE.is_some() {
|
||||
assert_eq!(config_response, Ok(ResponseData::AuthenticatorConfig));
|
||||
assert_eq!(persistent_store.enterprise_attestation(), Ok(true));
|
||||
} else {
|
||||
assert_eq!(
|
||||
config_response,
|
||||
Err(Ctap2StatusCode::CTAP1_ERR_INVALID_PARAMETER)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_toggle_always_uv() {
|
||||
let mut rng = ThreadRng256 {};
|
||||
|
||||
Reference in New Issue
Block a user