Skip to content

Commit

Permalink
fix(OpenSSL): fuzz errors #4663
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Oct 31, 2024
1 parent a33dc34 commit 4db4ef0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions NetSSL_OpenSSL/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,20 +930,25 @@ void Context::initDH(KeyDHGroup keyDHGroup, const std::string& dhParamsFile)

BIGNUM* p = nullptr;
BIGNUM* g = nullptr;
if (use2048Bits)
if (keyDHGroup == KEY_DH_GROUP_2048)
{
p = BN_bin2bn(dh2048_p, sizeof(dh2048_p), 0);
g = BN_bin2bn(dh2048_g, sizeof(dh2048_g), 0);
DH_set0_pqg(dh, p, 0, g);
DH_set_length(dh, 256);
}
else
else if (keyDHGroup == KEY_DH_GROUP_1024)
{
p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
DH_set0_pqg(dh, p, 0, g);
DH_set_length(dh, 160);
}
else
{
throw Poco::NotImplementedException(Poco::format(
"DH Group: %d", static_cast<int>(keyDHGroup)));
}
if (!p || !g)
{
DH_free(dh);
Expand All @@ -952,18 +957,22 @@ void Context::initDH(KeyDHGroup keyDHGroup, const std::string& dhParamsFile)

#else // OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)

if (use2048Bits)
if (keyDHGroup == KEY_DH_GROUP_2048)
{
dh->p = BN_bin2bn(dh2048_p, sizeof(dh2048_p), 0);
dh->g = BN_bin2bn(dh2048_g, sizeof(dh2048_g), 0);
dh->length = 256;
}
else
else if (keyDHGroup == KEY_DH_GROUP_1024)
{
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
dh->length = 160;
}
{
throw Poco::NotImplementedException(Poco::format(
"DH Group: %d", static_cast<int>(keyDHGroup)));
}
if ((!dh->p) || (!dh->g))
{
DH_free(dh);
Expand Down

0 comments on commit 4db4ef0

Please sign in to comment.