Skip to content

Commit

Permalink
doc: mark Certificate methods as static, add missing KeyObject.from
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Feb 3, 2021
1 parent 35fe310 commit 9396d6d
Showing 1 changed file with 29 additions and 3 deletions.
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

0 comments on commit 9396d6d

Please sign in to comment.