示例#1
0
def test_sig(sig_name):
    if not (helpers.is_sig_enabled_by_name(sig_name)):
        pytest.skip('Not enabled')
    output = helpers.run_subprocess(
        [helpers.path_to_executable('kat_sig'), sig_name], )
    output = output.replace("\r\n", "\n")
    kats = []
    avx2_aes_enabled_on_linux = helpers.is_use_option_enabled_by_name(
        'AVX2_INSTRUCTIONS') and helpers.is_use_option_enabled_by_name(
            'AES_INSTRUCTIONS') and platform.system() == 'Linux'
    for filename in os.listdir(os.path.join('tests', 'KATs', 'sig')):
        if filename.startswith(sig_name + '.') and filename.endswith('.kat'):
            # qtesla's avx2 implementation uses an optimized sampling method that results in different KAT values; we use the correct one (if avx2/aes instructions are available)
            append_kat = False
            if sig_name.startswith('qTesla'):
                if 'avx2' in filename:
                    if avx2_aes_enabled_on_linux and not helpers.is_build_portable(
                    ):
                        append_kat = True
                else:
                    append_kat = True
            else:
                append_kat = True
            if append_kat:
                with open(os.path.join('tests', 'KATs', 'sig', filename),
                          'r') as myfile:
                    kats.append(myfile.read())
    assert (output in kats)
示例#2
0
def test_kem(kem_name):
    if not(helpers.is_build_portable()):
        pytest.skip("Portability not enabled")

    if not(helpers.is_kem_enabled_by_name(kem_name)):
        pytest.skip('Not enabled')

    helpers.run_subprocess(["qemu-"+platform.machine()+"-static", "-cpu", MIN_CPUS[platform.machine()],
                            helpers.path_to_executable('test_kem'), kem_name])
示例#3
0
def test_sig(sig_name):
    if not(helpers.is_build_portable()):
        pytest.skip("Portability not enabled")

    if not(helpers.is_sig_enabled_by_name(sig_name)):
        pytest.skip('Not enabled')

    if (sig_name.startswith("picnic")):
        pytest.skip("Picnic portability known to not be given.")

    helpers.run_subprocess(["qemu-"+platform.machine()+"-static", "-cpu", MIN_CPUS[platform.machine()],
                             helpers.path_to_executable('test_sig'), sig_name])
示例#4
0
def test_sig(sig_name):
    kats = helpers.get_kats("sig")
    if not (helpers.is_sig_enabled_by_name(sig_name)):
        pytest.skip('Not enabled')
    output = helpers.run_subprocess(
        [helpers.path_to_executable('kat_sig'), sig_name], )
    output = output.replace("\r\n", "\n")
    h256 = sha256()
    h256.update(output.encode())
    # qtesla's avx2 implementation uses an optimized sampling method that results in
    # different KAT values; we use the correct one (if avx2/aes instructions are available)
    avx2_aes_enabled_on_linux = helpers.is_use_option_enabled_by_name(
        'AVX2_INSTRUCTIONS') and helpers.is_use_option_enabled_by_name(
            'AES_INSTRUCTIONS') and platform.system() == 'Linux'
    if sig_name.startswith(
            'qTesla'
    ) and avx2_aes_enabled_on_linux and not helpers.is_build_portable():
        sig_name = sig_name + ".avx2"

    assert (kats[sig_name] == h256.hexdigest())