Example #1
0
    def test_decrypt_short_server(self):
        pair = CryptoPair()
        pair.recv.setup(
            INITIAL_CIPHER_SUITE,
            binascii.unhexlify(
                "310281977cb8c1c1c1212d784b2d29e5a6489e23de848d370a5a2f9537f3a100"
            ),
        )

        plain_header, plain_payload, packet_number = pair.decrypt_packet(
            SHORT_SERVER_ENCRYPTED_PACKET, 9)
        self.assertEqual(plain_header, SHORT_SERVER_PLAIN_HEADER)
        self.assertEqual(plain_payload, SHORT_SERVER_PLAIN_PAYLOAD)
        self.assertEqual(packet_number, 3)
Example #2
0
    def test_decrypt_chacha20(self):
        pair = CryptoPair()
        pair.recv.setup(
            CipherSuite.CHACHA20_POLY1305_SHA256,
            binascii.unhexlify(
                "fcc211ac3ff1f3fe1b096a41e701e30033cbd899494ebabbbc009ee2626d987e"
            ),
        )

        plain_header, plain_payload, packet_number = pair.decrypt_packet(
            CHACHA20_CLIENT_ENCRYPTED_PACKET, 34)
        self.assertEqual(plain_header, CHACHA20_CLIENT_PLAIN_HEADER)
        self.assertEqual(plain_payload, CHACHA20_CLIENT_PLAIN_PAYLOAD)
        self.assertEqual(packet_number, 2)