refactor testvector check
这个提交包含在:
父节点
f7fb850ecf
当前提交
8c68841417
16
test/check_testvectors.py
可执行文件 -> 普通文件
16
test/check_testvectors.py
可执行文件 -> 普通文件
@ -18,9 +18,9 @@ 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', '')
|
||||
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)
|
||||
@ -29,10 +29,10 @@ 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)
|
||||
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)
|
||||
|
||||
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户