Exemplo n.º 1
0
	def aes_ctr_crypt(key, data_orig, ctr_val):
		data = [x for x in data_orig]
		AESr = AES.new(_OT.bytes_to_cbytes(key), AES.MODE_CTR, counter=OtrCrypt.aes_counter(ctr_val))
		# need to fill to a multiple of 16; since it is in 
		# counter mode, we can just ignore the end of the encrypted output
		fill_len = (16 - (len(data) % 16)) % 16
		data.extend([0]*fill_len)
		# do the encryption
		enc_str = AESr.encrypt(_OT.bytes_to_cbytes(data))
		return _OT.string_to_bytes(enc_str[:-fill_len])
Exemplo n.º 2
0
	def pack_message(self, bytes):
		message_data = _OT.bytes_to_cbytes(bytes)
		message_data_str = base64.b64encode(message_data)
		body_str = "?OTR:" + message_data_str+"."
		self.jabber_msg = self.make_jabber_message(body_str)