mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-06-27 19:55:38 +02:00
Fix for key decryption failure
This commit is contained in:
parent
f6b14efc5a
commit
1c8b6531e6
|
@ -329,7 +329,7 @@ def _load_crypto_pycrypto():
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def decrypt(self, data):
|
def decrypt(self, data):
|
||||||
return _PKCS1_v1_5.new(self._rsa).decrypt(data, 172)
|
return _PKCS1_v1_5.new(self._rsa).decrypt(data, b'')
|
||||||
|
|
||||||
return (AES, RSA)
|
return (AES, RSA)
|
||||||
|
|
||||||
|
@ -466,6 +466,12 @@ def adeptGetUserUUID(inpath):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def verify_book_key(bookkey):
|
def verify_book_key(bookkey):
|
||||||
|
if len(bookkey) < 16:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if len(bookkey) == 16:
|
||||||
|
return True
|
||||||
|
|
||||||
if bookkey[-17] != '\x00' and bookkey[-17] != 0:
|
if bookkey[-17] != '\x00' and bookkey[-17] != 0:
|
||||||
# Byte not null, invalid result
|
# Byte not null, invalid result
|
||||||
return False
|
return False
|
||||||
|
@ -523,9 +529,9 @@ def decryptBook(userkey, inpath, outpath):
|
||||||
bookkey = rsa.decrypt(base64.b64decode(bookkey.encode('ascii')))
|
bookkey = rsa.decrypt(base64.b64decode(bookkey.encode('ascii')))
|
||||||
|
|
||||||
# Verify key:
|
# Verify key:
|
||||||
|
if verify_book_key(bookkey):
|
||||||
if len(bookkey) > 16:
|
if len(bookkey) > 16:
|
||||||
# Padded as per RSAES-PKCS1-v1_5
|
# Padded as per RSAES-PKCS1-v1_5
|
||||||
if verify_book_key(bookkey):
|
|
||||||
bookkey = bookkey[-16:]
|
bookkey = bookkey[-16:]
|
||||||
else:
|
else:
|
||||||
print("Could not decrypt {0:s}. Wrong key".format(os.path.basename(inpath)))
|
print("Could not decrypt {0:s}. Wrong key".format(os.path.basename(inpath)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user