aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CSecurityDH.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/CSecurityDH.cxx')
-rw-r--r--common/rfb/CSecurityDH.cxx31
1 files changed, 15 insertions, 16 deletions
diff --git a/common/rfb/CSecurityDH.cxx b/common/rfb/CSecurityDH.cxx
index c9b2a2cf..aab25671 100644
--- a/common/rfb/CSecurityDH.cxx
+++ b/common/rfb/CSecurityDH.cxx
@@ -39,7 +39,6 @@
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rdr/RandomStream.h>
-#include <rdr/types.h>
#include <rfb/Exception.h>
#include <os/os.h>
@@ -94,12 +93,12 @@ bool CSecurityDH::readKey()
return false;
is->clearRestorePoint();
mpz_set_ui(g, gen);
- rdr::U8Array pBytes(keyLength);
- rdr::U8Array ABytes(keyLength);
- is->readBytes(pBytes.buf, keyLength);
- is->readBytes(ABytes.buf, keyLength);
- nettle_mpz_set_str_256_u(p, keyLength, pBytes.buf);
- nettle_mpz_set_str_256_u(A, keyLength, ABytes.buf);
+ std::vector<uint8_t> pBytes(keyLength);
+ std::vector<uint8_t> ABytes(keyLength);
+ is->readBytes(pBytes.data(), pBytes.size());
+ is->readBytes(ABytes.data(), ABytes.size());
+ nettle_mpz_set_str_256_u(p, pBytes.size(), pBytes.data());
+ nettle_mpz_set_str_256_u(A, ABytes.size(), ABytes.data());
return true;
}
@@ -110,22 +109,22 @@ void CSecurityDH::writeCredentials()
rdr::RandomStream rs;
(CSecurity::upg)->getUserPasswd(isSecure(), &username.buf, &password.buf);
- rdr::U8Array bBytes(keyLength);
+ std::vector<uint8_t> bBytes(keyLength);
if (!rs.hasData(keyLength))
throw ConnFailedException("failed to generate DH private key");
- rs.readBytes(bBytes.buf, keyLength);
- nettle_mpz_set_str_256_u(b, keyLength, bBytes.buf);
+ rs.readBytes(bBytes.data(), bBytes.size());
+ nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
mpz_powm(B, g, b, p);
- rdr::U8Array sharedSecret(keyLength);
- rdr::U8Array BBytes(keyLength);
- nettle_mpz_get_str_256(keyLength, sharedSecret.buf, k);
- nettle_mpz_get_str_256(keyLength, BBytes.buf, B);
+ std::vector<uint8_t> sharedSecret(keyLength);
+ std::vector<uint8_t> BBytes(keyLength);
+ nettle_mpz_get_str_256(sharedSecret.size(), sharedSecret.data(), k);
+ nettle_mpz_get_str_256(BBytes.size(), BBytes.data(), B);
uint8_t key[16];
struct md5_ctx md5Ctx;
md5_init(&md5Ctx);
- md5_update(&md5Ctx, keyLength, sharedSecret.buf);
+ md5_update(&md5Ctx, sharedSecret.size(), sharedSecret.data());
md5_digest(&md5Ctx, 16, key);
struct aes128_ctx aesCtx;
aes128_set_encrypt_key(&aesCtx, key);
@@ -146,6 +145,6 @@ void CSecurityDH::writeCredentials()
rdr::OutStream* os = cc->getOutStream();
os->writeBytes(buf, 128);
- os->writeBytes(BBytes.buf, keyLength);
+ os->writeBytes(BBytes.data(), BBytes.size());
os->flush();
}