Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility changes needed to implement virtual device with credential management #323

Open
wants to merge 1 commit into
base: ctap2-2021
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/ctap2/commands/credential_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Serialize for CredManagementParams {
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub(crate) enum CredManagementCommand {
pub enum CredManagementCommand {
GetCredsMetadata,
EnumerateRPsBegin,
EnumerateRPsGetNextRP,
Expand Down Expand Up @@ -98,9 +98,9 @@ impl CredManagementCommand {
}
#[derive(Debug)]
pub struct CredentialManagement {
pub(crate) subcommand: CredManagementCommand, // subCommand currently being requested
pin_uv_auth_param: Option<PinUvAuthParam>, // First 16 bytes of HMAC-SHA-256 of contents using pinUvAuthToken.
use_legacy_preview: bool,
pub subcommand: CredManagementCommand, // subCommand currently being requested
pub pin_uv_auth_param: Option<PinUvAuthParam>, // First 16 bytes of HMAC-SHA-256 of contents using pinUvAuthToken.
pub use_legacy_preview: bool,
}

impl CredentialManagement {
Expand Down Expand Up @@ -408,9 +408,9 @@ impl RequestCtap2 for CredentialManagement {

fn send_to_virtual_device<Dev: crate::VirtualFidoDevice>(
&self,
_dev: &mut Dev,
dev: &mut Dev,
) -> Result<Self::Output, HIDError> {
unimplemented!()
dev.manage_credentials(self)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/ctap2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ pub(crate) fn reset_helper<T: From<ResetResult>>(
}
}

pub(crate) fn set_or_change_pin_helper<T: From<()>>(
dev: &mut Device,
pub fn set_or_change_pin_helper<T: From<()>, Dev: FidoDevice>(
dev: &mut Dev,
mut current_pin: Option<Pin>,
new_pin: Pin,
status: Sender<crate::StatusUpdate>,
Expand Down Expand Up @@ -1104,8 +1104,8 @@ pub(crate) fn bio_enrollment(
false
}

pub(crate) fn credential_management(
dev: &mut Device,
pub fn credential_management<Dev: FidoDevice>(
dev: &mut Dev,
puat_result: Option<PinUvAuthResult>,
command: CredManagementCmd,
status: Sender<crate::StatusUpdate>,
Expand Down
7 changes: 7 additions & 0 deletions src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use crate::ctap2::commands::client_pin::{
GetPinUvAuthTokenUsingPinWithPermissions, GetPinUvAuthTokenUsingUvWithPermissions,
PinUvAuthTokenPermission,
};
use crate::ctap2::commands::credential_management::{
CredentialManagement, CredentialManagementResponse,
};
use crate::ctap2::commands::get_assertion::{GetAssertion, GetAssertionResult};
use crate::ctap2::commands::get_info::{AuthenticatorInfo, AuthenticatorVersion, GetInfo};
use crate::ctap2::commands::get_version::{GetVersion, U2FInfo};
Expand Down Expand Up @@ -366,4 +369,8 @@ pub trait VirtualFidoDevice: FidoDevice {
fn make_credentials(&self, req: &MakeCredentials) -> Result<MakeCredentialsResult, HIDError>;
fn reset(&self, req: &Reset) -> Result<(), HIDError>;
fn selection(&self, req: &Selection) -> Result<(), HIDError>;
fn manage_credentials(
&mut self,
req: &CredentialManagement,
) -> Result<CredentialManagementResponse, HIDError>;
}
Loading