mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
crypto: assign and use ERR_CRYPTO_UNKNOWN_CIPHER
PR-URL: https://github.com/nodejs/node/pull/31437 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
085a5c7638
commit
8c313ceedf
5 files changed
+16
-4
No files matched your search
+3
-3
@@ -3531,7 +3531,7 @@ static NonCopyableMaybe<PrivateKeyEncodingConfig> GetPrivateKeyEncodingFromJs(
|
||||
args[*offset].As<String>());
|
||||
result.cipher_ = EVP_get_cipherbyname(*cipher_name);
|
||||
if (result.cipher_ == nullptr) {
|
||||
env->ThrowError("Unknown cipher");
|
||||
THROW_ERR_CRYPTO_UNKNOWN_CIPHER(env);
|
||||
return NonCopyableMaybe<PrivateKeyEncodingConfig>();
|
||||
}
|
||||
needs_passphrase = true;
|
||||
@@ -4037,7 +4037,7 @@ void CipherBase::Init(const char* cipher_type,
|
||||
|
||||
const EVP_CIPHER* const cipher = EVP_get_cipherbyname(cipher_type);
|
||||
if (cipher == nullptr)
|
||||
return env()->ThrowError("Unknown cipher");
|
||||
return THROW_ERR_CRYPTO_UNKNOWN_CIPHER(env());
|
||||
|
||||
unsigned char key[EVP_MAX_KEY_LENGTH];
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH];
|
||||
@@ -4101,7 +4101,7 @@ void CipherBase::InitIv(const char* cipher_type,
|
||||
|
||||
const EVP_CIPHER* const cipher = EVP_get_cipherbyname(cipher_type);
|
||||
if (cipher == nullptr) {
|
||||
return env()->ThrowError("Unknown cipher");
|
||||
return THROW_ERR_CRYPTO_UNKNOWN_CIPHER(env());
|
||||
}
|
||||
|
||||
const int expected_iv_len = EVP_CIPHER_iv_length(cipher);
|
||||
|
||||
@@ -39,6 +39,7 @@ void PrintErrorString(const char* format, ...);
|
||||
V(ERR_BUFFER_TOO_LARGE, Error) \
|
||||
V(ERR_CONSTRUCT_CALL_REQUIRED, TypeError) \
|
||||
V(ERR_CONSTRUCT_CALL_INVALID, TypeError) \
|
||||
V(ERR_CRYPTO_UNKNOWN_CIPHER, Error) \
|
||||
V(ERR_CRYPTO_UNKNOWN_DH_GROUP, Error) \
|
||||
V(ERR_INVALID_ARG_VALUE, TypeError) \
|
||||
V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \
|
||||
@@ -90,6 +91,7 @@ void PrintErrorString(const char* format, ...);
|
||||
"Buffer is not available for the current Context") \
|
||||
V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \
|
||||
V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \
|
||||
V(ERR_CRYPTO_UNKNOWN_CIPHER, "Unknown cipher") \
|
||||
V(ERR_CRYPTO_UNKNOWN_DH_GROUP, "Unknown DH group") \
|
||||
V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \
|
||||
V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \
|
||||
|
||||
Reference in new issue
Block a user