Skip to content

Commit 11066fc

Browse files
committed
Use Sam's suggestion
1 parent 12cac31 commit 11066fc

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

doc/api/crypto.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,13 +1923,15 @@ generateKeyPair('rsa', {
19231923
On completion, `callback` will be called with `err` set to `undefined` and
19241924
`publicKey` / `privateKey` representing the generated key pair.
19251925

1926-
Private keys can be encrypted if the `type` is PKCS#8 or the `format` is PEM.
1927-
If a `cipher` is specified and PKCS#8 was selected, an `EncryptedPrivateKeyInfo`
1928-
structure will be produced. If PKCS#1 or SEC1 was selected and the `format` is
1929-
PEM, RFC1421-style PEM-level encryption will be used. For maximum compatibility,
1930-
it is recommended to use PKCS#8 for encrypted private keys. Since PKCS#8
1931-
defines its own encryption mechanism, PEM-level encryption is not supported when
1932-
encrypting a PKCS#8 key.
1926+
PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
1927+
the `cipher` and `format` options. The PKCS#8 `type` can be used with any
1928+
`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a
1929+
`cipher`. PKCS#1 and SEC1 can only be encrypted by specifying a `cipher`
1930+
when the PEM `format` is used. For maximum compatibility, it is recommended
1931+
to use PKCS#8 for encrypted private keys. Since PKCS#8 defines its own
1932+
encryption mechanism, PEM-level encryption is not supported when encrypting
1933+
a PKCS#8 key. See [RFC 5208] for PKCS#8 encryption and [RFC 1421][] for
1934+
PKCS#1 and SEC1 encryption.
19331935

19341936
If this method is invoked as its [`util.promisify()`][]ed version, it returns
19351937
a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
@@ -1991,14 +1993,15 @@ const { publicKey, privateKey } = generateKeyPairSync('rsa', {
19911993
The return value `{ publicKey, privateKey }` represents the generated key pair.
19921994
When PEM encoding was selected, the respective key will be a string, otherwise
19931995
it will be a buffer containing the data encoded as DER.
1994-
1995-
Private keys can be encrypted if the `type` is PKCS#8 or the `format` is PEM.
1996-
If a `cipher` is specified and PKCS#8 was selected, an `EncryptedPrivateKeyInfo`
1997-
structure will be produced. If PKCS#1 or SEC1 was selected and the `format` is
1998-
PEM, RFC1421-style PEM-level encryption will be used. For maximum compatibility,
1999-
it is recommended to use PKCS#8 for encrypted private keys. Since PKCS#8
2000-
defines its own encryption mechanism, PEM-level encryption is not supported when
2001-
encrypting a PKCS#8 key.
1996+
PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
1997+
the `cipher` and `format` options. The PKCS#8 `type` can be used with any
1998+
`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a
1999+
`cipher`. PKCS#1 and SEC1 can only be encrypted by specifying a `cipher`
2000+
when the PEM `format` is used. For maximum compatibility, it is recommended
2001+
to use PKCS#8 for encrypted private keys. Since PKCS#8 defines its own
2002+
encryption mechanism, PEM-level encryption is not supported when encrypting
2003+
a PKCS#8 key. See [RFC 5208] for PKCS#8 encryption and [RFC 1421][] for
2004+
PKCS#1 and SEC1 encryption.
20022005

20032006
### crypto.getCiphers()
20042007
<!-- YAML
@@ -3143,10 +3146,12 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
31433146
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
31443147
[Nonce-Disrespecting Adversaries]: https://github.com/nonce-disrespect/nonce-disrespect
31453148
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man1.1.0/apps/openssl-spkac.html
3149+
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
31463150
[RFC 2412]: https://www.rfc-editor.org/rfc/rfc2412.txt
31473151
[RFC 3526]: https://www.rfc-editor.org/rfc/rfc3526.txt
31483152
[RFC 3610]: https://www.rfc-editor.org/rfc/rfc3610.txt
31493153
[RFC 4055]: https://www.rfc-editor.org/rfc/rfc4055.txt
3154+
[RFC 5208]: https://www.rfc-editor.org/rfc/rfc5208.txt
31503155
[encoding]: buffer.html#buffer_buffers_and_character_encodings
31513156
[initialization vector]: https://en.wikipedia.org/wiki/Initialization_vector
31523157
[scrypt]: https://en.wikipedia.org/wiki/Scrypt

0 commit comments

Comments
 (0)