Skip to content

Commit 79171e0

Browse files
bnoordhuisMylesBorins
authored andcommitted
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. Backport-PR-URL: #16585 PR-URL: #15183 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f2cafff commit 79171e0

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
@@ -3362,10 +3362,7 @@ void CipherBase::Init(const char* cipher_type,
33623362
if (mode == EVP_CIPH_WRAP_MODE)
33633363
EVP_CIPHER_CTX_set_flags(&ctx_, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
33643364

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

33703367
EVP_CipherInit_ex(&ctx_,
33713368
nullptr,

0 commit comments

Comments
 (0)