From fc45b63024c5f99812b9b73559278a1c7d7d0668 Mon Sep 17 00:00:00 2001 From: Satsuoni Date: Wed, 4 Aug 2021 13:00:58 +0900 Subject: [PATCH] Even noisier debug and key preservation --- content_key_decryption.js | 8 ++++---- eme_interception.js | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/content_key_decryption.js b/content_key_decryption.js index d48830d..29f164b 100644 --- a/content_key_decryption.js +++ b/content_key_decryption.js @@ -139,11 +139,11 @@ WidevineCrypto.tryDecodingKey=async function(encKey) return new Uint8Array(hexToBytes(res)); } -WidevineCrypto.decryptContentKey = async function(sesid,licenseRequest, licenseResponse) +WidevineCrypto.decryptContentKey = async function(sesid,sdat) { await this.initLog(); - licenseRequest = SignedMessage.read(new Pbf(licenseRequest)); - licenseResponse = SignedMessage.read(new Pbf(licenseResponse)); + licenseRequest = SignedMessage.read(new Pbf(sdat.licenseRequest)); + licenseResponse = SignedMessage.read(new Pbf(sdat.licenseResponse)); //console.log("Decrypting?") //console.log("Request (from us)") this.log(licenseRequest) @@ -190,7 +190,7 @@ WidevineCrypto.decryptContentKey = async function(sesid,licenseRequest, licenseR // finally decrypt the content key var decryptedKey = wordToByteArray( this.cryptoJS.AES.decrypt({ ciphertext: arrayToWordArray(keyData) }, arrayToWordArray(encryptKey), { iv: arrayToWordArray(keyIv) }).words); - + sdat.keys.set(toHexString(keyId),toHexString(decryptedKey)); contentKeys.push(decryptedKey); this.log("WidevineDecryptor: Session: "+sesid+ " KID= " + toHexString(keyId)+" Key: "+toHexString(decryptedKey) ); } diff --git a/eme_interception.js b/eme_interception.js index 7f17da2..4af5cfd 100644 --- a/eme_interception.js +++ b/eme_interception.js @@ -18,6 +18,7 @@ function SessionData(sess) this.self=sess; this.licenseRequest=null; this.licenseResponse=null; + this.keys=new Map(); } /** * Gets called whenever an EME method is getting called or an EME event fires @@ -67,14 +68,11 @@ EmeInterception.onOperation = function(operationType, args,target) c_sessions.set(sesid,sdat); if (sdat.licenseResponse!==null && sdat.licenseRequest!==null) { - WidevineCrypto.decryptContentKey(sesid,sdat.licenseRequest, sdat.licenseResponse); + WidevineCrypto.decryptContentKey(sesid,sdat); + c_sessions.set(sesid,sdat); } } - - lastReceivedLicenseResponse = licenseResponse; - - // OK, let's try to decrypt it, assuming the response correlates to the request - + } else if (operationType == "KeyStatusesChangeEvent") {