_exdZddlZddlmcmZddlZddlZddl Z ddl Z ddl Z e j dde jDde jDe jdZedkrddlZe jejdSdS) a Checks that (hash of the) KATs (in NIST format) produced on this platform match the one provided in the META file for every scheme/implementation. Note that this only uses the first test case from the NIST-format KAT files. The appropriate hash can be generated from the original submission's KAT file using the command: cat PQCkemKAT_whatever.rsp | head -n 8 | tail -n 6 | sha256sum Nz.implementation,test_dir,impl_path, init, destrcdg|]-}|gtj|dR.S)test_functest_)helpersisolate_test_filespath.0impls 5/Users/thom/git/pqcrypto/pqclean/test/test_nistkat.py r sOAAA  GW ' 5E F FGGAAAc,g|]}t|S)strrs r r r sNNNtTNNNr )idsc|tj|d}tjd|jj|jj|j||tj|dtjtj|d |jj|jtjdkrdndgd  d d}|j d }|j }|} tj} |j} d } | | } | | }|j}|}|j }|}| |k}|st#jd|fd| |ft#j|t#j|t#j| dt)jvst#jtrt#jtndt#j| dt)jvst#j|rt#j|ndt#j| t#j| t#j| t#j|t#j|t#j|t#j|t#j|dz}dd|iz}t/t#j|dx}x}x} x}x} x} x} x} x}x}x}x}}|dS)Nbinnistkattest)TYPESCHEMEIMPLEMENTATION SCHEME_DIRDEST_DIR working_dirznistkat_{}_{}{}ntz.exeF) print_output znistkat-sha256zutf-8)==)a0%(py5)s {%(py5)s = %(py3)s {%(py3)s = %(py1)s.lower }() } == %(py26)s {%(py26)s = %(py24)s {%(py24)s = %(py22)s {%(py22)s = %(py20)s {%(py20)s = %(py18)s {%(py18)s = %(py9)s {%(py9)s = %(py7)s.sha256 }(%(py16)s {%(py16)s = %(py12)s {%(py12)s = %(py10)s.encode }(%(py14)s) }) }.hexdigest }() }.lower }() }hashlibout)py1py3py5py7py9py10py12py14py16py18py20py22py24py26zassert %(py28)spy28)osrjoinrmakeschemetypenamerun_subprocessformatreplacemetadatalowerr!sha256encode hexdigest @pytest_ar_call_reprcompare _saferepr @py_builtinslocals_should_repr_global_nameAssertionError_format_explanation)implementation impl_pathtest_dirinitdestr dest_pathr" @py_assert0 @py_assert2 @py_assert4 @py_assert8 @py_assert11 @py_assert13 @py_assert15 @py_assert17 @py_assert19 @py_assert21 @py_assert23 @py_assert25 @py_assert6 @py_format27 @py_format29s r test_nistkatr]s DFFF Xu--I L$+0&-2 . 3%#W\\(F;; ====  i!2!9!9  ! &  gooFF2" "        gdBG@FhhhhGGGGAFGGGGGGG@FGG@FGGGGGGGGGGGGGGGG=FGGGGGGGAFGGGGGGGGGGGGG5FGGGGGGGGGG=FGGGG=FGGGG=FGGGGG@FGGGGG.FGGGGG=FGGGGGG=FGGGGG@FGGGGG.FGGGGG=FGGGGGG=FGGGG=FGGGG=FGGGG=FGGGG=FGGGG=FGGGG=FGGGG=FGGGGGGGGGGGGGGG3FGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG EGGGGGr __main__)__doc__builtinsrC_pytest.assertion.rewrite assertionrewriter@r!r2pytestrpqcleanmark parametrizeSchemeall_supported_implementations filtered_testr]__name__sysmainargvrr r ros& 4AA==??AAANNw~KKMMNNN       . zJJJFKr