def test_derive_key_iv_hp(self): # client secret = binascii.unhexlify( "8a3515a14ae3c31b9c2d6d5bc58538ca5cd2baa119087143e60887428dcb52f6" ) key, iv, hp = derive_key_iv_hp(INITIAL_CIPHER_SUITE, secret) self.assertEqual(key, binascii.unhexlify("98b0d7e5e7a402c67c33f350fa65ea54")) self.assertEqual(iv, binascii.unhexlify("19e94387805eb0b46c03a788")) self.assertEqual(hp, binascii.unhexlify("0edd982a6ac527f2eddcbb7348dea5d7")) # server secret = binascii.unhexlify( "47b2eaea6c266e32c0697a9e2a898bdf5c4fb3e5ac34f0e549bf2c58581a3811" ) key, iv, hp = derive_key_iv_hp(INITIAL_CIPHER_SUITE, secret) self.assertEqual(key, binascii.unhexlify("9a8be902a9bdd91d16064ca118045fb4")) self.assertEqual(iv, binascii.unhexlify("0a82086d32205ba22241d8dc")) self.assertEqual(hp, binascii.unhexlify("94b9452d2b3c7c7f6da7fdd8593537fd"))
def test_derive_key_iv_hp(self): # https://tools.ietf.org/html/draft-ietf-quic-tls-34#appendix-A.1 # client secret = binascii.unhexlify( "c00cf151ca5be075ed0ebfb5c80323c42d6b7db67881289af4008f1f6c357aea") key, iv, hp = derive_key_iv_hp(INITIAL_CIPHER_SUITE, secret) self.assertEqual( key, binascii.unhexlify("1f369613dd76d5467730efcbe3b1a22d")) self.assertEqual(iv, binascii.unhexlify("fa044b2f42a3fd3b46fb255c")) self.assertEqual( hp, binascii.unhexlify("9f50449e04a0e810283a1e9933adedd2")) # server secret = binascii.unhexlify( "3c199828fd139efd216c155ad844cc81fb82fa8d7446fa7d78be803acdda951b") key, iv, hp = derive_key_iv_hp(INITIAL_CIPHER_SUITE, secret) self.assertEqual( key, binascii.unhexlify("cf3a5331653c364c88f0f379b6067e37")) self.assertEqual(iv, binascii.unhexlify("0ac1493ca1905853b0bba03e")) self.assertEqual( hp, binascii.unhexlify("c206b8d9b9f0f37644430b490eeaa314"))
def test_derive_key_iv_hp_chacha20(self): # https://tools.ietf.org/html/draft-ietf-quic-tls-34#appendix-A.5 # server secret = binascii.unhexlify( "9ac312a7f877468ebe69422748ad00a15443f18203a07d6060f688f30f21632b") key, iv, hp = derive_key_iv_hp(CipherSuite.CHACHA20_POLY1305_SHA256, secret) self.assertEqual( key, binascii.unhexlify( "c6d98ff3441c3fe1b2182094f69caa2ed4b716b65488960a7a984979fb23e1c8" ), ) self.assertEqual(iv, binascii.unhexlify("e0459b3474bdd0e44a41c144")) self.assertEqual( hp, binascii.unhexlify( "25a282b9e82f06f21f488917a4fc8f1b73573685608597d0efcb076b0ab7a7a4" ), )