mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-26 09:21:28 +00:00
Ensure Python3.5 compatibility
This means we must downgrade to SHA256, as SHA3 is not in hashlib.
This commit is contained in:
parent
98d54e42fa
commit
5d5b6f26a3
8
Makefile
8
Makefile
@ -150,22 +150,22 @@ run-valgrind-all:
|
|||||||
|
|
||||||
.PHONY: run-testvectors
|
.PHONY: run-testvectors
|
||||||
run-testvectors: test/check_testvectors.py | require_scheme
|
run-testvectors: test/check_testvectors.py | require_scheme
|
||||||
python3.7 test/check_testvectors.py $(SCHEME) || exit 1; \
|
python3 test/check_testvectors.py $(SCHEME) || exit 1; \
|
||||||
|
|
||||||
.PHONY: run-symbol-namespace
|
.PHONY: run-symbol-namespace
|
||||||
run-symbol-namespace: test/check_symbol_namespace.py | require_scheme
|
run-symbol-namespace: test/check_symbol_namespace.py | require_scheme
|
||||||
python3.7 test/check_symbol_namespace.py $(SCHEME) || exit 1; \
|
python3 test/check_symbol_namespace.py $(SCHEME) || exit 1; \
|
||||||
|
|
||||||
.PHONY: run-testvectors-all
|
.PHONY: run-testvectors-all
|
||||||
run-testvectors-all: test/check_testvectors.py
|
run-testvectors-all: test/check_testvectors.py
|
||||||
@for scheme in $(ALL_SCHEMES); do \
|
@for scheme in $(ALL_SCHEMES); do \
|
||||||
python3.7 test/check_testvectors.py $$scheme || exit 1; \
|
python3 test/check_testvectors.py $$scheme || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: run-symbol-namespace-all
|
.PHONY: run-symbol-namespace-all
|
||||||
run-symbol-namespace-all:
|
run-symbol-namespace-all:
|
||||||
@for scheme in $(ALL_SCHEMES); do \
|
@for scheme in $(ALL_SCHEMES); do \
|
||||||
python3.7 test/check_symbol_namespace.py $$scheme || exit 1; \
|
python3 test/check_symbol_namespace.py $$scheme || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: run-functest-all
|
.PHONY: run-functest-all
|
||||||
|
@ -4,7 +4,8 @@ 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
|
testvectors-sha3-256: f3d335a7c393083f11f2d9ef4d7312adb5683139473ea9bdf0091618476ba412
|
||||||
|
testvectors-sha256: 0e002ee528febdab1709f100df79ceb00b31a809e03a4fb84e3a72c39235d372
|
||||||
principal-submitter: Peter Schwabe
|
principal-submitter: Peter Schwabe
|
||||||
auxiliary-submitters:
|
auxiliary-submitters:
|
||||||
- Roberto Avanzi
|
- Roberto Avanzi
|
||||||
|
@ -4,7 +4,8 @@ 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
|
testvectors-sha3-256: ce28bbd23c2ac42c7f9a17a4fa463dc9f8acbf767397ad4ecde136a92d4d6c3e
|
||||||
|
testvectors-sha256: e1852a975842c44a683c914ed131d95bee9b786c36c41e47bb77d7dd3c0c07be
|
||||||
principal-submitter: Vadim Lyubashevsky
|
principal-submitter: Vadim Lyubashevsky
|
||||||
auxiliary-submitters:
|
auxiliary-submitters:
|
||||||
- Léo Ducas
|
- Léo Ducas
|
||||||
|
@ -13,12 +13,12 @@ if len(sys.argv) != 2:
|
|||||||
SCHEME = sys.argv[1]
|
SCHEME = sys.argv[1]
|
||||||
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
|
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
|
||||||
SCHEMESHORT = SCHEME.split('/')[1].upper()
|
SCHEMESHORT = SCHEME.split('/')[1].upper()
|
||||||
namespace = f"PQCLEAN_{SCHEMESHORT}_".replace('-', '')
|
namespace = "PQCLEAN_{}_".format(SCHEMESHORT).replace('-', '')
|
||||||
|
|
||||||
# TODO can we do this using object files instead, to preserve file origin?
|
# TODO can we do this using object files instead, to preserve file origin?
|
||||||
sharedlib = "bin/shared_{}_clean.so".format(SCHEMEFULL)
|
sharedlib = "bin/shared_{}_clean.so".format(SCHEMEFULL)
|
||||||
subprocess.run(["make", sharedlib, "SCHEME={}".format(SCHEME)])
|
subprocess.run(["make", sharedlib, "SCHEME={}".format(SCHEME)])
|
||||||
p = subprocess.run(["nm", "-D", sharedlib], capture_output=True)
|
p = subprocess.run(["nm", "-D", sharedlib], stdout=subprocess.PIPE)
|
||||||
|
|
||||||
symbols = p.stdout.decode('utf-8').strip().split("\n")
|
symbols = p.stdout.decode('utf-8').strip().split("\n")
|
||||||
non_namespaced = []
|
non_namespaced = []
|
||||||
|
@ -21,7 +21,7 @@ SCHEMESHORT = SCHEME.split('/')[1].upper()
|
|||||||
def get_hash(scheme):
|
def get_hash(scheme):
|
||||||
with open("{}/META.yml".format(scheme), 'r') as stream:
|
with open("{}/META.yml".format(scheme), 'r') as stream:
|
||||||
meta = yaml.load(stream)
|
meta = yaml.load(stream)
|
||||||
return hex(meta['testvectors-sha3-256']).replace('0x', '')
|
return meta['testvectors-sha256']
|
||||||
|
|
||||||
|
|
||||||
expectedTestvectorsHash = get_hash(SCHEME)
|
expectedTestvectorsHash = get_hash(SCHEME)
|
||||||
@ -33,7 +33,7 @@ implementations = [
|
|||||||
for impl in implementations:
|
for impl in implementations:
|
||||||
testvectors = subprocess.run(["bin/{}".format(impl)],
|
testvectors = subprocess.run(["bin/{}".format(impl)],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
testvectorsHash = hashlib.sha3_256(testvectors.stdout).hexdigest()
|
testvectorsHash = hashlib.sha256(testvectors.stdout).hexdigest()
|
||||||
if testvectorsHash.lower() != expectedTestvectorsHash.lower():
|
if testvectorsHash.lower() != expectedTestvectorsHash.lower():
|
||||||
print("testvectors of {} should be {}, but is {}"
|
print("testvectors of {} should be {}, but is {}"
|
||||||
.format(SCHEME, expectedTestvectorsHash, testvectorsHash))
|
.format(SCHEME, expectedTestvectorsHash, testvectorsHash))
|
||||||
|
Loading…
Reference in New Issue
Block a user