Skip to content

Commit

Permalink
test: Add chacha20 test vectors in muhash
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Jul 16, 2020
1 parent 0e2b400 commit 36ec980
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/functional/test_framework/muhash.py
Expand Up @@ -99,3 +99,12 @@ def test_muhash(self):
finalized = muhash.digest()
# This mirrors the result in the C++ MuHash3072 unit test
self.assertEqual(finalized[::-1].hex(), "a44e16d5e34d259b349af21c06e65d653915d2e208e4e03f389af750dc0bfdc3")

def test_chacha20(self):
def chacha_check(key, result):
self.assertEqual(chacha20_32_to_384(key)[:64].hex(), result)

# Test vectors from https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
# Since the nonce is hardcoded to 0 in our function we only use those vectors.
chacha_check([0]*32, "76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586")
chacha_check([0]*31 + [1], "4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea817e9ad275ae546963")

0 comments on commit 36ec980

Please sign in to comment.