Beispiel #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)
Beispiel #2
0
def test_sig(sig_name):
    if not (helpers.is_sig_enabled_by_name(sig_name)):
        pytest.skip('Not enabled')

    helpers.run_subprocess([
        "qemu-" + platform.machine() + "-static", "-cpu", MINCPU,
        helpers.path_to_executable('test_sig'), sig_name
    ])
Beispiel #3
0
def test_sig(sig_name):
    if not(helpers.is_sig_enabled_by_name(sig_name)): pytest.skip('Not enabled')
    if sys.platform.startswith("win") and 'APPVEYOR' in os.environ:
        if 'SPHINCS' in sig_name and ('192f' in sig_name or '192s' in sig_name or '256f' in sig_name or '256s' in sig_name):
            pytest.skip('Skipping SPHINCS+ 192s and 256s tests on Windows AppVeyor builds')
    helpers.run_subprocess(
        [helpers.path_to_executable('test_sig'), sig_name],
    )
Beispiel #4
0
def test_sig(sig_name):
    if not (helpers.is_sig_enabled_by_name(sig_name)):
        pytest.skip('Not enabled')

    Path('build/mem-benchmark').mkdir(parents=True, exist_ok=True)

    for i in range(3):
        helpers.run_subprocess(
            [helpers.path_to_executable('test_sig_mem'), sig_name,
             str(i)])
Beispiel #5
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())

    assert (kats[sig_name] == h256.hexdigest())
Beispiel #6
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])
Beispiel #7
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 = []
    for filename in os.listdir(os.path.join('tests', 'KATs', 'sig')):
        if filename.startswith(sig_name + '.') and filename.endswith('.kat'):
            with open(os.path.join('tests', 'KATs', 'sig', filename), 'r') as myfile:
                kats.append(myfile.read())
    assert(output in kats)
Beispiel #8
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 = []
    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 not sig_name.startswith('qTesla') or not (bool(
                    helpers.is_use_option_enabled_by_name(
                        'AVX2_INSTRUCTION')) ^ bool('avx2' in filename)):
                with open(os.path.join('tests', 'KATs', 'sig', filename),
                          'r') as myfile:
                    kats.append(myfile.read())
    assert (output in kats)
Beispiel #9
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())