Skip to content

Commit 36ec980

Browse files
committed
test: Add chacha20 test vectors in muhash
1 parent 0e2b400 commit 36ec980

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/test_framework/muhash.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,12 @@ def test_muhash(self):
9999
finalized = muhash.digest()
100100
# This mirrors the result in the C++ MuHash3072 unit test
101101
self.assertEqual(finalized[::-1].hex(), "a44e16d5e34d259b349af21c06e65d653915d2e208e4e03f389af750dc0bfdc3")
102+
103+
def test_chacha20(self):
104+
def chacha_check(key, result):
105+
self.assertEqual(chacha20_32_to_384(key)[:64].hex(), result)
106+
107+
# Test vectors from https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
108+
# Since the nonce is hardcoded to 0 in our function we only use those vectors.
109+
chacha_check([0]*32, "76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586")
110+
chacha_check([0]*31 + [1], "4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea817e9ad275ae546963")

0 commit comments

Comments
 (0)