summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin
diff options
context:
space:
mode:
authorNoDRM <[email protected]>2023-01-06 14:32:25 +0100
committerNoDRM <[email protected]>2023-01-06 14:32:25 +0100
commitfb8b0034448fd191fa2f3abc12233391d931e4a2 (patch)
tree8526bd4070620164c3f0ffe6e01f9d2c22b23152 /DeDRM_plugin
parent3c12806f38eecfd5b37a5ace890f7c00cbe52169 (diff)
Support for Adobe's 'aes128-cbc-uncompressed' encryption (see #242)
Diffstat (limited to 'DeDRM_plugin')
-rw-r--r--DeDRM_plugin/ineptepub.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/DeDRM_plugin/ineptepub.py b/DeDRM_plugin/ineptepub.py
index d403dac..f118ce6 100644
--- a/DeDRM_plugin/ineptepub.py
+++ b/DeDRM_plugin/ineptepub.py
@@ -91,6 +91,7 @@ class Decryptor(object):
self._aes = AES.new(bookkey, AES.MODE_CBC, b'\x00'*16)
self._encryption = etree.fromstring(encryption)
self._encrypted = encrypted = set()
+ self._encryptedForceNoDecomp = encryptedForceNoDecomp = set()
self._otherData = otherData = set()
self._json_elements_to_remove = json_elements_to_remove = set()
@@ -106,6 +107,11 @@ class Decryptor(object):
path = path.encode('utf-8')
encrypted.add(path)
json_elements_to_remove.add(elem.getparent().getparent())
+ elif (encryption_type_url == "http://ns.adobe.com/adept/xmlenc#aes128-cbc-uncompressed"):
+ # Adobe uncompressed, for stuff like video files
+ path = path.encode('utf-8')
+ encryptedForceNoDecomp.add(path)
+ json_elements_to_remove.add(elem.getparent().getparent())
else:
path = path.encode('utf-8')
otherData.add(path)
@@ -134,14 +140,15 @@ class Decryptor(object):
return decompressed_bytes
def decrypt(self, path, data):
- if path.encode('utf-8') in self._encrypted:
+ if path.encode('utf-8') in self._encrypted or path.encode('utf-8') in self._encryptedForceNoDecomp:
data = self._aes.decrypt(data)[16:]
if type(data[-1]) != int:
place = ord(data[-1])
else:
place = data[-1]
data = data[:-place]
- data = self.decompress(data)
+ if not path.encode('utf-8') in self._encryptedForceNoDecomp:
+ data = self.decompress(data)
return data
# check file to make check whether it's probably an Adobe Adept encrypted ePub