Skip to content

miniproto.crypto.mtproto.media_cbc_encrypt

miniproto.crypto.mtproto.media_cbc_encrypt

Section titled “miniproto.crypto.mtproto.media_cbc_encrypt”
media_cbc_encrypt(plaintext: bytes, key: bytes, iv: bytes) -> bytes

Encrypt block-aligned media data with AES-256-CBC.

Parameters:

  • plaintext (bytes) – Bytes whose length is a multiple of 16; no padding is added.
  • key (bytes) – Exactly 32 bytes of AES-256 key material.
  • iv (bytes) – Exactly 16 bytes of initialization value.

Returns:

  • bytes – CBC ciphertext equal in length to plaintext.

Raises:

  • ValueError – If key/IV lengths or block alignment are invalid.

The caller owns padding and IV uniqueness. Backend selection is output-compatible and may use cryptography rather than Rust.