fido2.ctap2.bio

Exceptions

CaptureError

Common base class for all non-exit exceptions.

Classes

BioEnrollment

FPEnrollmentContext

Helper object to perform fingerprint enrollment.

FPBioEnrollment

Implementation of a draft specification of the bio enrollment API.

Module Contents

class fido2.ctap2.bio.BioEnrollment(ctap, modality)[source]
Parameters:
class RESULT[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

MODALITY = 1
FINGERPRINT_KIND = 2
MAX_SAMPLES_REQUIRED = 3
TEMPLATE_ID = 4
LAST_SAMPLE_STATUS = 5
REMAINING_SAMPLES = 6
TEMPLATE_INFOS = 7
class TEMPLATE_INFO[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

ID = 1
NAME = 2
class MODALITY[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

FINGERPRINT = 1
static is_supported(info)[source]
Parameters:

info (fido2.ctap2.base.Info)

Return type:

bool

ctap
modality
get_modality()[source]

Get bio modality.

Returns:

The type of modality supported by the authenticator.

Return type:

int

exception fido2.ctap2.bio.CaptureError(code)[source]

Bases: Exception

Common base class for all non-exit exceptions.

Parameters:

code (int)

code
class fido2.ctap2.bio.FPEnrollmentContext(bio, timeout=None)[source]

Helper object to perform fingerprint enrollment.

Parameters:
  • bio (FPBioEnrollment) – An instance of FPBioEnrollment.

  • timeout (Optional[int]) – Optional timeout for fingerprint captures (ms).

Variables:
  • remaining – The number of (estimated) remaining samples needed.

  • template_id – The ID of the new template (only available after the initial sample has been captured).

timeout
template_id: bytes | None = None
remaining: int | None = None
capture(event=None, on_keepalive=None)[source]

Capture a fingerprint sample.

This call will block for up to timeout milliseconds (or indefinitely, if timeout not specified) waiting for the user to scan their fingerprint to collect one sample.

Returns:

None, if more samples are needed, or the template ID if enrollment is completed.

Parameters:
Return type:

Optional[bytes]

cancel()[source]

Cancels ongoing enrollment.

Return type:

None

class fido2.ctap2.bio.FPBioEnrollment(ctap, pin_uv_protocol, pin_uv_token)[source]

Bases: BioEnrollment

Implementation of a draft specification of the bio enrollment API. WARNING: This specification is not final and this class is likely to change.

NOTE: The get_fingerprint_sensor_info method does not require authentication, and can be used by setting pin_uv_protocol and pin_uv_token to None.

Parameters:
class CMD[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

ENROLL_BEGIN = 1
ENROLL_CAPTURE_NEXT = 2
ENROLL_CANCEL = 3
ENUMERATE_ENROLLMENTS = 4
SET_NAME = 5
REMOVE_ENROLLMENT = 6
GET_SENSOR_INFO = 7
class PARAM[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

TEMPLATE_ID = 1
TEMPLATE_NAME = 2
TIMEOUT_MS = 3
class FEEDBACK[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

FP_GOOD = 0
FP_TOO_HIGH = 1
FP_TOO_LOW = 2
FP_TOO_LEFT = 3
FP_TOO_RIGHT = 4
FP_TOO_FAST = 5
FP_TOO_SLOW = 6
FP_POOR_QUALITY = 7
FP_TOO_SKEWED = 8
FP_TOO_SHORT = 9
FP_MERGE_FAILURE = 10
FP_EXISTS = 11
FP_DATABASE_FULL = 12
NO_USER_ACTIVITY = 13
NO_UP_TRANSITION = 14
__str__()[source]

Return str(self).

pin_uv_protocol
pin_uv_token
get_fingerprint_sensor_info()[source]

Get fingerprint sensor info.

Returns:

A dict containing FINGERPRINT_KIND and MAX_SAMPLES_REQUIRES.

Return type:

Mapping[int, Any]

enroll_begin(timeout=None, event=None, on_keepalive=None)[source]

Start fingerprint enrollment.

Starts the process of enrolling a new fingerprint, and will wait for the user to scan their fingerprint once to provide an initial sample.

Parameters:
  • timeout (Optional[int]) – Optional timeout in milliseconds.

  • event (Optional[threading.Event])

  • on_keepalive (Optional[Callable[[int], None]])

Returns:

A tuple containing the new template ID, the sample status, and the number of samples remaining to complete the enrollment.

Return type:

Tuple[bytes, FPBioEnrollment, int]

enroll_capture_next(template_id, timeout=None, event=None, on_keepalive=None)[source]

Continue fingerprint enrollment.

Continues enrolling a new fingerprint and will wait for the user to scan their fingerpring once to provide a new sample. Once the number of samples remaining is 0, the enrollment is completed.

Parameters:
  • template_id (bytes) – The template ID returned by a call to enroll_begin.

  • timeout (Optional[int]) – Optional timeout in milliseconds.

  • event (Optional[threading.Event])

  • on_keepalive (Optional[Callable[[int], None]])

Returns:

A tuple containing the sample status, and the number of samples remaining to complete the enrollment.

Return type:

Tuple[FPBioEnrollment, int]

enroll_cancel()[source]

Cancel any ongoing fingerprint enrollment.

Return type:

None

enroll(timeout=None)[source]

Convenience wrapper for doing fingerprint enrollment.

See FPEnrollmentContext for details. :return: An initialized FPEnrollmentContext.

Parameters:

timeout (Optional[int])

Return type:

FPEnrollmentContext

enumerate_enrollments()[source]

Get a dict of enrolled fingerprint templates which maps template ID’s to their friendly names.

Returns:

A dict of enrolled template_id -> name pairs.

Return type:

Mapping[bytes, Optional[str]]

set_name(template_id, name)[source]

Set/Change the friendly name of a previously enrolled fingerprint template.

Parameters:
  • template_id (bytes) – The ID of the template to change.

  • name (str) – A friendly name to give the template.

Return type:

None

remove_enrollment(template_id)[source]

Remove a previously enrolled fingerprint template.

Parameters:

template_id (bytes) – The Id of the template to remove.

Return type:

None