diff --git a/crypto_kem/frodokem976shake/META.yml b/crypto_kem/frodokem976shake/META.yml index 6806fa9f..9314dd1d 100644 --- a/crypto_kem/frodokem976shake/META.yml +++ b/crypto_kem/frodokem976shake/META.yml @@ -20,17 +20,3 @@ auxiliary-submitters: implementations: - name: clean 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 diff --git a/test/duplicate_consistency/frodokem976shake_clean.yml b/test/duplicate_consistency/frodokem976shake_clean.yml new file mode 100644 index 00000000..fb1fb3de --- /dev/null +++ b/test/duplicate_consistency/frodokem976shake_clean.yml @@ -0,0 +1,9 @@ +source: + scheme: frodokem640shake + implementation: clean +files: + - common.h + - kem.c + - matrix_shake.c + - noise.c + - util.c diff --git a/test/pqclean.py b/test/pqclean.py index ecabe0c3..47b9e6d1 100644 --- a/test/pqclean.py +++ b/test/pqclean.py @@ -78,6 +78,9 @@ class Implementation: def path(self, base='..') -> str: 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: if os.name == 'nt': return "lib{}_{}.lib".format(self.scheme.name, self.name) diff --git a/test/test_duplicate_consistency.py b/test/test_duplicate_consistency.py index 23ace1df..52755a3b 100644 --- a/test/test_duplicate_consistency.py +++ b/test/test_duplicate_consistency.py @@ -6,12 +6,13 @@ import os import pqclean import helpers import unittest +import yaml def test_duplicate_consistency(): for scheme in pqclean.Scheme.all_schemes(): 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): with open(filename) as f: @@ -19,18 +20,18 @@ def file_get_contents(filename): def check_duplicate_consistency(implementation): helpers.skip_windows() - if not('duplicate-consistency' in implementation.metadata()): - raise unittest.SkipTest('No duplicate consistency requirements defined') - dc = implementation.metadata()['duplicate-consistency'] - for pairs in dc['files']: - transformed_src = helpers.run_subprocess( - ['sed', '-e', 's/{}/{}/g'.format(dc['source_namespace'], dc['target_namespace']), pairs['source_file']], - '..', - ) - this_src = file_get_contents(os.path.join(implementation.path(), pairs['target_file'])) - print(this_src) - assert(transformed_src == this_src) - + metafile = os.path.join('duplicate_consistency', '{}_{}.yml'.format(implementation.scheme.name, implementation.name)) + with open(metafile, encoding='utf-8') as f: + metadata = yaml.load(f.read()) + source = pqclean.Implementation.by_name(metadata['source']['scheme'], metadata['source']['implementation']) + for file in metadata['files']: + 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(), file)) + print(os.path.join(implementation.path(), file)) + print(this_src) + assert(transformed_src == this_src) if __name__ == '__main__': try: diff --git a/test/test_metadata.py b/test/test_metadata.py index 2b92539e..8d8fcbce 100644 --- a/test/test_metadata.py +++ b/test/test_metadata.py @@ -53,24 +53,6 @@ EXPECTED_FIELDS = { 'spec': { 'name': {'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}, - }, - }, - }, - }, - }, }, }, },