findmy.keys

Module to work with private and public keys as used in FindMy accessories.

Attributes

K

Classes

KeyType

Enum of possible key types.

HasHashedPublicKey

ABC for anything that has a public, hashed FindMy-key.

HasPublicKey

ABC for anything that has a public FindMy-key.

KeyPair

A private-public keypair for a trackable FindMy accessory.

KeyGenerator

KeyPair generator.

Module Contents

class findmy.keys.KeyType

Bases: enum.Enum

Enum of possible key types.

UNKNOWN = 0
PRIMARY = 1
SECONDARY = 2
class findmy.keys.HasHashedPublicKey

Bases: abc.ABC

ABC for anything that has a public, hashed FindMy-key.

Also called a “hashed advertisement” key or “lookup” key.

property hashed_adv_key_bytes: bytes
Abstractmethod:

Return the hashed advertised (public) key as bytes.

property hashed_adv_key_b64: str

Return the hashed advertised (public) key as a base64-encoded string.

__hash__() int
__eq__(other: object) bool
class findmy.keys.HasPublicKey

Bases: HasHashedPublicKey, abc.ABC

ABC for anything that has a public FindMy-key.

Also called an “advertisement” key, since it is the key that is advertised by findable devices.

property adv_key_bytes: bytes
Abstractmethod:

Return the advertised (public) key as bytes.

property adv_key_b64: str

Return the advertised (public) key as a base64-encoded string.

property mac_address: str

Get the mac address from the public key.

property hashed_adv_key_bytes: bytes

See HasHashedPublicKey.hashed_adv_key_bytes.

class findmy.keys.KeyPair(private_key: bytes, key_type: KeyType = KeyType.UNKNOWN, name: str | None = None)

Bases: HasPublicKey

A private-public keypair for a trackable FindMy accessory.

property key_type: KeyType

Type of this key.

property name: str | None

Name of this KeyPair.

classmethod new() KeyPair

Generate a new random KeyPair.

classmethod from_b64(key_b64: str) KeyPair

Import an existing KeyPair from its base64-encoded representation.

Same format as returned by KeyPair.private_key_b64.

property private_key_bytes: bytes

Return the private key as bytes.

property private_key_b64: str

Return the private key as a base64-encoded string.

Can be re-imported using KeyPair.from_b64.

property adv_key_bytes: bytes

Return the advertised (public) key as bytes.

dh_exchange(other_pub_key: cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey) bytes

Do a Diffie-Hellman key exchange using another EC public key.

__repr__() str
findmy.keys.K
class findmy.keys.KeyGenerator

Bases: abc.ABC, Generic[K]

KeyPair generator.

abstract __iter__() KeyGenerator
abstract __next__() K
abstract __getitem__(val: int) K
abstract __getitem__(val: slice) Generator[K, None, None]