Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 760f126

Browse filesBrowse files
panvadanielleadams
authored andcommitted
doc: mark Certificate methods as static, add missing KeyObject.from
PR-URL: #37198 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent aebe532 commit 760f126
Copy full SHA for 760f126

File tree

Expand file treeCollapse file tree

1 file changed

+29
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/crypto.md‎

Copy file name to clipboardExpand all lines: doc/api/crypto.md
+29-3Lines changed: 29 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The `crypto` module provides the `Certificate` class for working with SPKAC
5353
data. The most common usage is handling output generated by the HTML5
5454
`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation][] internally.
5555

56-
### `Certificate.exportChallenge(spkac[, encoding])`
56+
### Static method: `Certificate.exportChallenge(spkac[, encoding])`
5757
<!-- YAML
5858
added: v9.0.0
5959
changes:
@@ -76,7 +76,7 @@ console.log(challenge.toString('utf8'));
7676
// Prints: the challenge as a UTF8 string
7777
```
7878

79-
### `Certificate.exportPublicKey(spkac[, encoding])`
79+
### Static method: `Certificate.exportPublicKey(spkac[, encoding])`
8080
<!-- YAML
8181
added: v9.0.0
8282
changes:
@@ -99,7 +99,7 @@ console.log(publicKey);
9999
// Prints: the public key as <Buffer ...>
100100
```
101101

102-
### `Certificate.verifySpkac(spkac[, encoding])`
102+
### Static method: `Certificate.verifySpkac(spkac[, encoding])`
103103
<!-- YAML
104104
added: v9.0.0
105105
changes:
@@ -1284,6 +1284,32 @@ passing keys as strings or `Buffer`s due to improved security features.
12841284
The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to
12851285
be listed in the `transferList` argument.
12861286

1287+
### Static method: `KeyObject.from(key)`
1288+
<!-- YAML
1289+
added: v15.0.0
1290+
-->
1291+
1292+
* `key` {CryptoKey}
1293+
* Returns: {KeyObject}
1294+
1295+
Example: Converting a `CryptoKey` instance to a `KeyObject`:
1296+
1297+
```js
1298+
const { webcrypto: { subtle }, KeyObject } = require('crypto');
1299+
1300+
(async function() {
1301+
const key = await subtle.generateKey({
1302+
name: 'HMAC',
1303+
hash: 'SHA-256',
1304+
length: 256
1305+
}, true, ['sign', 'verify']);
1306+
1307+
const keyObject = KeyObject.from(key);
1308+
console.log(keyObject.symmetricKeySize);
1309+
// Prints: 32 (symmetric key size in bytes)
1310+
})();
1311+
```
1312+
12871313
### `keyObject.asymmetricKeyDetails`
12881314
<!-- YAML
12891315
added: v15.7.0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.