1# This file is dual licensed under the terms of the Apache License, Version 2# 2.0, and the BSD License. See the LICENSE file in the root of this repository 3# for complete details. 4 5from __future__ import absolute_import, division, print_function 6 7import binascii 8import os 9 10import pytest 11 12from cryptography.hazmat.backends.interfaces import CipherBackend 13from cryptography.hazmat.primitives.ciphers import algorithms 14 15from .utils import generate_stream_encryption_test 16from ...utils import load_nist_vectors 17 18 19@pytest.mark.supported( 20 only_if=lambda backend: backend.cipher_supported( 21 algorithms.ARC4(b"\x00" * 16), None 22 ), 23 skip_message="Does not support ARC4", 24) 25@pytest.mark.requires_backend_interface(interface=CipherBackend) 26class TestARC4(object): 27 test_rfc = generate_stream_encryption_test( 28 load_nist_vectors, 29 os.path.join("ciphers", "ARC4"), 30 [ 31 "rfc-6229-40.txt", 32 "rfc-6229-56.txt", 33 "rfc-6229-64.txt", 34 "rfc-6229-80.txt", 35 "rfc-6229-128.txt", 36 "rfc-6229-192.txt", 37 "rfc-6229-256.txt", 38 "arc4.txt", 39 ], 40 lambda key, **kwargs: algorithms.ARC4(binascii.unhexlify(key)), 41 ) 42