aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
blob: 1d9f96edabea8f1002700296a0bac8c46854729c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest

from cryptography.hazmat.backends import _ALL_BACKENDS
from cryptography.hazmat.backends.interfaces import (
    HMACBackend, CipherBackend, HashBackend
)

from .utils import check_for_iface, check_backend_support


@pytest.fixture(params=_ALL_BACKENDS)
def backend(request):
    return request.param


@pytest.mark.trylast
def pytest_runtest_setup(item):
    check_for_iface("hmac", HMACBackend, item)
    check_for_iface("cipher", CipherBackend, item)
    check_for_iface("hash", HashBackend, item)
    check_backend_support(item)
] = 32, [QCRYPTO_CIPHER_ALG_DES_RFB] = 8, }; static bool qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg, size_t nkey, Error **errp) { if ((unsigned)alg >= QCRYPTO_CIPHER_ALG_LAST) { error_setg(errp, "Cipher algorithm %d out of range", alg); return false; } if (alg_key_len[alg] != nkey) { error_setg(errp, "Cipher key length %zu should be %zu", alg_key_len[alg], nkey); return false; } return true; } #if defined(CONFIG_GNUTLS_GCRYPT) || defined(CONFIG_GNUTLS_NETTLE) static uint8_t * qcrypto_cipher_munge_des_rfb_key(const uint8_t *key, size_t nkey) { uint8_t *ret = g_new0(uint8_t, nkey); size_t i; for (i = 0; i < nkey; i++) { uint8_t r = key[i]; r = (r & 0xf0) >> 4 | (r & 0x0f) << 4; r = (r & 0xcc) >> 2 | (r & 0x33) << 2; r = (r & 0xaa) >> 1 | (r & 0x55) << 1; ret[i] = r; } return ret; } #endif /* CONFIG_GNUTLS_GCRYPT || CONFIG_GNUTLS_NETTLE */ #ifdef CONFIG_GNUTLS_GCRYPT #include "crypto/cipher-gcrypt.c" #elif defined CONFIG_GNUTLS_NETTLE #include "crypto/cipher-nettle.c" #else #include "crypto/cipher-builtin.c" #endif