Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: mark Certificate methods as static, add missing KeyObject.from #37198

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The `crypto` module provides the `Certificate` class for working with SPKAC
data. The most common usage is handling output generated by the HTML5
`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation][] internally.

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

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

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

### Static method: `KeyObject.from(key)`
<!-- YAML
added: v15.0.0
-->

* `key` {CryptoKey}
* Returns: {KeyObject}

Example: Converting a `CryptoKey` instance to a `KeyObject`:

```js
const { webcrypto: { subtle }, KeyObject } = require('crypto');

(async function() {
const key = await subtle.generateKey({
name: 'HMAC',
hash: 'SHA-256',
length: 256
}, true, ['sign', 'verify']);

const keyObject = KeyObject.from(key);
console.log(keyObject.symmetricKeySize);
// Prints: 32 (symmetric key size in bytes)
})();
```

### `keyObject.asymmetricKeyDetails`
<!-- YAML
added: v15.7.0
Expand Down