Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add python unittests to check compatibility #1021

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/pythemis/test_scell.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,48 @@
from pythemis.skeygen import GenerateSymmetricKey
from pythemis.exception import ThemisError

class CompatTestDecryptSymKeyTest(unittest.TestCase):
def setUp(self):
# This data was generated by Themis 0.15.1 (OpenSSL 1.1.1v) on Simulator iPhone 15 Pro with iOS 17, XCode 15
# Encrypt Hello Test::masterKey 661922e173fde186f834b47b6191fe75f9e82a083f6f0cf1f7076aa1a7d610b1
# Encrypt Hello Test::encrypted 000101400c0000001000000018000000047e491e00c03e6cae92eb0a87d8ed6bb1d1e227b7054d1af644c4c5a945296abe77f440c6692345cd79c609818de7b8245a1fab
self.ios_master_key = bytes.fromhex('661922e173fde186f834b47b6191fe75f9e82a083f6f0cf1f7076aa1a7d610b1')
self.ios_message = b'Hello, Themis!\nBuild #4;'
self.ios_encrypted_message = bytes.fromhex('000101400c0000001000000018000000047e491e00c03e6cae92eb0a87d8ed6bb1d1e227b7054d1af644c4c5a945296abe77f440c6692345cd79c609818de7b8245a1fab')
return super().setUp()

def test_decrypt_ios(self):
scell = SCellSeal(self.ios_master_key)
self.assertEqual(self.ios_message, scell.decrypt(self.ios_encrypted_message))

class CompatTestDecryptSymKeyCtxTest(unittest.TestCase):
def setUp(self):
# This data was generated by Themis 0.15.1 (OpenSSL 1.1.1v) on Simulator iPhone 15 Pro with iOS 17, XCode 15
# Encrypt Hello Test::masterKey 517ad939b402a8c2b7231d4b2a0cfe20f977c326fcdca19624fa0c236bab3a41
# Encrypt Hello Test::encrypted 000101400c0000001000000018000000570c73ba2a1a311c83e8b179202af4e4e472e69f6c09fc806f928007e461de0097f33ce7a112206a6856e98923bfb9129bd6cf5e
self.ios_master_key = bytes.fromhex('517ad939b402a8c2b7231d4b2a0cfe20f977c326fcdca19624fa0c236bab3a41')
self.ios_message = b'Hello, Themis!\nBuild #4;'
self.ios_context = b'context'
self.ios_encrypted_message = bytes.fromhex('000101400c0000001000000018000000570c73ba2a1a311c83e8b179202af4e4e472e69f6c09fc806f928007e461de0097f33ce7a112206a6856e98923bfb9129bd6cf5e')
return super().setUp()

def test_decrypt_ios(self):
scell = SCellSeal(self.ios_master_key)
self.assertEqual(self.ios_message, scell.decrypt(self.ios_encrypted_message, self.ios_context))

class CompatTestDecryptCtxPassphrase(unittest.TestCase):
def setUp(self) -> None:
# This data was generated by Themis 0.15.1 (OpenSSL 1.1.1v) on Simulator iPhone 15 Pro with iOS 17, XCode 15
self.ios_passphrase = 'passphrase'
self.ios_context = b'context'
self.ios_message = b'Hello, Themis!\nBuild #4;'
self.ios_encrypted_message = bytes.fromhex('000101410c000000100000001800000016000000bbcd07fca7f24d8da24443b1654e734ba6dcafc3cd2d65c173c4370cfeca04001000a3e2324b7df16a65ee4f5943da611813118697bdbab133b97e99387ba6b8b3f747a2901b4bf5439d')
return super().setUp()

def test_decrypt_ios(self):
scell = SCellSealPassphrase(self.ios_passphrase)
self.assertEqual(self.ios_message, scell.decrypt(self.ios_encrypted_message, self.ios_context))


class BaseSCellTestMixin(unittest.TestCase):
def setUp(self):
Expand Down
Loading