@@ -1923,13 +1923,15 @@ generateKeyPair('rsa', {
1923
1923
On completion, ` callback ` will be called with ` err ` set to ` undefined ` and
1924
1924
` publicKey ` / ` privateKey ` representing the generated key pair.
1925
1925
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.
1933
1935
1934
1936
If this method is invoked as its [ ` util.promisify() ` ] [ ] ed version, it returns
1935
1937
a ` Promise ` for an ` Object ` with ` publicKey ` and ` privateKey ` properties.
@@ -1991,14 +1993,15 @@ const { publicKey, privateKey } = generateKeyPairSync('rsa', {
1991
1993
The return value ` { publicKey, privateKey } ` represents the generated key pair.
1992
1994
When PEM encoding was selected, the respective key will be a string, otherwise
1993
1995
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.
2002
2005
2003
2006
### crypto.getCiphers()
2004
2007
<!-- YAML
@@ -3143,10 +3146,12 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
3143
3146
[ NIST SP 800-38D ] : https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
3144
3147
[ Nonce-Disrespecting Adversaries ] : https://github.com/nonce-disrespect/nonce-disrespect
3145
3148
[ 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
3146
3150
[ RFC 2412 ] : https://www.rfc-editor.org/rfc/rfc2412.txt
3147
3151
[ RFC 3526 ] : https://www.rfc-editor.org/rfc/rfc3526.txt
3148
3152
[ RFC 3610 ] : https://www.rfc-editor.org/rfc/rfc3610.txt
3149
3153
[ RFC 4055 ] : https://www.rfc-editor.org/rfc/rfc4055.txt
3154
+ [ RFC 5208 ] : https://www.rfc-editor.org/rfc/rfc5208.txt
3150
3155
[ encoding ] : buffer.html#buffer_buffers_and_character_encodings
3151
3156
[ initialization vector ] : https://en.wikipedia.org/wiki/Initialization_vector
3152
3157
[ scrypt ] : https://en.wikipedia.org/wiki/Scrypt
0 commit comments