Skip to content

Commit

Permalink
src: turn key length exception into CHECK
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bnoordhuis authored and MylesBorins committed Nov 14, 2017
1 parent 12036af commit 8b70ad1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3362,10 +3362,7 @@ void CipherBase::Init(const char* cipher_type,
if (mode == EVP_CIPH_WRAP_MODE)
EVP_CIPHER_CTX_set_flags(&ctx_, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);

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

EVP_CipherInit_ex(&ctx_,
nullptr,
Expand Down

0 comments on commit 8b70ad1

Please sign in to comment.