| 1 |
|
| 2 |
|
| 3 |
import copy |
| 4 |
|
| 5 |
from configuration import available_ports |
| 6 |
from common import Certificates, Ciphers, Protocols, ProviderOptions, data_bytes |
| 7 |
from fixtures import managed_process |
| 8 |
from providers import Provider, S2N, JavaSSL |
| 9 |
from utils import ( |
| 10 |
to_bytes, |
| 11 |
) |
| 12 |
|
| 13 |
|
| 14 |
def test_s2n_server_sslv2_client_hello(managed_process): |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
TEST_PROTOCOL = Protocols.TLS12 |
| 19 |
|
| 20 |
port = next(available_ports) |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
random_bytes = data_bytes(65519) |
| 28 |
|
| 29 |
certificate = Certificates.RSA_2048_SHA256 |
| 30 |
|
| 31 |
client_options = ProviderOptions( |
| 32 |
mode=Provider.ClientMode, |
| 33 |
port=port, |
| 34 |
|
| 35 |
|
| 36 |
cipher=Ciphers.AES256_SHA256, |
| 37 |
cert=certificate.cert, |
| 38 |
data_to_send=random_bytes, |
| 39 |
insecure=True, |
| 40 |
protocol=TEST_PROTOCOL, |
| 41 |
extra_flags=["SSLv2Hello"], |
| 42 |
) |
| 43 |
|
| 44 |
server_options = copy.copy(client_options) |
| 45 |
server_options.mode = Provider.ServerMode |
| 46 |
server_options.data_to_send = None |
| 47 |
server_options.key = certificate.key |
| 48 |
server_options.cert = certificate.cert |
| 49 |
server_options.extra_flags = None |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
server = managed_process(S2N, server_options, timeout=5) |
| 54 |
client = managed_process(JavaSSL, client_options, timeout=5) |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
for client_results in client.get_results(): |
| 60 |
client_results.assert_success() |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
for server_results in server.get_results(): |
| 65 |
server_results.assert_success() |
| 66 |
assert ( |
| 67 |
to_bytes(f"Client hello version: {Protocols.SSLv2.value}") |
| 68 |
in server_results.stdout |
| 69 |
) |
| 70 |
assert ( |
| 71 |
to_bytes(f"Actual protocol version: {TEST_PROTOCOL.value}") |
| 72 |
in server_results.stdout |
| 73 |
) |
| 74 |
assert random_bytes in server_results.stdout |