From cb31d8bb48019e976f2e8dc69f98f5584739a942 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 14 May 2014 17:06:58 +0200 Subject: [PATCH] Fixed RTMP handshake bug. Yay! --- lib/rtmpchunks.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/rtmpchunks.cpp b/lib/rtmpchunks.cpp index b4b307e5..9d61f02d 100644 --- a/lib/rtmpchunks.cpp +++ b/lib/rtmpchunks.cpp @@ -169,10 +169,7 @@ bool DHWrapper::CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length){ return false; } - if (DH_compute_key(_pSharedKey, _peerPublickey, _pDH) != _sharedKeyLength){ - return false; - } - + DH_compute_key(_pSharedKey, _peerPublickey, _pDH); return true; } @@ -840,13 +837,21 @@ bool RTMPStream::doHandshake(){ //generate DH key DHWrapper dhWrapper(1024); - if ( !dhWrapper.Initialize()) return false; - if ( !dhWrapper.CreateSharedKey(Client + clientDHOffset, 128)) return false; - if ( !dhWrapper.CopyPublicKey(Server + serverDHOffset, 128)) return false; + if ( !dhWrapper.Initialize()){ + return false; + } + if ( !dhWrapper.CreateSharedKey(Client + clientDHOffset, 128)){ + return false; + } + if ( !dhWrapper.CopyPublicKey(Server + serverDHOffset, 128)){ + return false; + } if (encrypted){ 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 _pKeyOut; InitRC4Encryption(secretKey, (uint8_t*) &Client[clientDHOffset], (uint8_t*) &Server[serverDHOffset], &_pKeyIn, &_pKeyOut);