func BuildSignedMessage(msg []byte, privateKey *rsa.PrivateKey) ([]byte, error)
BuildSignedMessage creates and serializes a SignedMessage protobuf for a license request.
func GetKey(keys []*KeyContainer, id []byte) ([]byte, bool)
GetKey searches a slice of KeyContainers for a key by its ID. It returns the key and true if found, otherwise it returns nil and false.
func ParsePrivateKey(pemBytes []byte) (*rsa.PrivateKey, error)
ParsePrivateKey parses a PEM-encoded private key from a byte slice. It supports both PKCS#8 ("PRIVATE KEY") and PKCS#1 ("RSA PRIVATE KEY") formats.
KeyContainer holds the parsed and decrypted content key from a license.
type KeyContainer struct { ID []byte IV []byte Key []byte // This now holds the fully DECRYPTED key. }
func ParseLicenseResponse(responseData []byte, originalRequestBytes []byte, privateKey *rsa.PrivateKey) ([]*KeyContainer, error)
ParseLicenseResponse parses a response from the license server. It returns a slice of key containers on success. If the server responded with an error message, it returns a *LicenseError. For any other failures, it returns a standard Go error.
LicenseError reflects the structure of the Widevine LicenseError protobuf.
type LicenseError struct { ErrorCode *protobuf.Field }
func (le *LicenseError) Error() string
Error implements the standard Go error interface.
PsshData represents the Widevine-specific protobuf message.
type PsshData struct { KeyIDs [][]byte ContentID []byte }
func (p *PsshData) BuildLicenseRequest(clientID []byte) ([]byte, error)
BuildLicenseRequest creates and serializes a Widevine LicenseRequest protobuf message. It is a method on PsshData, which is marshaled to populate the pssh_data field. It defaults to RequestType 1 (STREAMING).
func (p *PsshData) Marshal() ([]byte, error)
Marshal serializes the PsshData struct into the protobuf wire format.
func (p *PsshData) Unmarshal(data []byte) error
Unmarshal parses the protobuf wire format into the PsshData struct.