Module: crypto_provider

class x3dh.crypto_provider.CryptoProvider[source]

Bases: ABC

Abstraction of the cryptographic operations needed by this package to allow for different backend implementations.

abstractmethod async static hkdf_derive(hash_function, length, salt, info, key_material)[source]
Parameters:
  • hash_function (HashFunction) – The hash function to parameterize the HKDF with.

  • length (int) – The number of bytes to derive.

  • salt (bytes) – The salt input for the HKDF.

  • info (bytes) – The info input for the HKDF.

  • key_material (bytes) – The input key material to derive from.

Return type:

bytes

Returns:

The derived key material.

class x3dh.crypto_provider.HashFunction(*values)[source]

Bases: Enum

Enumeration of the hash functions supported for the key derivation step of X3DH.

SHA_256 = 'SHA_256'
SHA_512 = 'SHA_512'
property hash_size: int

Returns: The byte size of the hashes produced by this hash function.