Skip to content

Commit

Permalink
add python unittests that check the compatibility with bytes generate…
Browse files Browse the repository at this point in the history
…d on iOS 17, but OpenSSL 1.1 (#1021)
  • Loading branch information
radetsky committed Sep 5, 2024
1 parent 19c663e commit 0f47f5f
Showing 1 changed file with 42 additions and 0 deletions.
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

0 comments on commit 0f47f5f

Please sign in to comment.