bobocep.dist.crypto.aes.BoboDistributedCryptoAES

class bobocep.dist.crypto.aes.BoboDistributedCryptoAES(aes_key: str, nonce_length: int = 16, mac_length: int = 16)[source]

Bases: bobocep.dist.crypto.crypto.BoboDistributedCrypto

AES encryption in GCM mode. Data are encrypted using either AES-128, AES-192, or AES-256 encryption.

__init__(aes_key: str, nonce_length: int = 16, mac_length: int = 16)[source]
Parameters
  • aes_key – The AES key to use for encryption.

  • nonce_length – The nonce length.

  • mac_length – The MAC length.

decrypt(msg_bytes: bytes) str[source]
Parameters

msg_bytes – Incoming bytes.

Returns

Incoming JSON string with other data from transit.

encrypt(msg_str: str) bytes[source]
Parameters

msg_str – Wraps JSON string in other data for transit.

Returns

The bytes to transmit.

end_bytes() bytes[source]
Returns

Bytes used to signify the end of every encrypted payload.

min_length() int[source]
Returns

The minimum possible length of an encrypted payload, in number of bytes.