decryptor

package
v0.0.0-...-3a72003 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package decryptor handles decryption of encrypted DASH segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseIV

func ParseIV(ivStr string) ([]byte, error)

ParseIV parses a hex-encoded IV string (from #EXT-X-KEY IV attribute). Format: 0x... or plain hex string

func SegmentIV

func SegmentIV(sequenceNumber int) []byte

SegmentIV creates a default IV from segment sequence number. HLS spec: if no IV is specified, use the segment sequence number as a big-endian 128-bit value.

func ValidateKey

func ValidateKey(key string) error

ValidateKey checks if the decryption key format is valid.

Types

type Decryptor

type Decryptor struct {
	// contains filtered or unexported fields
}

Decryptor handles decryption of encrypted media segments.

func New

func New(keyString string) (*Decryptor, error)

New creates a new Decryptor with the given decryption key. keyString should be in format "KID:KEY" where both are 32 hex characters. Empty keyString creates a no-op decryptor.

func (*Decryptor) Decrypt

func (d *Decryptor) Decrypt(combined []byte) ([]byte, error)

Decrypt decrypts combined init+segment data. If decryption is not enabled, returns the original data unchanged. The combined slice should contain the init segment followed by the media segment.

func (*Decryptor) Enabled

func (d *Decryptor) Enabled() bool

Enabled returns true if decryption is configured.

type HLSDecryptor

type HLSDecryptor struct {
	// contains filtered or unexported fields
}

HLSDecryptor handles AES-128 decryption for HLS streams.

func NewHLSDecryptor

func NewHLSDecryptor(client *http.Client, headers map[string]string) *HLSDecryptor

NewHLSDecryptor creates a new HLS decryptor.

func (*HLSDecryptor) Decrypt

func (d *HLSDecryptor) Decrypt(data, key, iv []byte) ([]byte, error)

Decrypt decrypts data using AES-128-CBC with the given key and IV. If iv is nil, it defaults to the first 16 bytes of the data (or zero IV).

func (*HLSDecryptor) FetchKey

func (d *HLSDecryptor) FetchKey(ctx context.Context, keyURI string) ([]byte, error)

FetchKey retrieves the decryption key from the given URI. Keys are cached by URI to avoid redundant fetches.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL