Fixed RTMP handshake bug. Yay!

This commit is contained in:
Thulinma 2014-05-14 17:06:58 +02:00
parent c973e5060c
commit cb31d8bb48

View file

@ -169,10 +169,7 @@ bool DHWrapper::CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length){
return false; return false;
} }
if (DH_compute_key(_pSharedKey, _peerPublickey, _pDH) != _sharedKeyLength){ DH_compute_key(_pSharedKey, _peerPublickey, _pDH);
return false;
}
return true; return true;
} }
@ -840,13 +837,21 @@ bool RTMPStream::doHandshake(){
//generate DH key //generate DH key
DHWrapper dhWrapper(1024); DHWrapper dhWrapper(1024);
if ( !dhWrapper.Initialize()) return false; if ( !dhWrapper.Initialize()){
if ( !dhWrapper.CreateSharedKey(Client + clientDHOffset, 128)) return false; return false;
if ( !dhWrapper.CopyPublicKey(Server + serverDHOffset, 128)) return false; }
if ( !dhWrapper.CreateSharedKey(Client + clientDHOffset, 128)){
return false;
}
if ( !dhWrapper.CopyPublicKey(Server + serverDHOffset, 128)){
return false;
}
if (encrypted){ if (encrypted){
uint8_t secretKey[128]; uint8_t secretKey[128];
if ( !dhWrapper.CopySharedKey(secretKey, sizeof(secretKey))) return false; if ( !dhWrapper.CopySharedKey(secretKey, sizeof(secretKey))){
return false;
}
RC4_KEY _pKeyIn; RC4_KEY _pKeyIn;
RC4_KEY _pKeyOut; RC4_KEY _pKeyOut;
InitRC4Encryption(secretKey, (uint8_t*) &Client[clientDHOffset], (uint8_t*) &Server[serverDHOffset], &_pKeyIn, &_pKeyOut); InitRC4Encryption(secretKey, (uint8_t*) &Client[clientDHOffset], (uint8_t*) &Server[serverDHOffset], &_pKeyIn, &_pKeyOut);