def test_encrypt_decrypt(self):
'''
Tests encrypting and decrypting the shares
'''
DummyPKI = DummyEncryptionPKI()
expressions = ['a&b',
'a&b&c',
'a|b',
'a|b|c',
'(a&b)|c',
'(a|b)&c',
'a|(b&c)',
'a&(b|c)',
'(a&b)|(b&c)',
'(a|b)&(c|d)']
for e in expressions:
secret = Random.get_random_bytes(16)
encrypted_shares = SecretVisTreeEncryptor.encrypt_secret_shares(e,
secret,
Keytor('VIS_AES_CBC',DummyPKI,16),
Pycrypto_AES_CBC)
share = SecretVisTreeEncryptor.decrypt_secret_shares(e,
encrypted_shares,
Keytor('VIS_AES_CBC',DummyPKI,16),
Pycrypto_AES_CBC)
self.assertEqual(share, secret)
评论列表
文章目录