Exemplo n.º 1
0
void RTMFPReceiving::run() {
	if(!pPacket) {
		ERROR("RTMFPReceiving on session %u with a null packet",id);
		return;
	}
	if(!RTMFP::Decode(decoder,*pPacket)) {
		ERROR("Decrypt error on session %u",id);
		return;
	}
	waitHandle();
}
Exemplo n.º 2
0
bool RTMFPCookieComputing::run(Exception& ex) {
	// First execution is for the DH computing if pDH == null, else it's to compute Diffie-Hellman keys
	if (!_diffieHellman.initialized())
		return _diffieHellman.initialize(ex);

	// Compute Diffie-Hellman secret
	_diffieHellman.computeSecret(ex,initiatorKey.data(),initiatorKey.size(),_sharedSecret);
	if (ex)
		return false;

	if (packet.size() > 0) {
		ex.set(Exception::CRYPTO, "RTMFPCookieComputing already executed");
		return false;
	}

	// string hex;
	// DEBUG("Shared Secret : ", Util::FormatHex(_sharedSecret.data(), _sharedSecret.size(), hex));

	// It's our key public part
	int size = _diffieHellman.publicKeySize(ex);
	if (size<0) {
		if (!ex)
			ex.set(Exception::CRYPTO, "DH public key not initialized");
		return false;
	}
	packet.write7BitLongValue(size+11);
	UInt32 noncePos = packet.size();
	packet.writeRaw(EXPAND_DATA_SIZE("\x03\x1A\x00\x00\x02\x1E\x00"));
	UInt8 byte2 = DH_KEY_SIZE-size;
	if(byte2>2) {
		CRITIC("Generation DH key with less of 126 bytes!");
		byte2=2;
	}
	packet.write8(0x81);
	packet.write8(2-byte2);
	packet.write8(0x0D);
	packet.write8(0x02);
	if (size>2000)
		ERROR("RTMFP diffie hellman public key with an error size key of ",size) // TODO remove this log one time fixed!
	_diffieHellman.readPublicKey(ex,packet.buffer(size));
	packet.write8(0x58);

	// Compute Keys
	RTMFP::ComputeAsymetricKeys(_sharedSecret,initiatorNonce.data(),initiatorNonce.size(),packet.data()+noncePos,size+11,decryptKey,encryptKey);
	
	waitHandle();
	return true;
}
Exemplo n.º 3
0
 void run() {
     setPriority(Thread::PRIO_LOW);
     do {
         waitHandle();
     } while(sleep(2000)!=STOP);
 }