2.12.ipv8.messaging.anonymization.tunnelcrypto

Module Contents

Classes

exception 2.12.ipv8.messaging.anonymization.tunnelcrypto.CryptoException

Bases: Exception

Exception for when anything goes wrong with sessions, encoding, and decoding.

class 2.12.ipv8.messaging.anonymization.tunnelcrypto.SessionKeys

Session keys to communicate between hops.

key_forward: bytes
key_backward: bytes
salt_forward: bytes
salt_backward: bytes
salt_explicit_forward: int
salt_explicit_backward: int
class 2.12.ipv8.messaging.anonymization.tunnelcrypto.TunnelCrypto

Bases: 2.12.ipv8.keyvault.crypto.ECCrypto

Add Diffie-Hellman key establishment logic to ECCrypto.

initialize(key: 2.12.ipv8.keyvault.crypto.LibNaCLPK) None

Make this ECCrypto fit for key establishment based on the given public key.

is_key_compatible(key: 2.12.ipv8.types.PublicKey) bool

Whether the given key is a LibNaCLPK instance.

generate_diffie_secret() tuple[2.12.ipv8.keyvault.private.libnaclkey.LibNaCLSK, 2.12.ipv8.keyvault.crypto.LibNaCLPK]

Create a a new private-public keypair.

generate_diffie_shared_secret(dh_received: bytes, key: 2.12.ipv8.keyvault.crypto.LibNaCLPK | None = None) tuple[bytes, 2.12.ipv8.keyvault.crypto.LibNaCLPK, bytes]

Generate the shared secret from the received string and the given key.

verify_and_generate_shared_secret(dh_secret: 2.12.ipv8.keyvault.private.libnaclkey.LibNaCLSK, dh_received: bytes, auth: bytes, b: bytes) bytes

Generate the shared secret based on the response to the shared string and our own key.

generate_session_keys(shared_secret: bytes) SessionKeys

Generate new session keys based on the shared secret.

get_session_keys(keys: SessionKeys, direction: int) tuple[bytes, bytes, int]

Get the session keys for forward (0) or backward (1) communication.

encrypt_str(content: bytes, key: bytes, salt: bytes, salt_explicit: int) bytes

Encrypt content using the given key, salt, and incremental session salt.

decrypt_str(content: bytes, key: bytes, salt: bytes) bytes

Decrypt the given content using a key and salt.