From 8269e5c3966f498d7daec7a17a554e10b6464faf Mon Sep 17 00:00:00 2001 From: tuxxy Date: Tue, 10 Oct 2017 16:14:49 -0600 Subject: [PATCH] Add test for keccak_digest --- tests/crypto/test_crypto.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/crypto/test_crypto.py b/tests/crypto/test_crypto.py index 342873b6a..a8dff7a38 100644 --- a/tests/crypto/test_crypto.py +++ b/tests/crypto/test_crypto.py @@ -1,5 +1,6 @@ import unittest import random +import sha3 from nacl.utils import EncryptedMessage from npre import umbral from npre import elliptic_curve as ec @@ -42,6 +43,23 @@ class TestCrypto(unittest.TestCase): self.assertNotIn(2, output) self.assertIn(1, output) + def test_keccak_digest(self): + data = b'this is a test' + + digest1 = sha3.keccak_256(data).digest() + digest2 = Crypto.keccak_digest(data) + + self.assertEqual(digest1, digest2) + + # Test iterables + data = data.split() + + digest1 = sha3.keccak_256(b''.join(data)).digest() + digest2 = Crypto.keccak_digest(*data) + + self.assertEqual(digest1, digest2) + + def test_symm_encrypt(self): key = random._urandom(32) plaintext = b'this is a test'