aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/muhash.py
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-07-09 13:43:35 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-07-16 18:10:48 +0200
commit36ec9801a4edb9663ef9ce9ad298233766b903e8 (patch)
tree74595e0d0f9420bb966c667412b0c9d655fbc2bc /test/functional/test_framework/muhash.py
parent0e2b400fea890e769b75da5b55fa1902fd9f9851 (diff)
downloadbitcoin-36ec9801a4edb9663ef9ce9ad298233766b903e8.tar.xz
test: Add chacha20 test vectors in muhash
Diffstat (limited to 'test/functional/test_framework/muhash.py')
-rw-r--r--test/functional/test_framework/muhash.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/test_framework/muhash.py b/test/functional/test_framework/muhash.py
index 70a3cc53a0..97d02359cb 100644
--- a/test/functional/test_framework/muhash.py
+++ b/test/functional/test_framework/muhash.py
@@ -99,3 +99,12 @@ class TestFrameworkMuhash(unittest.TestCase):
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")