fido2.cose

Attributes

T_CoseKey

Classes

CoseKey

A COSE formatted public key.

UnsupportedKey

A COSE key with an unsupported algorithm.

ES256

A COSE formatted public key.

ES384

A COSE formatted public key.

ES512

A COSE formatted public key.

RS256

A COSE formatted public key.

PS256

A COSE formatted public key.

EdDSA

A COSE formatted public key.

RS1

A COSE formatted public key.

ES256K

A COSE formatted public key.

Module Contents

class fido2.cose.CoseKey[source]

Bases: dict

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM: int = None
abstract verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message (bytes) – The message which was signed.

  • signature (bytes) – The signature to check.

Return type:

None

classmethod from_cryptography_key(public_key)[source]
Abstractmethod:

Parameters:

public_key (cryptography.hazmat.primitives.asymmetric.types.PublicKeyTypes)

Return type:

T_CoseKey

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key (cryptography.hazmat.primitives.asymmetric.types.PublicKeyTypes) – Either an EC or RSA public key.

Returns:

A CoseKey.

Return type:

T_CoseKey

static for_alg(alg)[source]

Get a subclass of CoseKey corresponding to an algorithm identifier.

Parameters:

alg (int) – The COSE identifier of the algorithm.

Returns:

A CoseKey.

Return type:

Type[CoseKey]

static for_name(name)[source]

Get a subclass of CoseKey corresponding to an algorithm identifier.

Parameters:
  • alg – The COSE identifier of the algorithm.

  • name (str)

Returns:

A CoseKey.

Return type:

Type[CoseKey]

static parse(cose)[source]

Create a CoseKey from a dict

Parameters:

cose (Mapping[int, Any])

Return type:

CoseKey

static supported_algorithms()[source]

Get a list of all supported algorithm identifiers

Return type:

Sequence[int]

fido2.cose.T_CoseKey
class fido2.cose.UnsupportedKey[source]

Bases: CoseKey

A COSE key with an unsupported algorithm.

class fido2.cose.ES256[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

classmethod from_ctap1(data)[source]

Creates an ES256 key from a CTAP1 formatted public key byte string.

Parameters:

data – A 65 byte SECP256R1 public key.

Returns:

A ES256 key.

class fido2.cose.ES384[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.ES512[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.RS256[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.PS256[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.EdDSA[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.RS1[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.

class fido2.cose.ES256K[source]

Bases: CoseKey

A COSE formatted public key.

Parameters:

_ – The COSE key paramters.

Variables:

ALGORITHM – COSE algorithm identifier.

ALGORITHM
verify(message, signature)[source]

Validates a digital signature over a given message.

Parameters:
  • message – The message which was signed.

  • signature – The signature to check.

classmethod from_cryptography_key(public_key)[source]

Converts a PublicKey object from Cryptography into a COSE key.

Parameters:

public_key – Either an EC or RSA public key.

Returns:

A CoseKey.