Class: shaka.media.ClearKeyWebCryptoDecryptor

Constructor

new ClearKeyWebCryptoDecryptor()

Implements:
Source:

Members

BOX_TYPE_FREE_ :number

Box type for "free".
Type:
  • number
Source:

keyMap_ :Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>

Type:
  • Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>
Source:

keyMapPromise_ :Promise<!Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>>

Type:
  • Promise<!Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>>
Source:

lastInit_ :Uint8Array

Type:
  • Uint8Array
Source:

Methods

shouldUse(drmInfonullable) → {boolean}

Returns true if the ClearKey WebCrypto path should be used.
Parameters:
Name Type Attributes Description
drmInfo shaka.extern.DrmInfo <nullable>
Source:
Returns:
Type
boolean

addCounterOffset_(counternon-null, offset)

Add a block-count offset to a 16-byte big-endian AES-CTR counter. Only the lower 8 bytes (bytes 8-15) act as the incrementing counter per the CENC spec (section 9.1); the upper 8 bytes are the IV nonce.
Parameters:
Name Type Description
counter Uint8Array modified in place, 16 bytes
offset number number of 16-byte blocks to add
Source:

buildKeyMap_(drmInfonon-null) → {Promise<!Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>>}

Extracts a Map from a ClearKey DrmInfo whose licenseServerUri is a data:application/json;base64, URI.
Parameters:
Name Type Description
drmInfo shaka.extern.DrmInfo
Source:
Returns:
Type
Promise<!Map<string, {cbc: !CryptoKey, ctr: !CryptoKey}>>

decrypt(datanon-null, isInit, drmInfonon-null) → {Promise<!Uint8Array>}

Parameters:
Name Type Description
data BufferSource
isInit boolean
drmInfo shaka.extern.DrmInfo
Source:
Returns:
Type
Promise<!Uint8Array>

decryptFragment_(fragmentnon-null, segDatanon-null, initInfonon-null) → {Promise<!Uint8Array>}

Parameters:
Name Type Description
fragment shaka.media.ClearKeyWebCryptoDecryptor.FragmentInfo
segData Uint8Array
initInfo shaka.media.ClearKeyWebCryptoDecryptor.InitInfo
Source:
Returns:
Type
Promise<!Uint8Array>

decryptMdat_(mdatPayloadnon-null, sampleSizesnon-null, sencnullable, initInfonon-null, keyEntry, scheme) → {Promise<!Uint8Array>}

Decrypt the raw mdat payload sample by sample.
Parameters:
Name Type Attributes Description
mdatPayload Uint8Array
sampleSizes Array<number>
senc shaka.media.ClearKeyWebCryptoDecryptor.SencInfo <nullable>
initInfo shaka.media.ClearKeyWebCryptoDecryptor.InitInfo
keyEntry {cbc: !CryptoKey, ctr: !CryptoKey}
scheme string 'cenc' | 'cbcs'
Source:
Returns:
Type
Promise<!Uint8Array>

decryptSampleCbcs_(sampleDatanon-null, ivnon-null, subsamplesnullable, initInfonon-null, keyEntry) → {Promise<!Uint8Array>}

Decrypt one sample under CBCS (AES-128-CBC pattern encryption). Within each encrypted range, blocks alternate between encrypted (cryptByteBlock x 16 bytes) and clear (skipByteBlock x 16 bytes). Partial trailing blocks are always clear.
Parameters:
Name Type Attributes Description
sampleData Uint8Array
iv Uint8Array 16 bytes
subsamples Array<{clearBytes: number, encryptedBytes: number}> <nullable>
initInfo shaka.media.ClearKeyWebCryptoDecryptor.InitInfo
keyEntry {cbc: !CryptoKey, ctr: !CryptoKey}
Source:
Returns:
Type
Promise<!Uint8Array>

decryptSampleCenc_(sampleDatanon-null, ivnon-null, subsamplesnullable, keyEntry) → {Promise<!Uint8Array>}

Decrypt one sample under CENC (AES-128-CTR, full or subsample). The IV is the initial 128-bit counter block (big-endian). For subsample encryption the counter is NOT reset between subsample regions — it advances by the number of whole 16-byte blocks consumed in prior regions.
Parameters:
Name Type Attributes Description
sampleData Uint8Array
iv Uint8Array 16 bytes
subsamples Array<{clearBytes: number, encryptedBytes: number}> <nullable>
keyEntry {cbc: !CryptoKey, ctr: !CryptoKey}
Source:
Returns:
Type
Promise<!Uint8Array>

decryptSegment_(segmentDatanon-null, initDatanon-null) → {Promise<!Uint8Array>}

Full segment decryption pipeline.
Parameters:
Name Type Description
segmentData Uint8Array
initData Uint8Array
Source:
Returns:
Type
Promise<!Uint8Array>

destroy() → {Promise}

Request that this object be destroyed, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

parseInitSegment_(initDatanon-null) → {Map<number, !shaka.media.ClearKeyWebCryptoDecryptor.InitInfo>}

Parameters:
Name Type Description
initData Uint8Array
Source:
Returns:
Type
Map<number, !shaka.media.ClearKeyWebCryptoDecryptor.InitInfo>

parseMediaSegment_(segDatanon-null, trackInfosnon-null) → {shaka.media.ClearKeyWebCryptoDecryptor.SegmentParseResult}

Parameters:
Name Type Description
segData Uint8Array
trackInfos Map<number, !shaka.media.ClearKeyWebCryptoDecryptor.InitInfo>
Source:
Returns:
Type
shaka.media.ClearKeyWebCryptoDecryptor.SegmentParseResult

rawCBCDecrypt_(datanon-null, ivnon-null, cbcKeynon-null) → {Promise<!Uint8Array>}

AES-128-CBC decryption without PKCS7 unpadding. WebCrypto AES-CBC always applies PKCS7. CBCS stream data is NOT padded — partial final blocks are clear rather than padded. We work around this by appending a synthetic full PKCS7 padding block (16 x 0x10) so WebCrypto's automatic unpadding removes only that dummy block, leaving our real data (always 16-byte aligned here) intact.
Parameters:
Name Type Description
data Uint8Array Must be 16-byte aligned
iv Uint8Array 16 bytes
cbcKey CryptoKey AES-CBC key
Source:
Returns:
Exactly data.byteLength bytes
Type
Promise<!Uint8Array>

stripEncryptionFromInit_(initDatanon-null) → {Uint8Array}

Rewrites the init segment to strip encryption signalling: encv/enca -> original codec fourcc (from frma), sinf -> free. MSE will then accept the plain decrypted samples without complaint.
Parameters:
Name Type Description
initData Uint8Array
Source:
Returns:
Type
Uint8Array

Type Definitions

FragmentInfo

Type:
  • {moofStart: number, moofSize: number, mdatStart: number, mdatSize: number, sencInfo: ?shaka.media.ClearKeyWebCryptoDecryptor.SencInfo, tfhdDefaultSize: number, trackId: number, trunSamples: !Array<{size: number}>, boxesToFree: !Array<{start: number, size: number}>}
Source:

InitInfo

Type:
  • {defaultKID: string, encryptionScheme: string, defaultIVSize: number, defaultConstantIV: ?Uint8Array, defaultCryptByteBlock: number, defaultSkipByteBlock: number}
Source:

SegmentParseResult

Type:
Source:

SencInfo

Type:
  • {samples: !Array<{iv: !Uint8Array, subsamples: ?Array<{clearBytes: number, encryptedBytes: number}>}>}
Source: