aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CSecurityRSAAES.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-03 08:01:39 +0200
committerPierre Ossman <ossman@cendio.se>2024-11-06 21:06:27 +0100
commite4c60ef1985164d1207352bbfdf57ae1d7838404 (patch)
tree737d0db13dca148683ad02de5482c6a88e8d5275 /common/rfb/CSecurityRSAAES.cxx
parent1d9b2f9984fefbc050c8e3295397ffd280e41788 (diff)
downloadtigervnc-e4c60ef1985164d1207352bbfdf57ae1d7838404.tar.gz
tigervnc-e4c60ef1985164d1207352bbfdf57ae1d7838404.zip
Use specific class for protocol problems
Make it easier to identify communication issues.
Diffstat (limited to 'common/rfb/CSecurityRSAAES.cxx')
-rw-r--r--common/rfb/CSecurityRSAAES.cxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx
index 37b59532..11c392d5 100644
--- a/common/rfb/CSecurityRSAAES.cxx
+++ b/common/rfb/CSecurityRSAAES.cxx
@@ -174,9 +174,9 @@ bool CSecurityRSAAES::readPublicKey()
is->setRestorePoint();
serverKeyLength = is->readU32();
if (serverKeyLength < MinKeyLength)
- throw Exception("server key is too short");
+ throw ProtocolException("server key is too short");
if (serverKeyLength > MaxKeyLength)
- throw Exception("server key is too long");
+ throw ProtocolException("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 Exception("server key is invalid");
+ throw ProtocolException("server key is invalid");
return true;
}
@@ -255,7 +255,7 @@ bool CSecurityRSAAES::readRandom()
is->setRestorePoint();
size_t size = is->readU16();
if (size != clientKey.size)
- throw Exception("client key length doesn't match");
+ throw ProtocolException("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 Exception("failed to decrypt server random");
+ throw ProtocolException("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 Exception("hash doesn't match");
+ throw ProtocolException("hash doesn't match");
return true;
}
@@ -427,7 +427,7 @@ bool CSecurityRSAAES::readSubtype()
return false;
subtype = rais->readU8();
if (subtype != secTypeRA2UserPass && subtype != secTypeRA2Pass)
- throw Exception("unknown RSA-AES subtype");
+ throw ProtocolException("unknown RSA-AES subtype");
return true;
}