Commit 7b1b1267 authored by Jari Sundell's avatar Jari Sundell

Merge pull request #81 from RobertBorg/master

fixes #45
parents 72e90870 a88a8eee
......@@ -289,7 +289,8 @@ Handshake::read_encryption_key() {
if (m_incoming)
prepare_key_plus_pad();
m_encryption.key()->compute_secret(m_readBuffer.position(), 96);
if(!m_encryption.key()->compute_secret(m_readBuffer.position(), 96))
throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_encryption);
m_readBuffer.consume(96);
// Determine the synchronisation string.
......
......@@ -80,7 +80,7 @@ DiffieHellman::is_valid() const {
#endif
}
void
bool
DiffieHellman::compute_secret(const unsigned char *pubkey, unsigned int length) {
#ifdef USE_OPENSSL
BIGNUM* k = BN_bin2bn(pubkey, length, NULL);
......@@ -91,6 +91,10 @@ DiffieHellman::compute_secret(const unsigned char *pubkey, unsigned int length)
m_size = DH_compute_key((unsigned char*)m_secret, k, m_dh);
BN_free(k);
return m_size != -1;
#else
return false;
#endif
};
......
......@@ -53,7 +53,7 @@ public:
const unsigned char generator[], int generatorLength);
~DiffieHellman();
void compute_secret(const unsigned char pubkey[], unsigned int length);
bool compute_secret(const unsigned char pubkey[], unsigned int length);
void store_pub_key(unsigned char* dest, unsigned int length);
bool is_valid() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment