std::vector<uint8_t> bBytes(keyLength);
if (!rs.hasData(keyLength))
- throw ConnFailedException("failed to generate DH private key");
+ throw Exception("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
uint8_t buf[128];
if (!rs.hasData(128))
- throw ConnFailedException("failed to generate random padding");
+ throw Exception("failed to generate random padding");
rs.readBytes(buf, 128);
if (username.size() >= 64)
throw Exception("username is too long");
std::vector<uint8_t> bBytes(8);
if (!rs.hasData(8))
- throw ConnFailedException("failed to generate DH private key");
+ throw Exception("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
}
if (!rs.hasData(256 + 64))
- throw ConnFailedException("failed to generate random padding");
+ throw Exception("failed to generate random padding");
rs.readBytes(user, 256);
rs.readBytes(pass, 64);
if (username.size() >= 256)
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw ConnFailedException("failed to generate random");
+ throw Exception("failed to generate random");
rs->readBytes(dst, length);
}
{
rdr::OutStream* os = cc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw ConnFailedException("failed to generate random");
+ throw Exception("failed to generate random");
rs.readBytes(clientRandom, keySize / 8);
mpz_t x;
mpz_init(x);
{
FILE* file = fopen(keyFile, "rb");
if (!file)
- throw ConnFailedException("failed to open key file");
+ throw Exception("failed to open key file");
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
if (size == 0 || size > MaxKeyFileSize) {
fclose(file);
- throw ConnFailedException("size of key file is zero or too big");
+ throw Exception("size of key file is zero or too big");
}
fseek(file, 0, SEEK_SET);
std::vector<uint8_t> data(size);
if (fread(data.data(), 1, data.size(), file) != size) {
fclose(file);
- throw ConnFailedException("failed to read key");
+ throw Exception("failed to read key");
}
fclose(file);
loadPKCS8Key(der.data(), der.size());
return;
}
- throw ConnFailedException("failed to import key");
+ throw Exception("failed to import key");
}
void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
rsa_private_key_clear(&serverKey);
rsa_public_key_clear(&pub);
- throw ConnFailedException("failed to import key");
+ throw Exception("failed to import key");
}
serverKeyLength = serverKey.size * 8;
serverKeyN = new uint8_t[serverKey.size];
loadPKCS1Key(i.data, i.length);
return;
failed:
- throw ConnFailedException("failed to import key");
+ throw Exception("failed to import key");
}
bool SSecurityRSAAES::processMsg()