From ff4ee3ebac404cb067181a4c39e44731ff3123a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 30 Mar 2019 00:19:39 +0100 Subject: [PATCH 1/2] crypto: fail early if passphrase is too long This causes OpenSSL to fail early if the decryption passphrase is too long, and produces a somewhat helpful error message. Refs: https://github.com/nodejs/node/pull/25208 --- doc/api/crypto.md | 3 +++ src/node_crypto.cc | 3 ++- test/parallel/test-crypto-key-objects.js | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 35c15a7748ecc5..2a699ae73b5871 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1821,6 +1821,9 @@ Creates and returns a new key object containing a private key. If `key` is a string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above. +If the private key is encrypted, a `passphrase` must be specified. The length +of the passphrase is limited. + ### crypto.createPublicKey(key)