-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import zlib | ||
|
||
from wa_crypt_tools.lib.key.key15 import Key15 | ||
from wa_crypt_tools.lib.key.key14 import Key14 | ||
from wa_crypt_tools.lib.key.keyfactory import KeyFactory | ||
from wa_crypt_tools.lib.props import Props | ||
from hashlib import sha512 | ||
|
||
class Test_CreateKey: | ||
def test_createkey(self): | ||
key: Key15 = Key15(key= | ||
bytes.fromhex( | ||
'6730a595a1484d0c39c101dc0ac82ec5e401bb6f0e1b8ee2dc104a6b3687f017' | ||
)) | ||
keyb: bytes = key.dump() | ||
keyb_digest = sha512(keyb).digest() | ||
with open("tests/res/encrypted_backup.key", 'rb') as f: | ||
orig_check = sha512(f.read()).digest() | ||
assert keyb_digest == orig_check | ||
|
||
def test_createkey14(self): | ||
key: Key14 = Key14(key= | ||
bytes.fromhex( | ||
'3a146d9bbd8b6311d962c71619c0c2cce3ce694ea4a0f3f600e271380e1226c6' | ||
), | ||
serversalt=bytes.fromhex('cd788b1b4625f50d3fccdeac94e1ff638899733b77a224ff614918363901f044'), | ||
googleid=bytes.fromhex('92683e735c88727eef9486911f3ac6fa'), | ||
key_version=b'\x02', | ||
cipher_version=b'\x00\x01') | ||
keyb: bytes = key.dump() | ||
keyb_digest = sha512(keyb).digest() | ||
with open("tests/res/key", 'rb') as f: | ||
orig_check = sha512(f.read()).digest() | ||
assert keyb_digest == orig_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
import zlib | ||
|
||
from wa_crypt_tools.lib.db.db12 import Database12 | ||
from wa_crypt_tools.lib.db.db14 import Database14 | ||
from wa_crypt_tools.lib.db.db15 import Database15 | ||
from wa_crypt_tools.lib.db.dbfactory import DatabaseFactory | ||
from wa_crypt_tools.lib.key.keyfactory import KeyFactory | ||
from wa_crypt_tools.lib.props import Props | ||
from hashlib import sha512 | ||
|
||
class Test_Decryption: | ||
def test_decryption15(self): | ||
key = KeyFactory.new("tests/res/encrypted_backup.key") | ||
f = open("tests/res/msgstore.db.crypt15",'rb') | ||
db = DatabaseFactory.from_file(f) | ||
encrypted = f.read() | ||
decrypted_db = db.decrypt(key, encrypted) | ||
decrypted_db = zlib.decompress(decrypted_db) | ||
new_check = sha512(decrypted_db).digest() | ||
with open("tests/res/msgstore.db", 'rb') as f: | ||
orig_check = sha512(f.read()).digest() | ||
assert new_check == orig_check | ||
|
||
def test_decryption14(self): | ||
key = KeyFactory.new("tests/res/key") | ||
f = open("tests/res/msgstore.db.crypt14",'rb') | ||
db = DatabaseFactory.from_file(f) | ||
encrypted = f.read() | ||
decrypted_db = db.decrypt(key, encrypted) | ||
decrypted_db = zlib.decompress(decrypted_db) | ||
new_check = sha512(decrypted_db).digest() | ||
with open("tests/res/msgstore.db", 'rb') as f: | ||
orig_check = sha512(f.read()).digest() | ||
assert new_check == orig_check | ||
|
||
def test_decryption12(self): | ||
key = KeyFactory.new("tests/res/key") | ||
f = open("tests/res/msgstore.db.crypt12",'rb') | ||
db = DatabaseFactory.from_file(f) | ||
encrypted = f.read() | ||
decrypted_db = db.decrypt(key, encrypted) | ||
decrypted_db = zlib.decompress(decrypted_db) | ||
new_check = sha512(decrypted_db).digest() | ||
with open("tests/res/msgstore.db", 'rb') as f: | ||
orig_check = sha512(f.read()).digest() | ||
assert new_check == orig_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters