Skip to content

Commit 5b1484d

Browse files
committed
src: turn key length exception into CHECK
This exception can logically never happen because of the key stretching that takes place first. Failure must therefore be a bug in Node.js and not in the executing script. PR-URL: nodejs#15183 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 07e141c commit 5b1484d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/node_crypto.cc

+1-4
Original file line numberDiff line numberDiff line change
@@ -3363,10 +3363,7 @@ void CipherBase::Init(const char* cipher_type,
33633363
if (mode == EVP_CIPH_WRAP_MODE)
33643364
EVP_CIPHER_CTX_set_flags(&ctx_, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
33653365

3366-
if (!EVP_CIPHER_CTX_set_key_length(&ctx_, key_len)) {
3367-
EVP_CIPHER_CTX_cleanup(&ctx_);
3368-
return env()->ThrowError("Invalid key length");
3369-
}
3366+
CHECK_EQ(1, EVP_CIPHER_CTX_set_key_length(&ctx_, key_len));
33703367

33713368
EVP_CipherInit_ex(&ctx_,
33723369
nullptr,

0 commit comments

Comments
 (0)