crypto: expose KeyObject class
PR-URL: https://github.com/nodejs/node/pull/26438 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
6913bd183b
commit
f1056542f0
@ -1109,14 +1109,18 @@ This can be called many times with new data as it is streamed.
|
|||||||
## Class: KeyObject
|
## Class: KeyObject
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v11.6.0
|
added: v11.6.0
|
||||||
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/26438
|
||||||
|
description: This class is now exported.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Node.js uses an internal `KeyObject` class which should not be accessed
|
Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
|
||||||
directly. Instead, factory functions exist to create instances of this class
|
and each kind of key exposes different functions. The
|
||||||
in a secure manner, see [`crypto.createSecretKey()`][],
|
[`crypto.createSecretKey()`][], [`crypto.createPublicKey()`][] and
|
||||||
[`crypto.createPublicKey()`][] and [`crypto.createPrivateKey()`][]. A
|
[`crypto.createPrivateKey()`][] methods are used to create `KeyObject`
|
||||||
`KeyObject` can represent a symmetric or asymmetric key, and each kind of key
|
instances. `KeyObject` objects are not to be created directly using the `new`
|
||||||
exposes different functions.
|
keyword.
|
||||||
|
|
||||||
Most applications should consider using the new `KeyObject` API instead of
|
Most applications should consider using the new `KeyObject` API instead of
|
||||||
passing keys as strings or `Buffer`s due to improved security features.
|
passing keys as strings or `Buffer`s due to improved security features.
|
||||||
|
@ -60,7 +60,8 @@ const {
|
|||||||
const {
|
const {
|
||||||
createSecretKey,
|
createSecretKey,
|
||||||
createPublicKey,
|
createPublicKey,
|
||||||
createPrivateKey
|
createPrivateKey,
|
||||||
|
KeyObject,
|
||||||
} = require('internal/crypto/keys');
|
} = require('internal/crypto/keys');
|
||||||
const {
|
const {
|
||||||
DiffieHellman,
|
DiffieHellman,
|
||||||
@ -191,6 +192,7 @@ module.exports = exports = {
|
|||||||
ECDH,
|
ECDH,
|
||||||
Hash,
|
Hash,
|
||||||
Hmac,
|
Hmac,
|
||||||
|
KeyObject,
|
||||||
Sign,
|
Sign,
|
||||||
Verify
|
Verify
|
||||||
};
|
};
|
||||||
|
@ -333,6 +333,7 @@ module.exports = {
|
|||||||
createSecretKey,
|
createSecretKey,
|
||||||
createPublicKey,
|
createPublicKey,
|
||||||
createPrivateKey,
|
createPrivateKey,
|
||||||
|
KeyObject,
|
||||||
|
|
||||||
// These are designed for internal use only and should not be exposed.
|
// These are designed for internal use only and should not be exposed.
|
||||||
parsePublicKeyEncoding,
|
parsePublicKeyEncoding,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user