Skip to content

Commit b515726

Browse files
authored
test: Adds SSLv3 integ test (#4372)
1 parent a444087 commit b515726

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

tests/integrationv2/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ class Curves(object):
348348
"""
349349
X25519 = Curve("X25519", Protocols.TLS13)
350350
P256 = Curve("P-256")
351-
P384 = Curve("P-384")
352-
P521 = Curve("P-521")
351+
# Our only SSLv3 provider doesn't support extensions
352+
# so there is no way to negotiate a curve other than the
353+
# default P-256 in SSLv3.
354+
P384 = Curve("P-384", Protocols.TLS10)
355+
P521 = Curve("P-521", Protocols.TLS10)
353356
SecP256r1Kyber768Draft00 = Curve("SecP256r1Kyber768Draft00")
354357
X25519Kyber768Draft00 = Curve("X25519Kyber768Draft00")
355358

tests/integrationv2/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Protocols.TLS12,
1717
Protocols.TLS11,
1818
Protocols.TLS10,
19+
Protocols.SSLv3,
1920
]
2021

2122

tests/integrationv2/providers.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ def supports_protocol(cls, protocol, with_cert=None):
163163
# e.g. "openssl-1.0" in "openssl-1.0.2-fips"
164164
if unsupported_lc in current_libcrypto:
165165
return False
166+
167+
# s2n-tls will not negotiate SSLv3 if in fips mode
168+
if protocol == Protocols.SSLv3 and get_flag(S2N_FIPS_MODE):
169+
return False
170+
166171
return True
167172

168173
@classmethod
@@ -468,6 +473,9 @@ def get_version(cls):
468473

469474
@classmethod
470475
def supports_protocol(cls, protocol, with_cert=None):
476+
if protocol is Protocols.SSLv3:
477+
return False
478+
471479
return True
472480

473481
@classmethod
@@ -507,6 +515,8 @@ def setup_client(self):
507515
cmd_line.append('-tls1_1')
508516
elif self.options.protocol == Protocols.TLS10:
509517
cmd_line.append('-tls1')
518+
elif self.options.protocol == Protocols.SSLv3:
519+
cmd_line.append('-ssl3')
510520

511521
if self.options.cipher is not None:
512522
cmd_line.extend(self._cipher_to_cmdline(self.options.cipher))
@@ -582,6 +592,8 @@ def setup_server(self):
582592
cmd_line.append('-tls1_1')
583593
elif self.options.protocol == Protocols.TLS10:
584594
cmd_line.append('-tls1')
595+
elif self.options.protocol == Protocols.SSLv3:
596+
cmd_line.append('-ssl3')
585597

586598
if self.options.cipher is not None:
587599
cmd_line.extend(self._cipher_to_cmdline(self.options.cipher))
@@ -607,6 +619,26 @@ def setup_server(self):
607619
return cmd_line
608620

609621

622+
class SSLv3Provider(OpenSSL):
623+
def __init__(self, options: ProviderOptions):
624+
OpenSSL.__init__(self, options)
625+
self._override_libssl(options)
626+
627+
def _override_libssl(self, options: ProviderOptions):
628+
install_dir = os.environ["OPENSSL_1_0_2_INSTALL_DIR"]
629+
630+
override_env_vars = dict()
631+
override_env_vars["PATH"] = install_dir + "/bin"
632+
override_env_vars["LD_LIBRARY_PATH"] = install_dir + "/lib"
633+
options.env_overrides = override_env_vars
634+
635+
@classmethod
636+
def supports_protocol(cls, protocol, with_cert=None):
637+
if protocol is Protocols.SSLv3:
638+
return True
639+
return False
640+
641+
610642
class JavaSSL(Provider):
611643
"""
612644
NOTE: Only a Java SSL client has been set up. The server has not been
@@ -623,7 +655,7 @@ def get_send_marker(cls):
623655
@classmethod
624656
def supports_protocol(cls, protocol, with_cert=None):
625657
# https://aws.amazon.com/blogs/opensource/tls-1-0-1-1-changes-in-openjdk-and-amazon-corretto/
626-
if protocol is Protocols.TLS10 or protocol is Protocols.TLS11:
658+
if protocol is Protocols.SSLv3 or protocol is Protocols.TLS10 or protocol is Protocols.TLS11:
627659
return False
628660

629661
return True

tests/integrationv2/test_happy_path.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
from configuration import available_ports, ALL_TEST_CIPHERS, ALL_TEST_CURVES, ALL_TEST_CERTS, PROTOCOLS
55
from common import ProviderOptions, data_bytes
66
from fixtures import managed_process # lgtm [py/unused-import]
7-
from providers import Provider, S2N, OpenSSL, JavaSSL, GnuTLS
7+
from providers import Provider, S2N, OpenSSL, JavaSSL, GnuTLS, SSLv3Provider
88
from utils import invalid_test_parameters, get_parameter_name, get_expected_s2n_version, to_bytes
99

1010

1111
@pytest.mark.uncollect_if(func=invalid_test_parameters)
1212
@pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
13-
@pytest.mark.parametrize("provider", [S2N, OpenSSL, GnuTLS, JavaSSL])
14-
@pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
13+
@pytest.mark.parametrize("provider", [S2N, OpenSSL, GnuTLS, JavaSSL, SSLv3Provider])
1514
@pytest.mark.parametrize("curve", ALL_TEST_CURVES, ids=get_parameter_name)
1615
@pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
1716
@pytest.mark.parametrize("certificate", ALL_TEST_CERTS, ids=get_parameter_name)
18-
def test_s2n_server_happy_path(managed_process, cipher, provider, other_provider, curve, protocol, certificate):
17+
def test_s2n_server_happy_path(managed_process, cipher, provider, curve, protocol, certificate):
1918
port = next(available_ports)
2019

2120
# s2nd can receive large amounts of data because all the data is
@@ -69,12 +68,11 @@ def test_s2n_server_happy_path(managed_process, cipher, provider, other_provider
6968

7069
@pytest.mark.uncollect_if(func=invalid_test_parameters)
7170
@pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
72-
@pytest.mark.parametrize("provider", [S2N, OpenSSL, GnuTLS])
73-
@pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
71+
@pytest.mark.parametrize("provider", [S2N, OpenSSL, GnuTLS, SSLv3Provider])
7472
@pytest.mark.parametrize("curve", ALL_TEST_CURVES, ids=get_parameter_name)
7573
@pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
7674
@pytest.mark.parametrize("certificate", ALL_TEST_CERTS, ids=get_parameter_name)
77-
def test_s2n_client_happy_path(managed_process, cipher, provider, other_provider, curve, protocol, certificate):
75+
def test_s2n_client_happy_path(managed_process, cipher, provider, curve, protocol, certificate):
7876
port = next(available_ports)
7977

8078
# We can only send 4096 - 1 (\n at the end) bytes here because of the

tests/integrationv2/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ skipsdist = True
55
[testenv]
66
# install pytest in the virtualenv where commands will be executed
77
setenv = S2N_INTEG_TEST = 1
8-
passenv = DYLD_LIBRARY_PATH, LD_LIBRARY_PATH, OQS_OPENSSL_1_1_1_INSTALL_DIR, HOME, TOX_TEST_NAME
8+
passenv = DYLD_LIBRARY_PATH, LD_LIBRARY_PATH, OQS_OPENSSL_1_1_1_INSTALL_DIR, OPENSSL_1_0_2_INSTALL_DIR, HOME, TOX_TEST_NAME
99
ignore_errors=False
1010
deps =
1111
pytest==7

0 commit comments

Comments
 (0)