Skip to content

miniproto.media.cdn.decrypt_cdn_chunk

decrypt_cdn_chunk(data: bytes, *, key: bytes, iv: bytes, offset: int = 0) -> bytes

Decrypt a CDN ciphertext range with the counter aligned to its file offset.

Parameters:

  • data (bytes) – Ciphertext bytes for a contiguous CDN response; immutable buffers are not zeroized.
  • key (bytes) – Exactly 32 bytes of AES key material; immutable buffers are not zeroized.
  • iv (bytes) – Exactly 16 bytes forming the initial CTR counter; immutable buffers are not zeroized.
  • offset (int) – Non-negative file offset of data; defaults to 0.

Returns:

  • bytes – Plaintext bytes of the same length as data.

Raises:

  • ValueErrorkey, iv, or offset violates CDN cryptographic constraints.