DeDRM ion: Correctly throw last exception if decrypt fails
This commit is contained in:
parent
195ea69537
commit
34c4c067e8
|
@ -13,6 +13,7 @@ Revision history:
|
||||||
|
|
||||||
Copyright © 2013-2020 Apprentice Harper et al.
|
Copyright © 2013-2020 Apprentice Harper et al.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -1345,7 +1346,7 @@ class DrmIonVoucher(object):
|
||||||
process_V4648(shared), process_V5683(shared)]
|
process_V4648(shared), process_V5683(shared)]
|
||||||
|
|
||||||
decrypted=False
|
decrypted=False
|
||||||
ex=None
|
lastexception: Exception | None = None
|
||||||
for sharedsecret in sharedsecrets:
|
for sharedsecret in sharedsecrets:
|
||||||
key = hmac.new(sharedsecret, b"PIDv3", digestmod=hashlib.sha256).digest()
|
key = hmac.new(sharedsecret, b"PIDv3", digestmod=hashlib.sha256).digest()
|
||||||
aes = AES.new(key[:32], AES.MODE_CBC, self.cipheriv[:16])
|
aes = AES.new(key[:32], AES.MODE_CBC, self.cipheriv[:16])
|
||||||
|
@ -1362,9 +1363,10 @@ class DrmIonVoucher(object):
|
||||||
print("Decryption succeeded")
|
print("Decryption succeeded")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
lastexception = ex
|
||||||
print("Decryption failed, trying next fallback ")
|
print("Decryption failed, trying next fallback ")
|
||||||
if not decrypted:
|
if not decrypted:
|
||||||
raise ex
|
raise lastexception
|
||||||
|
|
||||||
self.drmkey.stepin()
|
self.drmkey.stepin()
|
||||||
while self.drmkey.hasnext():
|
while self.drmkey.hasnext():
|
||||||
|
|
Loading…
Reference in New Issue