Ejemplo n.º 1
0
 def test_tls1_2_prf_against_static_data(self):
     self._initialize_tls1_2_known_params()
     prf = tlsc.TLSPRF(tls.TLSVersion.TLS_1_2)
     self.assertEqual(
         prf.get_bytes(self.pms, tlsc.TLSPRF.TLS_MD_MASTER_SECRET_CONST,
                       "%s%s" % (self.client_random, self.server_random),
                       48), self.ms)
     crypto_material_len = len(self.client_mac) + len(self.client_key)
     crypto_material = prf.get_bytes(
         self.ms, tlsc.TLSPRF.TLS_MD_KEY_EXPANSION_CONST,
         "%s%s" % (self.server_random, self.client_random),
         2 * crypto_material_len)
     i = 0
     self.assertEqual(self.client_mac,
                      crypto_material[i:len(self.client_mac)])
     i += len(self.client_mac)
     self.assertEqual(self.server_mac,
                      crypto_material[i:i + len(self.server_mac)])
     i += len(self.server_mac)
     self.assertEqual(self.client_key,
                      crypto_material[i:i + len(self.client_key)])
     i += len(self.client_key)
     self.assertEqual(self.server_key,
                      crypto_material[i:i + len(self.server_key)])
     i += len(self.server_key)
Ejemplo n.º 2
0
 def setUp(self):
     self.prf = tlsc.TLSPRF(tls.TLSVersion.TLS_1_0)
     self.pre_master_secret = "\x03\x01aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbb"
     self.client_random = "a" * 32
     self.server_random = "z" * 32
     self.master_secret = binascii.unhexlify(
         "43278712b1feba3622c5745f79908a77b6e801239fc19390240cc45a17517b6218dfcb3f370c97f15329251e7a20ffb0")
     unittest.TestCase.setUp(self)
Ejemplo n.º 3
0
 def test_tls_1_1_defined_prf_raises_error(self):
     with self.assertRaises(ValueError):
         tlsc.TLSPRF(tls.TLSVersion.TLS_1_1, SHA)