def on_connected(self):
self.state = YY_CLIENT_HANDSHAKING
proto = YYProto_pb2.YYProto()
(pub_key, pri_key) = rsa.newkeys(512, 3)
self.rsa_pub_key = pub_key
self.rsa_pri_key = pri_key
proto.cmd = 0x1
proto.key_req.f1 = chr(0x01) + chr(0x00) + chr(0x01)
rsa_key = rsa.transform.int2bytes(pub_key.n)
reversed(rsa_key)
proto.key_req.rsa_key = chr(0x00) + rsa_key
buffer = proto.SerializeToString()
#hexdump.hexdump(buffer)
self.stream.write(struct.pack('I', len(buffer)) + buffer)
评论列表
文章目录