-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathtest_xsalsa20.py
More file actions
32 lines (29 loc) · 933 Bytes
/
test_xsalsa20.py
File metadata and controls
32 lines (29 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright 2018 Google LLC
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import paths
def parse():
d = {}
with (paths.top / "test_vectors" / "other" / "xsalsa20.txt").open() as f:
for l in f:
l = l.strip()
if l:
k, v = l.strip().split("=", 1)
d[k] = v
elif d:
yield d
d = {}
yield d
def test_vectors(x):
for d in parse():
bd = {k: bytes.fromhex(d[k]) for k in ["KEY", "IV", "PLAINTEXT", "CIPHERTEXT"]}
x.set_rounds_keylen(20, len(bd["KEY"]))
yield {
'cipher': x.variant,
'description': d['COUNT'],
'input': {'key': bd["KEY"], 'nonce': bd["IV"]},
'plaintext': bd["PLAINTEXT"],
'ciphertext': bd["CIPHERTEXT"],
}