From 73bca57988c847a4b17b923686eee8e04e4fa13c 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] 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. PR-URL: https://github.com/nodejs/node/pull/27010 Refs: https://github.com/nodejs/node/pull/25208 Reviewed-By: Ruben Bridgewater Reviewed-By: Sam Roberts --- doc/api/crypto.md | 3 +++ src/node_crypto.cc | 3 ++- test/parallel/test-crypto-key-objects.js | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 480930898eced0..4cacde0d8e9083 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1826,6 +1826,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 to 1024 bytes. + ### crypto.createPublicKey(key)