Skip to content

Commit

Permalink
DeDRM ion: Correctly throw last exception if decrypt fails
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j authored and noDRM committed Nov 10, 2024
1 parent 195ea69 commit 34c4c06
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DeDRM_plugin/ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Copyright © 2013-2020 Apprentice Harper et al.
"""
from __future__ import annotations

import collections
import hashlib
Expand Down Expand Up @@ -1345,7 +1346,7 @@ def decryptvoucher(self):
process_V4648(shared), process_V5683(shared)]

decrypted=False
ex=None
lastexception: Exception | None = None
for sharedsecret in sharedsecrets:
key = hmac.new(sharedsecret, b"PIDv3", digestmod=hashlib.sha256).digest()
aes = AES.new(key[:32], AES.MODE_CBC, self.cipheriv[:16])
Expand All @@ -1362,9 +1363,10 @@ def decryptvoucher(self):
print("Decryption succeeded")
break
except Exception as ex:
lastexception = ex
print("Decryption failed, trying next fallback ")
if not decrypted:
raise ex
raise lastexception

self.drmkey.stepin()
while self.drmkey.hasnext():
Expand Down

0 comments on commit 34c4c06

Please sign in to comment.