Skip to content

Instantly share code, notes, and snippets.

@j0sh
Created September 29, 2011 23:24
Show Gist options
  • Save j0sh/1252217 to your computer and use it in GitHub Desktop.
Save j0sh/1252217 to your computer and use it in GitHub Desktop.
diff --git a/sources/common/src/utils/misc/crypto.cpp b/sources/common/src/utils/misc/crypto.cpp
index 9d4e20a..ed41c71 100644
--- a/sources/common/src/utils/misc/crypto.cpp
+++ b/sources/common/src/utils/misc/crypto.cpp
@@ -119,6 +119,7 @@ bool DHWrapper::CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length) {
return false;
}
_pSharedKey = new uint8_t[_sharedKeyLength];
+ memset(_pSharedKey, 0, _sharedKeyLength);
_peerPublickey = BN_bin2bn(pPeerPublicKey, length, 0);
if (_peerPublickey == NULL) {
@@ -126,7 +127,7 @@ bool DHWrapper::CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length) {
return false;
}
- if (DH_compute_key(_pSharedKey, _peerPublickey, _pDH) != _sharedKeyLength) {
+ if (DH_compute_key(_pSharedKey, _peerPublickey, _pDH) == -1) {
FATAL("Unable to compute the shared key");
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment