Skip to content

miniproto.crypto.native.aes_256_gcm_encrypt_native

miniproto.crypto.native.aes_256_gcm_encrypt_native

Section titled “miniproto.crypto.native.aes_256_gcm_encrypt_native”
aes_256_gcm_encrypt_native(plaintext: bytes, key: bytes, nonce: bytes, associated_data: bytes) -> bytes

Encrypt with the explicit compiled Rust AES-256-GCM capability.

Parameters:

  • plaintext (bytes) – Bytes to protect.
  • key (bytes) – Exactly 32 bytes of AES-256 key material.
  • nonce (bytes) – Exactly 12 unique bytes for this key.
  • associated_data (bytes) – Authenticated but unencrypted bytes.

Returns:

  • bytes – Ciphertext followed by the GCM tag.

Raises:

  • RuntimeError – If native session AES-GCM is unavailable.
  • ValueError – If cryptographic inputs are invalid.

Unlike :func:aes_256_gcm_encrypt, this never falls back. It does not manage nonce uniqueness or key lifetime.