mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-26 09:21:28 +00:00
Move duplicate consistency data outside of META.yml
This commit is contained in:
parent
a296085e57
commit
46aa7ff9b2
@ -20,17 +20,3 @@ auxiliary-submitters:
|
|||||||
implementations:
|
implementations:
|
||||||
- name: clean
|
- name: clean
|
||||||
version: https://github.com/Microsoft/PQCrypto-LWEKE/commit/437e228fca580a82435cab09f30ae14b03183119
|
version: https://github.com/Microsoft/PQCrypto-LWEKE/commit/437e228fca580a82435cab09f30ae14b03183119
|
||||||
duplicate-consistency:
|
|
||||||
source_namespace: PQCLEAN_FRODOKEM640SHAKE_CLEAN_
|
|
||||||
target_namespace: PQCLEAN_FRODOKEM976SHAKE_CLEAN_
|
|
||||||
files:
|
|
||||||
- source_file: crypto_kem/frodokem640shake/clean/common.h
|
|
||||||
target_file: common.h
|
|
||||||
- source_file: crypto_kem/frodokem640shake/clean/kem.c
|
|
||||||
target_file: kem.c
|
|
||||||
- source_file: crypto_kem/frodokem640shake/clean/matrix_shake.c
|
|
||||||
target_file: matrix_shake.c
|
|
||||||
- source_file: crypto_kem/frodokem640shake/clean/noise.c
|
|
||||||
target_file: noise.c
|
|
||||||
- source_file: crypto_kem/frodokem640shake/clean/util.c
|
|
||||||
target_file: util.c
|
|
||||||
|
9
test/duplicate_consistency/frodokem976shake_clean.yml
Normal file
9
test/duplicate_consistency/frodokem976shake_clean.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
source:
|
||||||
|
scheme: frodokem640shake
|
||||||
|
implementation: clean
|
||||||
|
files:
|
||||||
|
- common.h
|
||||||
|
- kem.c
|
||||||
|
- matrix_shake.c
|
||||||
|
- noise.c
|
||||||
|
- util.c
|
@ -78,6 +78,9 @@ class Implementation:
|
|||||||
def path(self, base='..') -> str:
|
def path(self, base='..') -> str:
|
||||||
return os.path.join(self.scheme.path(), self.name)
|
return os.path.join(self.scheme.path(), self.name)
|
||||||
|
|
||||||
|
def namespace_prefix(self):
|
||||||
|
return 'PQCLEAN_{}_{}_'.format(self.scheme.name.upper(), self.name.upper()).replace('-', '')
|
||||||
|
|
||||||
def libname(self) -> str:
|
def libname(self) -> str:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
return "lib{}_{}.lib".format(self.scheme.name, self.name)
|
return "lib{}_{}.lib".format(self.scheme.name, self.name)
|
||||||
|
@ -6,12 +6,13 @@ import os
|
|||||||
import pqclean
|
import pqclean
|
||||||
import helpers
|
import helpers
|
||||||
import unittest
|
import unittest
|
||||||
|
import yaml
|
||||||
|
|
||||||
def test_duplicate_consistency():
|
def test_duplicate_consistency():
|
||||||
for scheme in pqclean.Scheme.all_schemes():
|
for scheme in pqclean.Scheme.all_schemes():
|
||||||
for implementation in scheme.implementations:
|
for implementation in scheme.implementations:
|
||||||
yield check_duplicate_consistency, implementation
|
if os.path.isfile(os.path.join('duplicate_consistency', '{}_{}.yml'.format(scheme.name, implementation.name))):
|
||||||
|
yield check_duplicate_consistency, implementation
|
||||||
|
|
||||||
def file_get_contents(filename):
|
def file_get_contents(filename):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
@ -19,18 +20,18 @@ def file_get_contents(filename):
|
|||||||
|
|
||||||
def check_duplicate_consistency(implementation):
|
def check_duplicate_consistency(implementation):
|
||||||
helpers.skip_windows()
|
helpers.skip_windows()
|
||||||
if not('duplicate-consistency' in implementation.metadata()):
|
metafile = os.path.join('duplicate_consistency', '{}_{}.yml'.format(implementation.scheme.name, implementation.name))
|
||||||
raise unittest.SkipTest('No duplicate consistency requirements defined')
|
with open(metafile, encoding='utf-8') as f:
|
||||||
dc = implementation.metadata()['duplicate-consistency']
|
metadata = yaml.load(f.read())
|
||||||
for pairs in dc['files']:
|
source = pqclean.Implementation.by_name(metadata['source']['scheme'], metadata['source']['implementation'])
|
||||||
transformed_src = helpers.run_subprocess(
|
for file in metadata['files']:
|
||||||
['sed', '-e', 's/{}/{}/g'.format(dc['source_namespace'], dc['target_namespace']), pairs['source_file']],
|
transformed_src = helpers.run_subprocess(
|
||||||
'..',
|
['sed', '-e', 's/{}/{}/g'.format(source.namespace_prefix(), implementation.namespace_prefix()), os.path.join(source.path(), file)]
|
||||||
)
|
)
|
||||||
this_src = file_get_contents(os.path.join(implementation.path(), pairs['target_file']))
|
this_src = file_get_contents(os.path.join(implementation.path(), file))
|
||||||
print(this_src)
|
print(os.path.join(implementation.path(), file))
|
||||||
assert(transformed_src == this_src)
|
print(this_src)
|
||||||
|
assert(transformed_src == this_src)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
|
@ -53,24 +53,6 @@ EXPECTED_FIELDS = {
|
|||||||
'spec': {
|
'spec': {
|
||||||
'name': {'type': str},
|
'name': {'type': str},
|
||||||
'version': {'type': str},
|
'version': {'type': str},
|
||||||
'duplicate-consistency': {
|
|
||||||
'type': dict,
|
|
||||||
'optional': True,
|
|
||||||
'spec': {
|
|
||||||
'source_namespace': {'type': str},
|
|
||||||
'target_namespace': {'type': str},
|
|
||||||
'files': {
|
|
||||||
'type': list,
|
|
||||||
'elements': {
|
|
||||||
'type': dict,
|
|
||||||
'spec': {
|
|
||||||
'source_file': {'type': str},
|
|
||||||
'target_file': {'type': str},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user