Example #1
0
 def send_raw(self, data):
     msg_len = len(data) >> 2
     tcp_stream = self._get_tcp_stream()
     if self._send_abridged_flag:
         tcp_stream.write(chr(0xef))
         self._send_abridged_flag = False
     if msg_len < 127:
         tcp_stream.write(Bytes.from_int(msg_len, 1, False))
     else:
         tcp_stream.write(chr(0x7f))
         tcp_stream.write(Bytes.from_int(msg_len, 3, False))
     tcp_stream.write(data)
Example #2
0
 def serialize_int32(i, signed=True):
     return Bytes.from_int(i, 4, False, signed)
Example #3
0
 def rsa_encrypt(plain, key):
     if isinstance(plain, Bytes):
         plain = plain.to_int(True)
     return Bytes.from_int(pow(plain, key.e, key.n), 256, True)
Example #4
0
 def serialize(self):
     ser_id = Bytes.from_int(self.ID, 4, False, False)
     ser_params = super(TLFunction, self).serialize()
     return ser_id + ser_params
Example #5
0
 def serialize_long(l, signed=True):
     return Bytes.from_int(l, 8, False, signed)
Example #6
0
	def serialize(self):
		v = self.get()
		return Bytes.from_int(v, 16, True)
Example #7
0
	def serialize(self):
		itos = Bytes.from_int(self.get(), self._byte_len, True, self._signed)
		tls = TL_string(itos)
		return tls.serialize()
Example #8
0
	def serialize(self):
		return Bytes.from_int(self.get(), 32, True, signed=self._signed)