Example #1
0
 def test_finished(self):
     record = Handshake.from_bytes(self.finished_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.FINISHED
     assert record.length == 20
     assert isinstance(record.body, Finished)
     assert record.body.verify_data == b'some-encrypted-bytes'
Example #2
0
 def test_as_bytes_certificate_status(self):
     """
     :py:class:`tls.message.Handshake` serializes a record containing a
     ``CertificateStatus`` message.
     """
     record = Handshake.from_bytes(self.certificate_status_handshake)
     assert record.as_bytes() == self.certificate_status_handshake
Example #3
0
 def test_as_bytes_certificate_status(self):
     """
     :py:class:`tls.message.Handshake` serializes a record containing a
     ``CertificateStatus`` message.
     """
     record = Handshake.from_bytes(self.certificate_status_handshake)
     assert record.as_bytes() == self.certificate_status_handshake
Example #4
0
 def test_as_bytes_certificate_url(self):
     """
     :py:meth:`tls.message.Handshake.as_bytes` returns a valid packet when
     the body contains a ``CertificateURL`` message.
     """
     record = Handshake.from_bytes(self.certificate_url_handshake_packet)
     assert record.as_bytes() == self.certificate_url_handshake_packet
Example #5
0
 def test_as_bytes_certificate_url(self):
     """
     :py:meth:`tls.message.Handshake.as_bytes` returns a valid packet when
     the body contains a ``CertificateURL`` message.
     """
     record = Handshake.from_bytes(self.certificate_url_handshake_packet)
     assert record.as_bytes() == self.certificate_url_handshake_packet
Example #6
0
 def test_finished(self):
     record = Handshake.from_bytes(self.finished_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.FINISHED
     assert record.length == 20
     assert isinstance(record.body, Finished)
     assert record.body.verify_data == b'some-encrypted-bytes'
Example #7
0
 def test_parse_certificate_request_in_handshake(self):
     record = Handshake.from_bytes(
         self.certificate_request_handshake
     )
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CERTIFICATE_REQUEST
     assert record.length == 8
     assert isinstance(record.body, CertificateRequest)
Example #8
0
 def test_from_bytes_certificate_status(self):
     """
     :py:class:`tls.message.Handshake` parses a valid packet with
     ``CertificateStatus`` message.
     """
     record = Handshake.from_bytes(self.certificate_status_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == enums.HandshakeType.CERTIFICATE_STATUS
     assert record.length == 9
     assert isinstance(record.body, CertificateStatus)
     assert record.body.status_type == enums.CertificateStatusType.OCSP
     assert record.body.response == b'12345'
Example #9
0
 def test_from_bytes_certificate_status(self):
     """
     :py:class:`tls.message.Handshake` parses a valid packet with
     ``CertificateStatus`` message.
     """
     record = Handshake.from_bytes(self.certificate_status_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == enums.HandshakeType.CERTIFICATE_STATUS
     assert record.length == 9
     assert isinstance(record.body, CertificateStatus)
     assert record.body.status_type == enums.CertificateStatusType.OCSP
     assert record.body.response == b'12345'
Example #10
0
 def test_from_bytes_certificate_url(self):
     """
     :py:class:`tls.messages.Handshake` parses a valid packet with a
     ``CertificateURL`` message.
     """
     record = Handshake.from_bytes(self.certificate_url_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == enums.HandshakeType.CERTIFICATE_URL
     assert record.length == 42
     assert isinstance(record.body, CertificateURL)
     assert record.body.type == enums.CertChainType.INDIVIDUAL_CERTS
     assert len(record.body.url_and_hash_list) == 1
     assert isinstance(record.body.url_and_hash_list[0], URLAndHash)
     assert record.body.url_and_hash_list[0].url == b'cert.example.com'
     assert record.body.url_and_hash_list[0].padding == 1
     assert (record.body.url_and_hash_list[0].sha1_hash ==
             b'abcdefghijklmnopqrst')
Example #11
0
 def test_from_bytes_certificate_url(self):
     """
     :py:class:`tls.message.Handshake` parses a valid packet with a
     ``CertificateURL`` message.
     """
     record = Handshake.from_bytes(self.certificate_url_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == enums.HandshakeType.CERTIFICATE_URL
     assert record.length == 42
     assert isinstance(record.body, CertificateURL)
     assert record.body.type == enums.CertChainType.INDIVIDUAL_CERTS
     assert len(record.body.url_and_hash_list) == 1
     assert isinstance(record.body.url_and_hash_list[0], URLAndHash)
     assert record.body.url_and_hash_list[0].url == b'cert.example.com'
     assert record.body.url_and_hash_list[0].padding == 1
     assert (record.body.url_and_hash_list[0].sha1_hash ==
             b'abcdefghijklmnopqrst')
Example #12
0
 def test_parse_server_hello_in_handshake(self):
     record = Handshake.from_bytes(self.server_hello_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_HELLO
     assert record.length == 80
     assert isinstance(record.body, ServerHello)
Example #13
0
 def test_parse_client_hello_in_handshake(self):
     record = Handshake.from_bytes(self.client_hello_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CLIENT_HELLO
     assert record.length == 51
     assert isinstance(record.body, ClientHello)
Example #14
0
 def test_not_implemented(self):
     record = Handshake.from_bytes(self.server_key_exchange_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_KEY_EXCHANGE
     assert record.length == 0
     assert record.body is None
Example #15
0
 def test_parse_hello_request(self):
     record = Handshake.from_bytes(self.hello_request_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.HELLO_REQUEST
     assert record.length == 0
     assert isinstance(record.body, HelloRequest)
Example #16
0
 def test_as_bytes_not_implemented(self):
     record = Handshake.from_bytes(self.server_key_exchange_handshake)
     assert record.as_bytes() == self.server_key_exchange_handshake
Example #17
0
 def test_parse_hello_request(self):
     record = Handshake.from_bytes(self.hello_request_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.HELLO_REQUEST
     assert record.length == 0
     assert isinstance(record.body, HelloRequest)
Example #18
0
 def test_as_bytes_client_hello_packet(self):
     record = Handshake.from_bytes(self.client_hello_handshake_packet)
     assert record.as_bytes() == self.client_hello_handshake_packet
Example #19
0
 def test_as_bytes_client_hello_packet(self):
     record = Handshake.from_bytes(self.client_hello_handshake_packet)
     assert record.as_bytes() == self.client_hello_handshake_packet
Example #20
0
 def test_parse_server_hello_in_handshake(self):
     record = Handshake.from_bytes(self.server_hello_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_HELLO
     assert record.length == 80
     assert isinstance(record.body, ServerHello)
Example #21
0
 def test_not_implemented(self):
     record = Handshake.from_bytes(self.server_key_exchange_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_KEY_EXCHANGE
     assert record.length == 0
     assert record.body is None
Example #22
0
 def test_server_hello_done(self):
     record = Handshake.from_bytes(self.server_hello_done_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_HELLO_DONE
     assert record.length == 0
     assert isinstance(record.body, ServerHelloDone)
Example #23
0
 def test_parse_certificate_request_in_handshake(self):
     record = Handshake.from_bytes(self.certificate_request_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CERTIFICATE_REQUEST
     assert record.length == 8
     assert isinstance(record.body, CertificateRequest)
Example #24
0
 def test_as_bytes_server_hello_done(self):
     record = Handshake.from_bytes(self.server_hello_done_handshake)
     assert record.as_bytes() == self.server_hello_done_handshake
Example #25
0
 def test_parse_certificate_in_handshake(self):
     record = Handshake.from_bytes(self.certificate_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CERTIFICATE
     assert record.length == 11
     assert isinstance(record.body, Certificate)
Example #26
0
 def test_parse_client_hello_in_handshake(self):
     record = Handshake.from_bytes(self.client_hello_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CLIENT_HELLO
     assert record.length == 51
     assert isinstance(record.body, ClientHello)
Example #27
0
 def test_server_hello_done(self):
     record = Handshake.from_bytes(self.server_hello_done_handshake)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.SERVER_HELLO_DONE
     assert record.length == 0
     assert isinstance(record.body, ServerHelloDone)
Example #28
0
 def test_as_bytes_finished(self):
     record = Handshake.from_bytes(self.finished_handshake)
     assert record.as_bytes() == self.finished_handshake
Example #29
0
 def test_as_bytes_certificate_request_packet(self):
     record = Handshake.from_bytes(self.certificate_request_handshake)
     assert record.as_bytes() == self.certificate_request_handshake
Example #30
0
 def test_parse_certificate_in_handshake(self):
     record = Handshake.from_bytes(self.certificate_handshake_packet)
     assert isinstance(record, Handshake)
     assert record.msg_type == HandshakeType.CERTIFICATE
     assert record.length == 11
     assert isinstance(record.body, Certificate)
Example #31
0
 def test_as_bytes_certificate_request_packet(self):
     record = Handshake.from_bytes(self.certificate_request_handshake)
     assert record.as_bytes() == self.certificate_request_handshake
Example #32
0
 def test_as_bytes_not_implemented(self):
     record = Handshake.from_bytes(self.server_key_exchange_handshake)
     assert record.as_bytes() == self.server_key_exchange_handshake
Example #33
0
 def test_as_bytes_hello_request(self):
     record = Handshake.from_bytes(self.hello_request_handshake)
     assert record.as_bytes() == self.hello_request_handshake
Example #34
0
 def test_as_bytes_hello_request(self):
     record = Handshake.from_bytes(self.hello_request_handshake)
     assert record.as_bytes() == self.hello_request_handshake
Example #35
0
 def test_as_bytes_finished(self):
     record = Handshake.from_bytes(self.finished_handshake)
     assert record.as_bytes() == self.finished_handshake
Example #36
0
 def test_as_bytes_server_hello_done(self):
     record = Handshake.from_bytes(self.server_hello_done_handshake)
     assert record.as_bytes() == self.server_hello_done_handshake