From 7c1fc93e30e4dac664782c7d229823fd10fa71ba Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Tue, 19 Mar 2019 21:38:23 +0100 Subject: [PATCH] crypto: don't crash on unknown asymmetricKeyType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/26786 Fixes: https://github.com/nodejs/node/issues/26775 Reviewed-By: Sam Roberts Reviewed-By: Tobias Nießen --- doc/api/crypto.md | 9 ++++++-- src/node_crypto.cc | 4 ++-- src/node_crypto.h | 2 +- test/fixtures/test_unknown_privkey.pem | 28 ++++++++++++++++++++++++ test/parallel/test-crypto-key-objects.js | 7 ++++++ 5 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/test_unknown_privkey.pem diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 35c15a7748ecc5..480930898eced0 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1129,18 +1129,23 @@ passing keys as strings or `Buffer`s due to improved security features. * {string} For asymmetric keys, this property represents the type of the embedded key (`'rsa'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'` or `'x448'`). -This property is `undefined` for symmetric keys. +This property is `undefined` for unrecognized `KeyObject` types and symmetric +keys. ### keyObject.export([options])