AirPlay.V2.SecureChannel (AirPlay v0.5.0)

Copy Markdown View Source

AirPlay 2 encrypted RTSP control/event channel framing.

Plain RTSP bytes are split into 1024-byte chunks. Each encrypted chunk is: uint16_le(length) <> ciphertext <> tag, with the length prefix as AAD and a monotonically increasing little-endian counter in the ChaCha20-Poly1305 nonce.

Summary

Functions

Create a client-side secure control channel from the SRP shared secret.

Decrypt AP2 secure-channel chunks, buffering an incomplete trailing chunk.

Decrypt as many complete chunks as are available.

Encrypt plaintext into AP2 secure-channel chunks.

Create a control secure channel from a shared secret.

Create a secure channel for :control or :events.

Types

t()

@type t() :: %AirPlay.V2.SecureChannel{
  cipher_buffer: term(),
  decrypt_counter: term(),
  decrypt_key: term(),
  encrypt_counter: term(),
  encrypt_key: term(),
  read_ctr: term(),
  read_key: term(),
  write_ctr: term(),
  write_key: term()
}

Functions

control(shared_secret)

@spec control(binary()) :: t()

Create a client-side secure control channel from the SRP shared secret.

decrypt(channel, ciphertext)

@spec decrypt(t(), binary()) :: {binary(), t()}

Decrypt AP2 secure-channel chunks, buffering an incomplete trailing chunk.

decrypt_available(channel, ciphertext)

@spec decrypt_available(t(), binary()) ::
  {:ok, binary(), binary(), t()} | {:error, term()}

Decrypt as many complete chunks as are available.

encrypt(channel, plaintext)

@spec encrypt(t(), binary()) :: {binary(), t()}

Encrypt plaintext into AP2 secure-channel chunks.

new(shared_secret)

@spec new(binary()) :: t()

Create a control secure channel from a shared secret.

new(shared_secret, channel)

@spec new(binary(), :control | :events) :: t()

Create a secure channel for :control or :events.