@@ -147,10 +147,10 @@ fn check_fingerprint_loop<E: Env>(
147147
148148fn enroll_begin < E : Env > (
149149 env : & mut E ,
150- sub_command_params : BioEnrollmentSubCommandParams ,
150+ sub_command_params : Option < BioEnrollmentSubCommandParams > ,
151151) -> CtapResult < ResponseData > {
152152 let template_id = env. fingerprint ( ) . prepare_enrollment ( ) ?;
153- let timeout_ms = sub_command_params. timeout_milliseconds ;
153+ let timeout_ms = sub_command_params. and_then ( |p| p . timeout_milliseconds ) ;
154154 let ( sample_status, remaining_samples) =
155155 env. fingerprint ( ) . capture_sample ( & template_id, timeout_ms) ?;
156156 let response = AuthenticatorBioEnrollmentResponse {
@@ -284,17 +284,20 @@ pub fn process_bio_enrollment<E: Env>(
284284 client_pin. verify_pin_uv_auth_token ( & command_data, & pin_uv_auth_param, pin_uv_auth_protocol) ?;
285285 client_pin. has_permission ( PinPermission :: BioEnrollment ) ?;
286286 // Now we process all other subcommands that need PIN UV authentication.
287- if sub_command == BioEnrollmentSubCommand :: EnumerateEnrollments {
288- return enumerate_enrollments ( env) ;
289- }
290- let sub_command_params = ok_or_missing ( params. sub_command_params ) ?;
291287 match sub_command {
292- BioEnrollmentSubCommand :: EnrollBegin => enroll_begin ( env, sub_command_params) ,
288+ // Since the subcommand parameter map can be empty, the whole map might be missing.
289+ // In CTAP, the parameter is not marked as optional, but Chrome omits it when empty.
290+ BioEnrollmentSubCommand :: EnrollBegin => enroll_begin ( env, params. sub_command_params ) ,
293291 BioEnrollmentSubCommand :: EnrollCaptureNextSample => {
294- enroll_capture_next_sample ( env, sub_command_params)
292+ enroll_capture_next_sample ( env, ok_or_missing ( params. sub_command_params ) ?)
293+ }
294+ BioEnrollmentSubCommand :: EnumerateEnrollments => enumerate_enrollments ( env) ,
295+ BioEnrollmentSubCommand :: SetFriendlyName => {
296+ set_friendly_name ( env, ok_or_missing ( params. sub_command_params ) ?)
297+ }
298+ BioEnrollmentSubCommand :: RemoveEnrollment => {
299+ remove_enrollment ( env, ok_or_missing ( params. sub_command_params ) ?)
295300 }
296- BioEnrollmentSubCommand :: SetFriendlyName => set_friendly_name ( env, sub_command_params) ,
297- BioEnrollmentSubCommand :: RemoveEnrollment => remove_enrollment ( env, sub_command_params) ,
298301 _ => unreachable ! ( ) ,
299302 }
300303}
0 commit comments