From c15135b12ff2a0944f456314fa801d5881c2b161 Mon Sep 17 00:00:00 2001 From: NoDRM Date: Sat, 16 Jul 2022 09:48:27 +0200 Subject: [PATCH] Fix RSA.import_key (fixes #101) Apparently "import_key" only exists in newer versions (as an alias to "importKey"). "importKey" works in all versions ... --- CHANGELOG.md | 2 +- DeDRM_plugin/ineptepub.py | 2 +- DeDRM_plugin/ineptpdf.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e206d76..8d48de7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,4 +69,4 @@ List of changes since the fork of Apprentice Harper's repository: ## Fixes on master (not yet released): -- (None) \ No newline at end of file +- Fix a bug introduced with #48 that breaks DeDRM'ing on Calibre 4 (fixes #101). \ No newline at end of file diff --git a/DeDRM_plugin/ineptepub.py b/DeDRM_plugin/ineptepub.py index b9ec149..6b4b676 100644 --- a/DeDRM_plugin/ineptepub.py +++ b/DeDRM_plugin/ineptepub.py @@ -302,7 +302,7 @@ def decryptBook(userkey, inpath, outpath): if len(bookkey) != 64: # Normal or "hardened" Adobe ADEPT - rsakey = RSA.import_key(userkey) # parses the ASN1 structure + rsakey = RSA.importKey(userkey) # parses the ASN1 structure bookkey = base64.b64decode(bookkey) if int(keytype, 10) > 2: bookkey = removeHardening(rights, keytype, bookkey) diff --git a/DeDRM_plugin/ineptpdf.py b/DeDRM_plugin/ineptpdf.py index 24fc150..7a14750 100755 --- a/DeDRM_plugin/ineptpdf.py +++ b/DeDRM_plugin/ineptpdf.py @@ -1669,7 +1669,7 @@ class PDFDocument(object): def initialize_ebx_inept(self, password, docid, param): self.is_printable = self.is_modifiable = self.is_extractable = True - rsakey = RSA.import_key(password) # parses the ASN1 structure + rsakey = RSA.importKey(password) # parses the ASN1 structure length = int_value(param.get('Length', 0)) // 8 rights = codecs.decode(param.get('ADEPT_LICENSE'), 'base64') rights = zlib.decompress(rights, -15)