示例#1
0
文件: RTMFP.cpp 项目: 191919/Cumulus
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);
}
示例#2
0
文件: RTMFP.cpp 项目: 191919/Cumulus
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;
}
示例#3
0
文件: RTMFP.cpp 项目: agazso/Cumulus
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());
}
示例#4
0
文件: RTMFP.cpp 项目: 191919/Cumulus
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);
}