Skip to content

Latest commit

 

History

History
118 lines (83 loc) · 2.71 KB

README_Biometric_management.md

File metadata and controls

118 lines (83 loc) · 2.71 KB

Biometric management

This command manages the fingerprints in the authenticator.
Spec: 6.7. authenticatorBioEnrollment (0x09)

To use this feature, the Authenticator must implement BioEnroll or UserVerificationMgmtPreview. check with enable_info_option()

fn is_supported(device: &FidoKeyHid) -> Result<bool> {
    if device.enable_info_option(&InfoOption::BioEnroll)?.is_some() {
        return Ok(true);
    }

    if device
        .enable_info_option(&&InfoOption::UserVerificationMgmtPreview)?
        .is_some()
    {
        Ok(true)
    } else {
        Ok(false)
    }
}

Example

bio_enrollment_get_fingerprint_sensor_info()

Get fingerprint sensor information.

match device.bio_enrollment_get_fingerprint_sensor_info() {
    Ok(result) => println!("- {:?}", result),
    Err(e) => println!("- error: {:?}", e),
}

bio_enrollment_enumerate_enrollments()

Enumurate a list of registered fingerprints.

match device.bio_enrollment_enumerate_enrollments(Some(pin)) {
    Ok(infos) => for i in infos {println!("- {}", i)},
    Err(e) => println!("- error: {:?}", e)
}

bio_enrollment_begin(),bio_enrollment_next()

Enroll one fingerprint.
run bio_enrollment_begin first and then bio_enrollment_next several times.
is_finish detects the completion of registration.

fn bio_enrollment(pin: &str) -> Result<(), String> {
    println!("bio_enrollment_begin");
    let result = device.bio_enrollment_begin(
        Some(pin),
        Some(10000),
    )?;
    println!("{}", result.1);
    println!("");

    for _counter in 0..10 {
        if bio_enrollment_next(&result.0)? {
            break;
        }
    }
    Ok(())
}

fn bio_enrollment_next(enroll_status: &EnrollStatus1) -> Result<bool, String> {
    println!("bio_enrollment_next");
    let result = device.bio_enrollment_next(enroll_status, Some(10000))?;
    println!("{}", result);
    println!("");
    Ok(result.is_finish)
}

bio_enrollment_set_friendly_name()

Update the registered name of the fingerprint.

match device::bio_enrollment_set_friendly_name(
    Some(pin),
    template_id, "display-name",
) {
    Ok(()) => println!("- Success"),
    Err(e) => println!("- error: {:?}", e),
}

bio_enrollment_remove()

Delete a fingerprint.

match ctap_hid_fido2::bio_enrollment_remove(
     Some(pin),
     template_id,
 ) {
     Ok(_) => println!("- Success"),
     Err(e) => println!("- error: {:?}", e),
 }