diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-11-22 14:27:02 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-11-22 14:27:02 +0100 |
commit | 895b751c92775f7610869a205d58a0a7c98632e0 (patch) | |
tree | a2182b8a5ddee92e0d649968e50842572072addf /common/rfb/CSecurityRSAAES.cxx | |
parent | 9366d8e54c5ee1c2cfcf333a17b7fd4bdbd13993 (diff) | |
download | tigervnc-895b751c92775f7610869a205d58a0a7c98632e0.tar.gz tigervnc-895b751c92775f7610869a205d58a0a7c98632e0.zip |
Capitalize some more logging and exceptions
Diffstat (limited to 'common/rfb/CSecurityRSAAES.cxx')
-rw-r--r-- | common/rfb/CSecurityRSAAES.cxx | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx index 96fd20cd..416eaa2d 100644 --- a/common/rfb/CSecurityRSAAES.cxx +++ b/common/rfb/CSecurityRSAAES.cxx @@ -134,7 +134,7 @@ static void random_func(void* ctx, size_t length, uint8_t* dst) { rdr::RandomStream* rs = (rdr::RandomStream*)ctx; if (!rs->hasData(length)) - throw std::runtime_error("failed to generate random"); + throw std::runtime_error("Failed to generate random"); rs->readBytes(dst, length); } @@ -155,7 +155,7 @@ void CSecurityRSAAES::writePublicKey() if (!rsa_generate_keypair(&clientPublicKey, &clientKey, &rs, random_func, nullptr, nullptr, clientKeyLength, 0)) - throw std::runtime_error("failed to generate key"); + throw std::runtime_error("Failed to generate key"); clientKeyN = new uint8_t[rsaKeySize]; clientKeyE = new uint8_t[rsaKeySize]; nettle_mpz_get_str_256(rsaKeySize, clientKeyN, clientPublicKey.n); @@ -174,9 +174,9 @@ bool CSecurityRSAAES::readPublicKey() is->setRestorePoint(); serverKeyLength = is->readU32(); if (serverKeyLength < MinKeyLength) - throw protocol_error("server key is too short"); + throw protocol_error("Server key is too short"); if (serverKeyLength > MaxKeyLength) - throw protocol_error("server key is too long"); + throw protocol_error("Server key is too long"); size_t size = (serverKeyLength + 7) / 8; if (!is->hasDataOrRestore(size * 2)) return false; @@ -189,7 +189,7 @@ bool CSecurityRSAAES::readPublicKey() nettle_mpz_set_str_256_u(serverKey.n, size, serverKeyN); nettle_mpz_set_str_256_u(serverKey.e, size, serverKeyE); if (!rsa_public_key_prepare(&serverKey)) - throw protocol_error("server key is invalid"); + throw protocol_error("Server key is invalid"); return true; } @@ -222,7 +222,7 @@ void CSecurityRSAAES::writeRandom() { rdr::OutStream* os = cc->getOutStream(); if (!rs.hasData(keySize / 8)) - throw std::runtime_error("failed to generate random"); + throw std::runtime_error("Failed to generate random"); rs.readBytes(clientRandom, keySize / 8); mpz_t x; mpz_init(x); @@ -236,7 +236,7 @@ void CSecurityRSAAES::writeRandom() } if (!res) { mpz_clear(x); - throw std::runtime_error("failed to encrypt random"); + throw std::runtime_error("Failed to encrypt random"); } uint8_t* buffer = new uint8_t[serverKey.size]; nettle_mpz_get_str_256(serverKey.size, buffer, x); @@ -255,7 +255,7 @@ bool CSecurityRSAAES::readRandom() is->setRestorePoint(); size_t size = is->readU16(); if (size != clientKey.size) - throw protocol_error("client key length doesn't match"); + throw protocol_error("Client key length doesn't match"); if (!is->hasDataOrRestore(size)) return false; is->clearRestorePoint(); @@ -268,7 +268,7 @@ bool CSecurityRSAAES::readRandom() if (!rsa_decrypt(&clientKey, &randomSize, serverRandom, x) || randomSize != (size_t)keySize / 8) { mpz_clear(x); - throw protocol_error("failed to decrypt server random"); + throw protocol_error("Failed to decrypt server random"); } mpz_clear(x); return true; @@ -397,7 +397,7 @@ bool CSecurityRSAAES::readHash() sha256_digest(&ctx, hashSize, realHash); } if (memcmp(hash, realHash, hashSize) != 0) - throw protocol_error("hash doesn't match"); + throw protocol_error("Hash doesn't match"); return true; } @@ -427,7 +427,7 @@ bool CSecurityRSAAES::readSubtype() return false; subtype = rais->readU8(); if (subtype != secTypeRA2UserPass && subtype != secTypeRA2Pass) - throw protocol_error("unknown RSA-AES subtype"); + throw protocol_error("Unknown RSA-AES subtype"); return true; } @@ -443,7 +443,7 @@ void CSecurityRSAAES::writeCredentials() if (subtype == secTypeRA2UserPass) { if (username.size() > 255) - throw std::out_of_range("username is too long"); + throw std::out_of_range("Username is too long"); raos->writeU8(username.size()); raos->writeBytes((const uint8_t*)username.data(), username.size()); } else { @@ -451,7 +451,7 @@ void CSecurityRSAAES::writeCredentials() } if (password.size() > 255) - throw std::out_of_range("password is too long"); + throw std::out_of_range("Password is too long"); raos->writeU8(password.size()); raos->writeBytes((const uint8_t*)password.data(), password.size()); raos->flush(); |