From cb7bce6a6ca2e9f9689da506faba45bcef1b03cb Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 7 Jul 2019 18:22:11 +0200 Subject: [PATCH] Updated changelog --- src/protocol/CryptionHandler.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/protocol/CryptionHandler.cpp b/src/protocol/CryptionHandler.cpp index f5a8224..7250f9d 100644 --- a/src/protocol/CryptionHandler.cpp +++ b/src/protocol/CryptionHandler.cpp @@ -112,7 +112,7 @@ void _fe_neg(fe h, const fe f) { h[9] = h9; } -inline void keyMul(uint8_t(& target_buffer)[32], const uint8_t* publicKey /* compressed */, const uint8_t* privateKey /* uncompressed */, bool negate){ +inline void keyMul(uint8_t* target_buffer, const uint8_t* publicKey /* compressed */, const uint8_t* privateKey /* uncompressed */, bool negate){ ge_p3 keyA{}; ge_p2 result{}; @@ -130,20 +130,34 @@ bool CryptionHandler::setupSharedSecretNew(const std::string &alpha, const std:: if(alpha.length() != 10 || beta.length() != 54) return false; + /* uint8_t shared[32]; uint8_t shared_iv[64]; ed25519_key_exchange(shared, (uint8_t*) publicKey, (uint8_t*) privateKey); keyMul(shared, reinterpret_cast(publicKey), reinterpret_cast(privateKey), true); //Remote key get negated digest::sha512((char*) shared, 32, shared_iv); + */ + string shared; + string sharedIv; + shared.resize(32, '\0'); + sharedIv.resize(64, '\0'); + ed25519_key_exchange((uint8_t*) shared.data(), (uint8_t*) publicKey, (uint8_t*) privateKey); + keyMul(shared.data(), reinterpret_cast(publicKey), reinterpret_cast(privateKey), true); //Remote key get negated + sharedIv = digest::sha512(shared); + auto xor_key = alpha + beta; for(int i = 0; i < 64; i++) - shared_iv[i] ^= xor_key[i]; + //shared_iv[i] ^= xor_key[i]; + sharedIv[i] ^= xor_key[i]; + + { lock_guard lock(this->cache_key_lock); - memcpy(this->iv_struct, shared_iv, 64); + //memcpy(this->iv_struct, shared_iv, 64); + memcpy(this->iv_struct, sharedIv.data(), 64); this->iv_struct_length = 64; uint8_t mac_buffer[SHA_DIGEST_LENGTH];