Skip to content

Commit 59aec29

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. PR-URL: #15183 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c0033c4 commit 59aec29

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
@@ -3352,10 +3352,7 @@ void CipherBase::Init(const char* cipher_type,
33523352
if (mode == EVP_CIPH_WRAP_MODE)
33533353
EVP_CIPHER_CTX_set_flags(&ctx_, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
33543354

3355-
if (!EVP_CIPHER_CTX_set_key_length(&ctx_, key_len)) {
3356-
EVP_CIPHER_CTX_cleanup(&ctx_);
3357-
return env()->ThrowError("Invalid key length");
3358-
}
3355+
CHECK_EQ(1, EVP_CIPHER_CTX_set_key_length(&ctx_, key_len));
33593356

33603357
EVP_CipherInit_ex(&ctx_,
33613358
nullptr,

0 commit comments

Comments
 (0)