def test_addVarSeq(self): w = Writer() w.addVarSeq([16, 17, 18], 2, 2) self.assertEqual( bytearray(b'\x00\x06' + b'\x00\x10' + b'\x00\x11' + b'\x00\x12'), w.bytes)
def test_addVarSeq_triple_byte_data(self): w = Writer() w.addVarSeq([0xaa, 0xbb, 0xcc], 3, 2) self.assertEqual( bytearray(b'\x00\x09' + b'\x00\x00\xaa' + b'\x00\x00\xbb' + b'\x00\x00\xcc'), w.bytes)
def extData(self): """Serialise the extension.""" if self.renegotiated_connection is None: return bytearray(0) writer = Writer() writer.addVarSeq(self.renegotiated_connection, 1, 1) return writer.bytes
def test_addVarSeq_triple_byte_data(self): w = Writer() w.addVarSeq([0xaa, 0xbb, 0xcc], 3, 2) self.assertEqual(bytearray( b'\x00\x09' + b'\x00\x00\xaa' + b'\x00\x00\xbb' + b'\x00\x00\xcc'), w.bytes)
def test_addVarSeq(self): w = Writer() w.addVarSeq([16, 17, 18], 2, 2) self.assertEqual(bytearray( b'\x00\x06' + b'\x00\x10' + b'\x00\x11' + b'\x00\x12'), w.bytes)
def _setup_tls13_handshake_keys(self, state): """Prepare handshake ciphers for the HRR handling""" prf_name = state.prf_name ch_hash = self._ch_hh.digest(prf_name) new_hh = HandshakeHashes() writer = Writer() writer.add(HandshakeType.message_hash, 1) writer.addVarSeq(ch_hash, 1, 3) new_hh.update(writer.bytes) new_hh.update(self._msg.write()) state.handshake_hashes = new_hh
def extData(self): """Serialise the extension.""" if self.client_shares is None: return bytearray(0) writer = Writer() for group_id, share in self.client_shares: writer.add(group_id, 2) if group_id in GroupName.allFF: share_length_length = 2 else: share_length_length = 1 writer.addVarSeq(share, 1, share_length_length) ext_writer = Writer() ext_writer.add(len(writer.bytes), 2) ext_writer.bytes += writer.bytes return ext_writer.bytes
def test_addVarSeq_with_three_byte_overflowing_data(self): w = Writer() with self.assertRaises(ValueError): w.addVarSeq([16, 17, 0x1000000], 3, 2)
def test_addVarSeq(self): w = Writer() w.addVarSeq([16, 17, 18], 2, 2) self.assertEqual(bytearray(b"\x00\x06" + b"\x00\x10" + b"\x00\x11" + b"\x00\x12"), w.bytes)