mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-12-27 19:47:40 +06:00
Support for Adobe's 'aes128-cbc-uncompressed' encryption (see #242)
This commit is contained in:
parent
3c12806f38
commit
fb8b003444
@ -87,3 +87,5 @@ List of changes since the fork of Apprentice Harper's repository:
|
|||||||
- Obok: Fix where changing the Calibre UI language to some languages would cause the "duplicate book" setting to reset.
|
- Obok: Fix where changing the Calibre UI language to some languages would cause the "duplicate book" setting to reset.
|
||||||
- Fix Python3 bug in stylexml2css.php script, fixes #232.
|
- Fix Python3 bug in stylexml2css.php script, fixes #232.
|
||||||
- PDF: Ignore invalid PDF objids unless the script is running in strict mode. Fixes some PDFs, apparently. Fixes #233.
|
- PDF: Ignore invalid PDF objids unless the script is running in strict mode. Fixes some PDFs, apparently. Fixes #233.
|
||||||
|
- Bugfix: EPUBs with remaining content in the encryption.xml after decryption weren't written correctly.
|
||||||
|
- Support for Adobe's 'aes128-cbc-uncompressed' encryption method (fixes #242).
|
||||||
|
@ -91,6 +91,7 @@ class Decryptor(object):
|
|||||||
self._aes = AES.new(bookkey, AES.MODE_CBC, b'\x00'*16)
|
self._aes = AES.new(bookkey, AES.MODE_CBC, b'\x00'*16)
|
||||||
self._encryption = etree.fromstring(encryption)
|
self._encryption = etree.fromstring(encryption)
|
||||||
self._encrypted = encrypted = set()
|
self._encrypted = encrypted = set()
|
||||||
|
self._encryptedForceNoDecomp = encryptedForceNoDecomp = set()
|
||||||
self._otherData = otherData = set()
|
self._otherData = otherData = set()
|
||||||
|
|
||||||
self._json_elements_to_remove = json_elements_to_remove = set()
|
self._json_elements_to_remove = json_elements_to_remove = set()
|
||||||
@ -106,6 +107,11 @@ class Decryptor(object):
|
|||||||
path = path.encode('utf-8')
|
path = path.encode('utf-8')
|
||||||
encrypted.add(path)
|
encrypted.add(path)
|
||||||
json_elements_to_remove.add(elem.getparent().getparent())
|
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:
|
else:
|
||||||
path = path.encode('utf-8')
|
path = path.encode('utf-8')
|
||||||
otherData.add(path)
|
otherData.add(path)
|
||||||
@ -134,13 +140,14 @@ class Decryptor(object):
|
|||||||
return decompressed_bytes
|
return decompressed_bytes
|
||||||
|
|
||||||
def decrypt(self, path, data):
|
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:]
|
data = self._aes.decrypt(data)[16:]
|
||||||
if type(data[-1]) != int:
|
if type(data[-1]) != int:
|
||||||
place = ord(data[-1])
|
place = ord(data[-1])
|
||||||
else:
|
else:
|
||||||
place = data[-1]
|
place = data[-1]
|
||||||
data = data[:-place]
|
data = data[:-place]
|
||||||
|
if not path.encode('utf-8') in self._encryptedForceNoDecomp:
|
||||||
data = self.decompress(data)
|
data = self.decompress(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user