noDRM / DeDRM_tools

DeDRM tools for ebooks
7.37k stars 324 forks source link

Failed to decrypt with error: Failed to decrypt KFX DRM voucher with any key #631

Closed Gogglemex closed 2 months ago

Gogglemex commented 2 months ago

Question / bug report

I bought the graphical novel Monstress - volume 3 from Amazon Kindle, downloaded it to my pc and tried to remove the DRM by importing the book with 'Add a book' in Calibre. However, I am experiencing an issue that the voucher cannot be decrypted. Does anyone know why this error happens and how to fix it? Thanks in advance! And thanks to the contributors for maintaining this software!

Which version of Calibre are you running?

7.18

Which version of the DeDRM plugin are you running?

v10.0.9

If applicable, which version of the Kindle software are you running?

2.5.0 (70951)

Log output

ApplicationPaletteChange event ignored
Using calibre Qt style: True
calibre Debug log
calibre 7.18  embedded-python: True
Windows-10-10.0.22631-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22631')
Python 3.11.5
Windows: ('10', '10.0.22631', 'SP0', 'Multiprocessor Free')
Interface language: None
EXE path: C:\Program Files\Calibre2\calibre-debug.exe
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 15, 0) && DeDRM (10, 0, 9) && Package KFX (from KFX Input) (2, 15, 0) && KFX metadata reader (from KFX Input) (2, 15, 0) && From KFX (2, 15, 0) && KFX Input (2, 15, 0)
calibre 7.18  embedded-python: True
Windows-10-10.0.22631-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22631')
Python 3.11.5
Windows: ('10', '10.0.22631', 'SP0', 'Multiprocessor Free')
Interface language: None
EXE path: C:\Program Files\Calibre2\calibre-debug.exe
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 15, 0) && DeDRM (10, 0, 9) && Package KFX (from KFX Input) (2, 15, 0) && KFX metadata reader (from KFX Input) (2, 15, 0) && From KFX (2, 15, 0) && KFX Input (2, 15, 0)
QPA platform: windows
devicePixelRatio: 1.5
logicalDpi: 96.0 x 96.0
physicalDpi: 126.04011627906975 x 126.05488372093023
[0.00] Starting up...
[0.00] Showing splash screen...
[1.16] splash screen shown
[1.16] Initializing db...
[1.19] db initialized
[1.19] Constructing main UI...
[2.19] GUI main window shown
[2.25] main UI initialized...
[2.25] Hiding splash screen
[2.25] splash screen hidden
[2.25] Started up in 2.25 seconds with 1 books
Gather KFX-ZIP (from KFX Input) 2.15.0: Importing C:\Users\Myname\Documents\My Kindle Content\B07GL8CMSN_EBOK\B07GL8CMSN_EBOK.azw
stdout+stderr from file dialog helper: [b'', b'']
piped data from file dialog helper: [b'\x9f\x98\xd7\nh\xb6\xad\xcbQ\xc3{\x8d\xb7\xf7\xcb\xdf\x12\\2\xfe\xb5\xda\xbaY"\\:\x8b2\xbb\xb2\xc5', b'C:\\Users\\Myname\\Documents\\My Kindle Content\\B07GL8CMSN_EBOK\\B07GL8CMSN_EBOK.azw']
Gather KFX-ZIP (from KFX Input): Gathered 44 file(s) as C:\Users\Myname\AppData\Local\Temp\calibre_tk7_wvih\2je1odox.kfx-zip
DeDRM v10.0.9: Trying to decrypt 2je1odox.kfx-zip
Decrypting KFX-ZIP ebook: 2je1odox
Found 0 keys to try after 0.6 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.22b4ead1-33c9-4105-a03d-8f0f02975f0b.voucher
Traceback (most recent call last):
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 104, in decrypt_voucher
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 1394, in parse
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 103, in _assert
Exception: Unknown type encountered in envelope, expected VoucherEnvelope
DeDRM v10.0.9: Failed to decrypt with error: Failed to decrypt KFX DRM voucher with any key
DeDRM v10.0.9: Looking for new default Kindle Key after 0.6 seconds
searching for kinfoFiles in C:\Users\Myname\AppData\Local
Found K4PC 1.25+ kinf2018 file: C:\Users\Myname\AppData\Local\Amazon\Kindle\storage\.kinf2018
Decrypted key file using IDString '1289678758' and UserName 'Myname'
DeDRM v10.0.9: Found 1 new key
Decrypting KFX-ZIP ebook: 2je1odox
Got DSN key from database key_0
Found 1 keys to try after 0.8 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.22b4ead1-33c9-4105-a03d-8f0f02975f0b.voucher
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\k4mobidedrm.py", line 203, in GetDecryptedBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 67, in processBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 111, in decrypt_voucher
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 104, in decrypt_voucher
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 1394, in parse
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 103, in _assert
Exception: Unknown type encountered in envelope, expected VoucherEnvelope
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\k4mobidedrm.py", line 203, in GetDecryptedBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 67, in processBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 111, in decrypt_voucher
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 104, in decrypt_voucher
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 1394, in parse
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\ion.py", line 103, in _assert
Exception: Unknown type encountered in envelope, expected VoucherEnvelope
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\k4mobidedrm.py", line 203, in GetDecryptedBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 67, in processBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 111, in decrypt_voucher
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 965, in KindleMobiDecrypt
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\k4mobidedrm.py", line 203, in GetDecryptedBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 67, in processBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 111, in decrypt_voucher
Exception: Failed to decrypt KFX DRM voucher with any key
DeDRM v10.0.9: Ultimately failed to decrypt after 0.8 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\k4mobidedrm.py", line 203, in GetDecryptedBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 67, in processBook
  File "C:\Users\Myname\AppData\Roaming\calibre\plugins\DeDRM.zip\kfxdedrm.py", line 111, in decrypt_voucher
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 199, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 1030, in run
  File "calibre_plugins.dedrm.__init__", line 981, in KindleMobiDecrypt
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.9: Ultimately failed to decrypt after 0.8 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Package KFX (from KFX Input) 2.15.0: Packaging C:\Users\Myname\AppData\Local\Temp\calibre_tk7_wvih\2je1odox.kfx-zip
Processing container: B07GL8CMSN_EBOK.azw
Running file type plugin Package KFX (from KFX Input) failed with traceback:
Traceback (most recent call last):
  File "calibre\customize\ui.py", line 199, in _run_filetype_plugins
  File "calibre_plugins.kfx_input.package_filetype", line 23, in run
  File "calibre_plugins.kfx_input.package_filetype", line 34, in package_kfx
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 79, in convert_to_single_kfx
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 212, in decode_book
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 321, in get_container
calibre_plugins.kfx_input.kfxlib.utilities.KFXDRMError: Book container B07GL8CMSN_EBOK.azw has DRM and cannot be converted
KFX metadata reader (from KFX Input) activated for C:\Users\Myname\AppData\Local\Temp\calibre_tk7_wvih\mpcm_anj_add_books\0\B07GL8CMSN_EBOK.kfx-zip
ElleKayEm commented 2 months ago

Go back to Kindle for PC 2.4.0 (70904) aka 2.4.70904. DeDRM stops working with newer versions. See info about blocking updates under method 2 here: https://www.mobileread.com/forums/showthread.php?t=361503

Gogglemex commented 2 months ago

@ElleKayEm Thank you very much for both a correct and quick answer!

For anyone else seeing similar issues, here is a link to the official 2.4.0 client: https://kindleforpc.s3.amazonaws.com/70904/KindleForPC-installer-2.4.70904.exe

After this, I had the issue that for my specific book the KFX format caused some conversions issues. Specifically this error:

image

Following the steps here from the OP: https://www.reddit.com/r/Calibre/comments/1e9qmu2/comment/lehsxb3/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

This will lead you to not use Calibre conversion but rather the 'From KFX Input' tool to convert to other formats which does work. This allowed me to convert the book to .cvz with DRM removed so I can finally use other readers than the Kindle reader.

ElleKayEm commented 2 months ago

Thanks for the additional info.