From d1a2177f195cb8336da60c6114ca0ce2f4758af0 Mon Sep 17 00:00:00 2001 From: Imelstorm Date: Thu, 8 Aug 2019 11:57:19 +0300 Subject: [PATCH] Renamed sign_then_encrypt -> sign_and_encrypt and decrypt_then_verify -> decrypt_and_verify --- virgil_crypto/crypto.py | 4 ++-- virgil_crypto/tests/compatibility_test.py | 6 +++--- virgil_crypto/tests/crypto_test.py | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/virgil_crypto/crypto.py b/virgil_crypto/crypto.py index 5d6c22d..5268c8e 100644 --- a/virgil_crypto/crypto.py +++ b/virgil_crypto/crypto.py @@ -288,7 +288,7 @@ def decrypt(data, private_key): result += cipher.finish_decryption() return result - def sign_then_encrypt(self, data, private_key, *recipients): + def sign_and_encrypt(self, data, private_key, *recipients): # type: (Union[Tuple[int], List[int], bytearray], VirgilPrivateKey, List[VirgilPublicKey]) -> Union[Tuple[int], bytearray] """Signs and encrypts the data. @@ -323,7 +323,7 @@ def sign_then_encrypt(self, data, private_key, *recipients): return result - def decrypt_then_verify(self, data, private_key, signers_public_keys): + def decrypt_and_verify(self, data, private_key, signers_public_keys): # type: (Union[Tuple[int], List[int], bytearray], VirgilPrivateKey, Union[List[VirgilPublicKey], VirgilPublicKey]) -> Union[Tuple[int], bytearray] """Decrypts and verifies the data. diff --git a/virgil_crypto/tests/compatibility_test.py b/virgil_crypto/tests/compatibility_test.py index 796ec19..5d218db 100644 --- a/virgil_crypto/tests/compatibility_test.py +++ b/virgil_crypto/tests/compatibility_test.py @@ -73,7 +73,7 @@ def test_sign_then_encrypt_single_recipient(self): data = self._compatibility_data["sign_then_encrypt_single_recipient"] private_key = self._crypto.import_private_key(data["private_key"]).private_key public_key = self._crypto.extract_public_key(private_key) - decrypted_data = self._crypto.decrypt_then_verify( + decrypted_data = self._crypto.decrypt_and_verify( data["cipher_data"], private_key, public_key @@ -87,7 +87,7 @@ def test_sign_then_encrypt_multiple_recipients(self): self.assertGreater(len(private_keys), 0) public_key = self._crypto.extract_public_key(private_keys[0]) for private_key in private_keys: - decrypted_data = self._crypto.decrypt_then_verify( + decrypted_data = self._crypto.decrypt_and_verify( data["cipher_data"], private_key, public_key @@ -111,7 +111,7 @@ def test_decrypt_then_verify_multiple_signers(self): data = self._compatibility_data["sign_then_encrypt_multiple_signers"] private_key = self._crypto.import_private_key(data["private_key"]).private_key public_keys = [self._crypto.import_public_key(pk) for pk in data["public_keys"]] - decrypted_data = self._crypto.decrypt_then_verify( + decrypted_data = self._crypto.decrypt_and_verify( data["cipher_data"], private_key, public_keys diff --git a/virgil_crypto/tests/crypto_test.py b/virgil_crypto/tests/crypto_test.py index f9739df..aefcdb1 100644 --- a/virgil_crypto/tests/crypto_test.py +++ b/virgil_crypto/tests/crypto_test.py @@ -105,13 +105,13 @@ def __check_sign_then_encrypt(self, key_pair_type): data = bytearray("test data".encode()) - encrypted = self._crypto().sign_then_encrypt(data, key_pair_1.private_key, key_pair_1.public_key, key_pair_2.public_key) - decrypted = self._crypto().decrypt_then_verify(encrypted, key_pair_2.private_key, [key_pair_1.public_key, key_pair_2.public_key]) + encrypted = self._crypto().sign_and_encrypt(data, key_pair_1.private_key, key_pair_1.public_key, key_pair_2.public_key) + decrypted = self._crypto().decrypt_and_verify(encrypted, key_pair_2.private_key, [key_pair_1.public_key, key_pair_2.public_key]) self.assertEqual(data, decrypted) - self.assertRaises(VirgilCryptoFoundationError, self._crypto().decrypt_then_verify, encrypted, key_pair_3.private_key, [key_pair_1.public_key, key_pair_2.public_key]) - self.assertRaises(VirgilCryptoError, self._crypto().decrypt_then_verify, encrypted, key_pair_2.private_key, key_pair_3.public_key) + self.assertRaises(VirgilCryptoFoundationError, self._crypto().decrypt_and_verify, encrypted, key_pair_3.private_key, [key_pair_1.public_key, key_pair_2.public_key]) + self.assertRaises(VirgilCryptoError, self._crypto().decrypt_and_verify, encrypted, key_pair_2.private_key, key_pair_3.public_key) def __check_stream_sign(self, key_pair_type): key_pair_1 = self._crypto().generate_key_pair(key_pair_type) @@ -442,13 +442,13 @@ def test_sign_then_encrypt(self): key_pair_3 = crypto.generate_key_pair() data = [1, 2, 3] - cipher_data = crypto.sign_then_encrypt(data, key_pair_1.private_key, key_pair_2.public_key) + cipher_data = crypto.sign_and_encrypt(data, key_pair_1.private_key, key_pair_2.public_key) - decrypted_data = crypto.decrypt_then_verify(cipher_data, key_pair_2.private_key, [key_pair_1.public_key, key_pair_2.public_key]) + decrypted_data = crypto.decrypt_and_verify(cipher_data, key_pair_2.private_key, [key_pair_1.public_key, key_pair_2.public_key]) self.assertEqual(data, list(decrypted_data)) - self.assertRaises(VirgilCryptoError, crypto.decrypt_then_verify, cipher_data, key_pair_2.private_key, key_pair_3.public_key) + self.assertRaises(VirgilCryptoError, crypto.decrypt_and_verify, cipher_data, key_pair_2.private_key, key_pair_3.public_key) def test_generate_key_using_seed(self): crypto = VirgilCrypto()