Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: don't claim errors come from within OpenSSL #44560

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/crypto/crypto_dh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,11 @@ bool DiffieHellman::Init(BignumPointer&& bn_p, int g) {
bool DiffieHellman::Init(const char* p, int p_len, int g) {
dh_.reset(DH_new());
if (p_len <= 0) {
ERR_put_error(ERR_LIB_BN, BN_F_BN_GENERATE_PRIME_EX,
BN_R_BITS_TOO_SMALL, __FILE__, __LINE__);
ERR_put_error(ERR_LIB_BN, 0, BN_R_BITS_TOO_SMALL, __FILE__, __LINE__);
return false;
}
if (g <= 1) {
ERR_put_error(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS,
DH_R_BAD_GENERATOR, __FILE__, __LINE__);
ERR_put_error(ERR_LIB_DH, 0, DH_R_BAD_GENERATOR, __FILE__, __LINE__);
return false;
}
BIGNUM* bn_p =
Expand All @@ -178,21 +176,18 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) {
dh_.reset(DH_new());
if (p_len <= 0) {
ERR_put_error(ERR_LIB_BN, BN_F_BN_GENERATE_PRIME_EX,
BN_R_BITS_TOO_SMALL, __FILE__, __LINE__);
ERR_put_error(ERR_LIB_BN, 0, BN_R_BITS_TOO_SMALL, __FILE__, __LINE__);
return false;
}
if (g_len <= 0) {
ERR_put_error(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS,
DH_R_BAD_GENERATOR, __FILE__, __LINE__);
ERR_put_error(ERR_LIB_DH, 0, DH_R_BAD_GENERATOR, __FILE__, __LINE__);
return false;
}
BIGNUM* bn_g =
BN_bin2bn(reinterpret_cast<const unsigned char*>(g), g_len, nullptr);
if (BN_is_zero(bn_g) || BN_is_one(bn_g)) {
BN_free(bn_g);
ERR_put_error(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS,
DH_R_BAD_GENERATOR, __FILE__, __LINE__);
ERR_put_error(ERR_LIB_DH, 0, DH_R_BAD_GENERATOR, __FILE__, __LINE__);
return false;
}
BIGNUM* bn_p =
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/crypto_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ bool Hash::HashInit(const EVP_MD* md, Maybe<unsigned int> xof_md_len) {
// This is a little hack to cause createHash to fail when an incorrect
// hashSize option was passed for a non-XOF hash function.
if ((EVP_MD_flags(md) & EVP_MD_FLAG_XOF) == 0) {
EVPerr(EVP_F_EVP_DIGESTFINALXOF, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
EVPerr(0, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
return false;
}
md_len_ = xof_md_len.FromJust();
Expand Down