From 85d71bb6d30287e2b56d2b88b2a4c06213c363a6 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 7 Nov 2022 07:35:25 +0100 Subject: [PATCH] crypto: handle unsupported AES ciphers in webcrypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/electron/electron/issues/36256 PR-URL: https://github.com/nodejs/node/pull/45321 Reviewed-By: Antoine du Hamel Reviewed-By: Daeyeon Jeong Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Shelley Vohr --- src/crypto/crypto_aes.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crypto/crypto_aes.cc b/src/crypto/crypto_aes.cc index 5f84e21fc23763..c1c5bf762a765f 100644 --- a/src/crypto/crypto_aes.cc +++ b/src/crypto/crypto_aes.cc @@ -556,7 +556,10 @@ Maybe AESCipherTraits::AdditionalConfig( } params->cipher = EVP_get_cipherbynid(cipher_nid); - CHECK_NOT_NULL(params->cipher); + if (params->cipher == nullptr) { + THROW_ERR_CRYPTO_UNKNOWN_CIPHER(env); + return Nothing(); + } if (params->iv.size() < static_cast(EVP_CIPHER_iv_length(params->cipher))) {