COSE Algorithms

Overview

All CoseAlgorithm have a fullname and identifier attribute. Both attributes can be used in COSE headers and COSE keys.

>>> from pycose.messages import Enc0Message
>>> from pycose.algorithms import A128GCM

>>> msg1 = Enc0Message(phdr={'ALG': A128GCM})
>>> msg2 = Enc0Message(phdr={'ALG': 'A128GCM'})
>>> msg3 = Enc0Message(phdr={'ALG': 1})

>>> # encoded protected header
>>> msg1.phdr_encoded
b'\xa1\x01\x01'

>>> msg1.phdr_encoded == msg2.phdr_encoded == msg3.phdr_encoded
True

The full list with COSE algorithms and their identifiers can be found at the IANA registry

API

class pycose.algorithms.Shake256

SHAKE-256 512-bit Hash Value

Attributes:

identifier -45

fullname SHAKE-256

class pycose.algorithms.Sha512

SHA-2 512-bit Hash

Attributes:

identifier -46

fullname SHA-512

class pycose.algorithms.Sha384

SHA-2 384-bit Hash

Attributes:

identifier -43

fullname SHA-384

class pycose.algorithms.Es512

ECDSA w/ SHA-512

Attributes:

identifier -36

fullname ES512

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_curve()

Returns a curve object used with this algorithm

class pycose.algorithms.Es384

ECDSA w/ SHA-384

Attributes:

identifier -35

fullname ES384

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_curve()

Returns a curve object used with this algorithm

class pycose.algorithms.EcdhSsA256KW

ECDH SS w/ Concat KDF and AES Key Wrap w/ 256-bit key

Attributes:

identifier -34

fullname ECDH_SS_A256KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function

class pycose.algorithms.EcdhSsA192KW

ECDH SS w/ Concat KDF and AES Key Wrap w/ 192-bit key

Attributes:

identifier -33

fullname ECDH_SS_A192KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function

class pycose.algorithms.EcdhSsA128KW

ECDH SS w/ Concat KDF and AES Key Wrap w/ 128-bit key

Attributes:

identifier -32

fullname ECDH_SS_A128KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function

class pycose.algorithms.EcdhEsA256KW

ECDH ES w/ Concat KDF and AES Key Wrap w/ 256-bit key

Attributes:

identifier -33

fullname ECDH_ES_A256KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function

class pycose.algorithms.EcdhEsA192KW

ECDH ES w/ Concat KDF and AES Key Wrap w/ 192-bit key

Attributes:

identifier -30

fullname ECDH_ES_A192KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function

class pycose.algorithms.EcdhEsA128KW

ECDH ES w/ Concat KDF and AES Key Wrap w/ 128-bit key

Attributes:

identifier -29

fullname ECDH_ES_A128KW

classmethod get_hash_func()

Returns a hash function used with this algorithm

classmethod get_key_wrap_func()

Returns a key wrap function used with this algorithm

classmethod get_key_length()

Returns the key length of the wrapping function