check testvectors
这个提交包含在:
父节点
dd445c1513
当前提交
f7fb850ecf
@ -4,6 +4,7 @@ version: https://github.com/pq-crystals/kyber/commit/ab996e7460e5356b0e23aa034e7
|
||||
claimed-nist-level: 3
|
||||
length-public-key: 1088
|
||||
length-ciphertext: 1152
|
||||
testvectors-sha3-256: 0xF3D335A7C393083F11F2D9EF4D7312ADB5683139473EA9BDF0091618476BA412
|
||||
principal-submitter: Peter Schwabe
|
||||
auxiliary-submitters:
|
||||
- Roberto Avanzi
|
||||
|
@ -4,6 +4,7 @@ version: https://github.com/pq-crystals/dilithium/commit/ffa89bdbc12a8ee178ccec4
|
||||
claimed-nist-level: 3
|
||||
length-public-key: 1472
|
||||
length-signature: 2701
|
||||
testvectors-sha3-256: 0xCE28BBD23C2AC42C7F9A17A4FA463DC9F8ACBF767397AD4ECDE136A92D4D6C3E
|
||||
principal-submitter: Vadim Lyubashevsky
|
||||
auxiliary-submitters:
|
||||
- Léo Ducas
|
||||
|
1
requirements.txt
普通文件
1
requirements.txt
普通文件
@ -0,0 +1 @@
|
||||
PyYAML==3.13
|
38
test/check_testvectors.py
可执行文件
38
test/check_testvectors.py
可执行文件
@ -0,0 +1,38 @@
|
||||
import yaml
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import hashlib
|
||||
|
||||
"""
|
||||
For a given SCHEME, this script verifies that the hash of the testvectors
|
||||
produced on this platform matches the one provided in the META file.
|
||||
"""
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Provide a scheme name (e.g. crypto_kem/kyber768) as argv[1]")
|
||||
exit(1)
|
||||
|
||||
SCHEME = sys.argv[1]
|
||||
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
|
||||
SCHEMESHORT = SCHEME.split('/')[1].upper()
|
||||
|
||||
def get_hash(scheme):
|
||||
with open(f"{scheme}/META.yml", 'r') as stream:
|
||||
meta = yaml.load(stream)
|
||||
return hex(meta['testvectors-sha3-256']).replace('0x', '')
|
||||
|
||||
|
||||
expectedTestvectorsHash = get_hash(SCHEME)
|
||||
|
||||
subprocess.run(["make", "testvectors", f"SCHEME={SCHEME}"])
|
||||
implementations = [x for x in os.listdir('bin') if 'testvectors' in x and SCHEMEFULL in x]
|
||||
|
||||
for impl in implementations:
|
||||
testvectors = subprocess.run([f"bin/{impl}"],stdout=subprocess.PIPE)
|
||||
testvectorsHash = hashlib.sha3_256(testvectors.stdout).hexdigest()
|
||||
if testvectorsHash.lower() != expectedTestvectorsHash.lower():
|
||||
print(f"testvectors of {SCHEME} should be {expectedTestvectorsHash}, but is {testvectorsHash}")
|
||||
sys.exit(1)
|
||||
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户