Totally lost in it. dh2. Agree returns half-different (second 32byte differs) value every time. It is so because we generate ephemeral our private every time. But how we in such case do anything with obtained derivedKey? Or should I use only my private + other's epheeral?
CryptoPP::DH2 dh2(dh); //loading keys: //our private CryptoPP::SecByteBlock privKey; size_t encodedSize = priv_int.MinEncodedSize(CryptoPP::Integer::UNSIGNED); privKey.resize(encodedSize); priv_int.Encode(privKey.BytePtr(), encodedSize, CryptoPP::Integer::UNSIGNED ); //generating our ephemeral private CryptoPP::AutoSeededRandomPool rnd; CryptoPP::SecByteBlock ephPrivKey(dh2.EphemeralPrivateKeyLength()); dh2.GenerateEphemeralPrivateKey(rnd, ephPrivKey); //google public CryptoPP::SecByteBlock g_pubKey((const CryptoPP::byte*) google_public_key. data(), dh2.StaticPublicKeyLength()); //google ephemeral public CryptoPP::SecByteBlock g_ephKey((const CryptoPP::byte*) google_ephemeral_pub_key.data(), dh2.EphemeralPublicKeyLength()); //TEST - retrieving our part of sharing secret (our_private * thir_pub) CryptoPP::SecByteBlock sharedA(dh.AgreedValueLength()); dh.Agree(sharedA,privKey,g_pubKey); string str_shared_secret((const char*)sharedA.data(), sharedA.size()); //deriving shared secret CryptoPP::SecByteBlock shared_secret(dh2.AgreedValueLength()); bool get_shared = dh2.Agree(shared_secret, privKey, ephPrivKey, g_pubKey, g_ephKey); //converting from bytes to string string str_shared_secret((const char*)shared_secret.data(), 64); If anybody knows how to help - it is great time to do it! -- You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
