Aead class

class crsysapi.Aead

Authenticated encryption with Additional Data (AEAD) functions.

class AeadAlg

AEAD algorithm options.

AEAD_ASCON_128 = 26

ASCON-128 authentication scheme (provisional)

AEAD_ASCON_128A = 27

ASCON-128A authentication scheme (provisional)

AES_128_GCM = 1

AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)

AES_256_GCM = 2

AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)

CHACHA20_POLY1305 = 29

AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539)

class Opts

Advanced options.

DEFAULT = 0

Use default options

PREFIXIV = 4096

Prepend the IV before the ciphertext in the output

static decrypt_with_tag(input, key, iv, aeadalg, aad=None, opts=0)

Decrypt data using specified AEAD algorithm in one-off operation. The authentication tag is expected appended to the output.

Parameters:
  • input (bytes) -- Input data to be decrypted.

  • key (bytes) -- Key of exact length for algorithm (16 or 32 bytes).

  • iv (bytes) -- Initialization Vector (IV) (aka nonce). Set as None if prepended to input.

  • aeadalg (Aead.Alg) -- AEAD algorithm.

  • aad (bytes) -- Additional authenticated data (AAD) (optional).

  • opts (Aead.Opts) -- Advanced options. Use Aead.Opts.PREFIXIV to expect the IV to be prepended to the input.

Returns:

Plaintext in a byte array.

Return type:

bytes

static encrypt_with_tag(input, key, iv, aeadalg, aad=None, opts=0)

Encrypt data using specified AEAD algorithm in one-off operation. The authentication tag is appended to the output.

Parameters:
  • input (bytes) -- Input data to be encrypted.

  • key (bytes) -- Key of exact length for algorithm (16 or 32 bytes).

  • iv (bytes) -- Initialization Vector (IV) (aka nonce).

  • aeadalg (Aead.Alg) -- AEAD algorithm.

  • aad (bytes) -- Additional authenticated data (AAD) (optional).

  • opts (Aead.Opts) -- Advanced options. Use Aead.Opts.PREFIXIV to prepend the IV the output.

Returns:

Ciphertext with tag appended in a byte array.

Return type:

bytes