|
67 | 67 | ) |
68 | 68 | from OpenSSL.SSL import ( |
69 | 69 | DTLS_METHOD, |
70 | | - MODE_RELEASE_BUFFERS, |
71 | 70 | NO_OVERLAPPING_PROTOCOLS, |
72 | 71 | OP_COOKIE_EXCHANGE, |
73 | 72 | OP_NO_COMPRESSION, |
|
132 | 131 | _NoOverlappingProtocols, |
133 | 132 | ) |
134 | 133 |
|
| 134 | +from . import conftest |
135 | 135 | from .test_crypto import ( |
136 | 136 | client_cert_pem, |
137 | 137 | client_key_pem, |
@@ -643,6 +643,12 @@ def test_set_cipher_list_no_cipher_match(self, context: Context) -> None: |
643 | 643 | "", |
644 | 644 | "no cipher match", |
645 | 645 | ), |
| 646 | + # aws-lc |
| 647 | + ( |
| 648 | + "SSL routines", |
| 649 | + "OPENSSL_internal", |
| 650 | + "NO_CIPHER_MATCH", |
| 651 | + ), |
646 | 652 | ] |
647 | 653 |
|
648 | 654 | def test_load_client_ca(self, context: Context, ca_file: bytes) -> None: |
@@ -700,6 +706,12 @@ def test_set_session_id_fail(self, context: Context) -> None: |
700 | 706 | "", |
701 | 707 | "ssl session id context too long", |
702 | 708 | ), |
| 709 | + # aws-lc |
| 710 | + ( |
| 711 | + "SSL routines", |
| 712 | + "OPENSSL_internal", |
| 713 | + "SSL_SESSION_ID_CONTEXT_TOO_LONG", |
| 714 | + ), |
703 | 715 | ] |
704 | 716 |
|
705 | 717 | def test_set_session_id_unicode(self, context: Context) -> None: |
@@ -922,7 +934,8 @@ def test_set_mode(self) -> None: |
922 | 934 | newly set mode. |
923 | 935 | """ |
924 | 936 | context = Context(SSLv23_METHOD) |
925 | | - assert MODE_RELEASE_BUFFERS & context.set_mode(MODE_RELEASE_BUFFERS) |
| 937 | + mode = _lib.SSL_MODE_ENABLE_PARTIAL_WRITE |
| 938 | + assert mode & context.set_mode(mode) |
926 | 939 |
|
927 | 940 | def test_set_timeout_wrong_args(self) -> None: |
928 | 941 | """ |
@@ -969,7 +982,7 @@ def _write_encrypted_pem(self, passphrase: bytes, tmpfile: bytes) -> bytes: |
969 | 982 | """ |
970 | 983 | key = PKey() |
971 | 984 | key.generate_key(TYPE_RSA, 1024) |
972 | | - pem = dump_privatekey(FILETYPE_PEM, key, "blowfish", passphrase) |
| 985 | + pem = dump_privatekey(FILETYPE_PEM, key, "aes-256-cbc", passphrase) |
973 | 986 | with open(tmpfile, "w") as fObj: |
974 | 987 | fObj.write(pem.decode("ascii")) |
975 | 988 | return tmpfile |
@@ -1163,7 +1176,7 @@ def test_set_proto_version(self) -> None: |
1163 | 1176 | client_context = Context(TLS_METHOD) |
1164 | 1177 | client_context.set_max_proto_version(low_version) |
1165 | 1178 |
|
1166 | | - with pytest.raises(Error, match="unsupported protocol"): |
| 1179 | + with pytest.raises(Error, match=r"(?i)unsupported.protocol"): |
1167 | 1180 | self._handshake_test(server_context, client_context) |
1168 | 1181 |
|
1169 | 1182 | client_context = Context(TLS_METHOD) |
@@ -1632,7 +1645,9 @@ def test_set_verify_default_callback(self, mode: int) -> None: |
1632 | 1645 | if mode == SSL.VERIFY_PEER: |
1633 | 1646 | with pytest.raises(Exception) as exc: |
1634 | 1647 | self._handshake_test(serverContext, clientContext) |
1635 | | - assert "certificate verify failed" in str(exc.value) |
| 1648 | + assert "certificate verify failed" in str( |
| 1649 | + exc.value |
| 1650 | + ) or "CERTIFICATE_VERIFY_FAILED" in str(exc.value) |
1636 | 1651 | else: |
1637 | 1652 | self._handshake_test(serverContext, clientContext) |
1638 | 1653 |
|
@@ -1861,9 +1876,27 @@ def test_set_tmp_ecdh(self) -> None: |
1861 | 1876 | with pytest.deprecated_call(): |
1862 | 1877 | context.set_tmp_ecdh(curve) |
1863 | 1878 |
|
| 1879 | + awslc_unsupported_curves = { |
| 1880 | + "BRAINPOOLP256R1", |
| 1881 | + "BRAINPOOLP384R1", |
| 1882 | + "BRAINPOOLP512R1", |
| 1883 | + "SECP192R1", |
| 1884 | + "SECT163K1", |
| 1885 | + "SECT163R2", |
| 1886 | + "SECT233K1", |
| 1887 | + "SECT233R1", |
| 1888 | + "SECT283K1", |
| 1889 | + "SECT283R1", |
| 1890 | + "SECT409K1", |
| 1891 | + "SECT409R1", |
| 1892 | + "SECT571K1", |
| 1893 | + "SECT571R1", |
| 1894 | + } |
1864 | 1895 | for name in dir(ec.EllipticCurveOID): |
1865 | 1896 | if name.startswith("_"): |
1866 | 1897 | continue |
| 1898 | + if conftest.is_awslc and name in awslc_unsupported_curves: |
| 1899 | + continue |
1867 | 1900 | oid = getattr(ec.EllipticCurveOID, name) |
1868 | 1901 | cryptography_curve = ec.get_curve_for_oid(oid) |
1869 | 1902 | context.set_tmp_ecdh(cryptography_curve()) |
@@ -2699,10 +2732,12 @@ def test_state_string(self) -> None: |
2699 | 2732 | assert tls_server.get_state_string() in [ |
2700 | 2733 | b"before/accept initialization", |
2701 | 2734 | b"before SSL initialization", |
| 2735 | + b"TLS server start_accept", |
2702 | 2736 | ] |
2703 | 2737 | assert tls_client.get_state_string() in [ |
2704 | 2738 | b"before/connect initialization", |
2705 | 2739 | b"before SSL initialization", |
| 2740 | + b"TLS client start_connect", |
2706 | 2741 | ] |
2707 | 2742 |
|
2708 | 2743 | def test_app_data(self) -> None: |
@@ -3179,9 +3214,10 @@ def _perform_moving_buffer_test( |
3179 | 3214 | return False # Retry succeeded |
3180 | 3215 | except SSL.Error as e: |
3181 | 3216 | reason = get_ssl_error_reason(e) |
3182 | | - assert reason == "bad write retry", ( |
3183 | | - f"Retry failed with unexpected SSL error: {e!r}({reason})." |
3184 | | - ) |
| 3217 | + assert reason in ( |
| 3218 | + "bad write retry", |
| 3219 | + "BAD_WRITE_RETRY", |
| 3220 | + ), f"Retry failed with unexpected SSL error: {e!r}({reason})." |
3185 | 3221 | return True # Bad write retry |
3186 | 3222 |
|
3187 | 3223 | def _shutdown_connections( |
@@ -3895,6 +3931,10 @@ def test_total_renegotiations(self) -> None: |
3895 | 3931 | connection = Connection(Context(SSLv23_METHOD), None) |
3896 | 3932 | assert connection.total_renegotiations() == 0 |
3897 | 3933 |
|
| 3934 | + @pytest.mark.skipif( |
| 3935 | + conftest.is_awslc, |
| 3936 | + reason="aws-lc doesn't support renegotiation", |
| 3937 | + ) |
3898 | 3938 | def test_renegotiate(self) -> None: |
3899 | 3939 | """ |
3900 | 3940 | Go through a complete renegotiation cycle. |
@@ -3988,6 +4028,10 @@ def test_op_no_ticket(self) -> None: |
3988 | 4028 | "OP_NO_COMPRESSION unavailable - OpenSSL version may be too old" |
3989 | 4029 | ), |
3990 | 4030 | ) |
| 4031 | + @pytest.mark.skipif( |
| 4032 | + conftest.is_awslc, |
| 4033 | + reason="aws-lc defines OP_NO_COMPRESSION as 0", |
| 4034 | + ) |
3991 | 4035 | def test_op_no_compression(self) -> None: |
3992 | 4036 | """ |
3993 | 4037 | The value of `OpenSSL.SSL.OP_NO_COMPRESSION` is 0x20000, the |
@@ -5050,9 +5094,17 @@ def pump() -> None: |
5050 | 5094 | c.set_ciphertext_mtu(500) |
5051 | 5095 | assert 0 < c.get_cleartext_mtu() < 500 |
5052 | 5096 |
|
| 5097 | + @pytest.mark.skipif( |
| 5098 | + OP_COOKIE_EXCHANGE is None, |
| 5099 | + reason="DTLS cookie exchange not supported", |
| 5100 | + ) |
5053 | 5101 | def test_it_works_at_all(self) -> None: |
5054 | 5102 | self._test_handshake_and_data(srtp_profile=None) |
5055 | 5103 |
|
| 5104 | + @pytest.mark.skipif( |
| 5105 | + OP_COOKIE_EXCHANGE is None, |
| 5106 | + reason="DTLS cookie exchange not supported", |
| 5107 | + ) |
5056 | 5108 | def test_it_works_with_srtp(self) -> None: |
5057 | 5109 | self._test_handshake_and_data(srtp_profile=b"SRTP_AES128_CM_SHA1_80") |
5058 | 5110 |
|
|
0 commit comments