From 946c770b5fbc548f70a493d0322b119cffc220c0 Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Tue, 17 Jan 2017 18:59:55 +0900 Subject: [PATCH] crypto: Add crypto.getEngines() This adds a new api to show the list of loaded engines of OpenSSL. It also includes the test of dynamic engine for `crypto.setEngine()`. --- doc/api/crypto.md | 19 ++++++ lib/crypto.js | 3 + node.gyp | 12 ++++ src/env.h | 1 + src/node_crypto.cc | 31 ++++++++++ src/node_crypto.h | 1 + .../openssl_test_engine/node_test_engine.c | 14 +++++ .../openssl_test_engine/node_test_engine.gypi | 39 ++++++++++++ test/parallel/test-crypto-engine.js | 62 +++++++++++++++++++ 9 files changed, 182 insertions(+) create mode 100644 test/fixtures/openssl_test_engine/node_test_engine.c create mode 100644 test/fixtures/openssl_test_engine/node_test_engine.gypi diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 077c244c431d03..696d7faf94d941 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1698,6 +1698,25 @@ is a bit field taking one of or a mix of the following flags (defined in * `crypto.constants.ENGINE_METHOD_ALL` * `crypto.constants.ENGINE_METHOD_NONE` +### crypto.getEngines() + + +Returns an array of objects with id, name and flags of loaded engines. +The flags value represents an integer of one of or a mix of the crypto +constants described above. + +```js +const crypto = require('crypto'); +console.log(crypto.getEngines()); +// Prints: +// [ { id: 'rdrand', name: 'Intel RDRAND engine', flags: 8 }, +// { id: 'dynamic', +// name: 'Dynamic engine loading support', +// flags: 4 } ] +``` + ### crypto.timingSafeEqual(a, b)