Exemple #1
0
void RTMFP::WriteCRC(PacketWriter& packet) {
	// Compute the CRC and add it at the beginning of the request
	PacketReader reader(packet.begin(),packet.length());
	reader.next(6);
	UInt16 sum = CheckSum(reader);
	packet.reset(4);packet << sum;
}
Exemple #2
0
void RTMFP::Encode(AESEngine& aesEncrypt,PacketWriter packet) {
	// paddingBytesLength=(0xffffffff-plainRequestLength+5)&0x0F
	int paddingBytesLength = (0xFFFFFFFF-packet.length()+5)&0x0F;
	// Padd the plain request with paddingBytesLength of value 0xff at the end
	packet.reset(packet.length());
	string end(paddingBytesLength,(UInt8)0xFF);
	packet.writeRaw(end);
	// Compute the CRC and add it at the beginning of the request
	PacketReader reader(packet);
	reader.next(6);
	UInt16 sum = CheckSum(reader);
	packet.reset(4);packet << sum;
	
	// Encrypt the resulted request
	reader.reset(4);
	aesEncrypt.process(reader.current(),reader.current(),reader.available());
}
Exemple #3
0
void RTMFP::Encode(AESEngine& aesEncrypt,PacketWriter& packet) {
	if(aesEncrypt.type != AESEngine::EMPTY) {
		// paddingBytesLength=(0xffffffff-plainRequestLength+5)&0x0F
		int paddingBytesLength = (0xFFFFFFFF-packet.length()+5)&0x0F;
		// Padd the plain request with paddingBytesLength of value 0xff at the end
		packet.reset(packet.length());
		string end(paddingBytesLength,(UInt8)0xFF);
		packet.writeRaw(end);
	}

	WriteCRC(packet);
	
	// Encrypt the resulted request
	aesEncrypt.process(packet.begin()+4,packet.begin()+4,packet.length()-4);
}
Exemple #4
0
void RTMFP::Pack(PacketWriter& packet,UInt32 farId) {
	PacketReader reader(packet.begin(),packet.length());
	reader.next(4);
	packet.reset(0);
	packet.write32(reader.read32()^reader.read32()^farId);
}
Exemple #5
0
void RTMFP::Pack(PacketWriter packet,UInt32 farId) {
	packet.reset();
	PacketReader reader(packet);
	reader.read32();
	packet.write32(reader.read32()^reader.read32()^farId);
}