From 79171e0c2f16fff17f5ab7a4899b2be0c2574c17 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 27 Aug 2017 06:31:59 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/16585 PR-URL: https://github.com/nodejs/node/pull/15183 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node_crypto.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 4941d96655a9bf..b4c338aa59c34e 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -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,