def test_save(self): private_key = self.__crypto.generate_keys().private_key context = VirgilContext() vk = VirgilKey(context, private_key) alias = "virgil_key_test_save" km = DefaultKeyStorage() try: vk.save(alias) self.assertEqual(bytearray(private_key.value), km.load(alias)) finally: try: km.delete(alias) except IOError: pass
def test_load(self): km = KeyManager(self.__context) key_pair = self.__context.crypto.generate_keys() vk = VirgilKey(self.__context, key_pair.private_key) alias = "key_manager_test_load" try: vk.save(alias) self.assertEqual(vk._VirgilKey__private_key, km.load(alias)._VirgilKey__private_key) finally: try: ks = DefaultKeyStorage() ks.delete(alias) except IOError: pass
def test_save_with_passwd(self): private_key = self.__crypto.generate_keys().private_key context = VirgilContext() vk = VirgilKey(context, private_key) alias = "virgil_key_test_save" km = DefaultKeyStorage() try: vk.save(alias, "SomeCoolPass") self.assertEqual( private_key.value, self.__crypto.import_private_key(bytearray(km.load(alias)), "SomeCoolPass").value) finally: try: km.delete(alias) except IOError: pass