mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 15:39:07 +00:00
check testvectors
This commit is contained in:
parent
dd445c1513
commit
f7fb850ecf
@ -4,6 +4,7 @@ version: https://github.com/pq-crystals/kyber/commit/ab996e7460e5356b0e23aa034e7
|
|||||||
claimed-nist-level: 3
|
claimed-nist-level: 3
|
||||||
length-public-key: 1088
|
length-public-key: 1088
|
||||||
length-ciphertext: 1152
|
length-ciphertext: 1152
|
||||||
|
testvectors-sha3-256: 0xF3D335A7C393083F11F2D9EF4D7312ADB5683139473EA9BDF0091618476BA412
|
||||||
principal-submitter: Peter Schwabe
|
principal-submitter: Peter Schwabe
|
||||||
auxiliary-submitters:
|
auxiliary-submitters:
|
||||||
- Roberto Avanzi
|
- Roberto Avanzi
|
||||||
|
@ -4,6 +4,7 @@ version: https://github.com/pq-crystals/dilithium/commit/ffa89bdbc12a8ee178ccec4
|
|||||||
claimed-nist-level: 3
|
claimed-nist-level: 3
|
||||||
length-public-key: 1472
|
length-public-key: 1472
|
||||||
length-signature: 2701
|
length-signature: 2701
|
||||||
|
testvectors-sha3-256: 0xCE28BBD23C2AC42C7F9A17A4FA463DC9F8ACBF767397AD4ECDE136A92D4D6C3E
|
||||||
principal-submitter: Vadim Lyubashevsky
|
principal-submitter: Vadim Lyubashevsky
|
||||||
auxiliary-submitters:
|
auxiliary-submitters:
|
||||||
- Léo Ducas
|
- Léo Ducas
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
PyYAML==3.13
|
38
test/check_testvectors.py
Executable file
38
test/check_testvectors.py
Executable file
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user