Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 2dece7c

Browse files
MarshallOfSoundnitsakh
authored andcommitted
fixme: Revert "crypto: add API for key pair generation"
This reverts commit 8c502f5. boringssl does not support these APIs.
1 parent 654aacc commit 2dece7c

File tree

8 files changed

+0
-476
lines changed

8 files changed

+0
-476
lines changed

doc/api/crypto.md

-126
Original file line numberDiff line numberDiff line change
@@ -1896,132 +1896,6 @@ Use [`crypto.getHashes()`][] to obtain an array of names of the available
18961896
signing algorithms. Optional `options` argument controls the
18971897
`stream.Writable` behavior.
18981898

1899-
In some cases, a `Verify` instance can be created using the name of a signature
1900-
algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
1901-
the corresponding digest algorithm. This does not work for all signature
1902-
algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
1903-
algorithm names.
1904-
1905-
### crypto.generateKeyPair(type, options, callback)
1906-
<!-- YAML
1907-
added: v10.12.0
1908-
changes:
1909-
- version: REPLACEME
1910-
pr-url: https://github.com/nodejs/node/pull/26774
1911-
description: Add ability to generate X25519 and X448 key pairs.
1912-
- version: REPLACEME
1913-
pr-url: https://github.com/nodejs/node/pull/26554
1914-
description: Add ability to generate Ed25519 and Ed448 key pairs.
1915-
- version: v11.6.0
1916-
pr-url: https://github.com/nodejs/node/pull/24234
1917-
description: The `generateKeyPair` and `generateKeyPairSync` functions now
1918-
produce key objects if no encoding was specified.
1919-
-->
1920-
* `type`: {string} Must be `'rsa'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`,
1921-
`'x25519'`, or `'x448'`.
1922-
* `options`: {Object}
1923-
- `modulusLength`: {number} Key size in bits (RSA, DSA).
1924-
- `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
1925-
- `divisorLength`: {number} Size of `q` in bits (DSA).
1926-
- `namedCurve`: {string} Name of the curve to use (EC).
1927-
- `publicKeyEncoding`: {Object} See [`keyObject.export()`][].
1928-
- `privateKeyEncoding`: {Object} See [`keyObject.export()`][].
1929-
* `callback`: {Function}
1930-
- `err`: {Error}
1931-
- `publicKey`: {string | Buffer | KeyObject}
1932-
- `privateKey`: {string | Buffer | KeyObject}
1933-
1934-
Generates a new asymmetric key pair of the given `type`. RSA, DSA, EC, Ed25519
1935-
and Ed448 are currently supported.
1936-
1937-
If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
1938-
behaves as if [`keyObject.export()`][] had been called on its result. Otherwise,
1939-
the respective part of the key is returned as a [`KeyObject`].
1940-
1941-
It is recommended to encode public keys as `'spki'` and private keys as
1942-
`'pkcs8'` with encryption for long-term storage:
1943-
1944-
```js
1945-
const { generateKeyPair } = require('crypto');
1946-
generateKeyPair('rsa', {
1947-
modulusLength: 4096,
1948-
publicKeyEncoding: {
1949-
type: 'spki',
1950-
format: 'pem'
1951-
},
1952-
privateKeyEncoding: {
1953-
type: 'pkcs8',
1954-
format: 'pem',
1955-
cipher: 'aes-256-cbc',
1956-
passphrase: 'top secret'
1957-
}
1958-
}, (err, publicKey, privateKey) => {
1959-
// Handle errors and use the generated key pair.
1960-
});
1961-
```
1962-
1963-
On completion, `callback` will be called with `err` set to `undefined` and
1964-
`publicKey` / `privateKey` representing the generated key pair.
1965-
1966-
If this method is invoked as its [`util.promisify()`][]ed version, it returns
1967-
a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
1968-
1969-
### crypto.generateKeyPairSync(type, options)
1970-
<!-- YAML
1971-
added: v10.12.0
1972-
changes:
1973-
- version: REPLACEME
1974-
pr-url: https://github.com/nodejs/node/pull/26554
1975-
description: Add ability to generate Ed25519 and Ed448 key pairs.
1976-
- version: v11.6.0
1977-
pr-url: https://github.com/nodejs/node/pull/24234
1978-
description: The `generateKeyPair` and `generateKeyPairSync` functions now
1979-
produce key objects if no encoding was specified.
1980-
-->
1981-
* `type`: {string} Must be `'rsa'`, `'dsa'`, `'ec'`, `'ed25519'`, or `'ed448'`.
1982-
* `options`: {Object}
1983-
- `modulusLength`: {number} Key size in bits (RSA, DSA).
1984-
- `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
1985-
- `divisorLength`: {number} Size of `q` in bits (DSA).
1986-
- `namedCurve`: {string} Name of the curve to use (EC).
1987-
- `publicKeyEncoding`: {Object} See [`keyObject.export()`][].
1988-
- `privateKeyEncoding`: {Object} See [`keyObject.export()`][].
1989-
* Returns: {Object}
1990-
- `publicKey`: {string | Buffer | KeyObject}
1991-
- `privateKey`: {string | Buffer | KeyObject}
1992-
1993-
Generates a new asymmetric key pair of the given `type`. RSA, DSA, EC, Ed25519
1994-
and Ed448 are currently supported.
1995-
1996-
If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
1997-
behaves as if [`keyObject.export()`][] had been called on its result. Otherwise,
1998-
the respective part of the key is returned as a [`KeyObject`].
1999-
2000-
When encoding public keys, it is recommended to use `'spki'`. When encoding
2001-
private keys, it is recommended to use `'pks8'` with a strong passphrase, and to
2002-
keep the passphrase confidential.
2003-
2004-
```js
2005-
const { generateKeyPairSync } = require('crypto');
2006-
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
2007-
modulusLength: 4096,
2008-
publicKeyEncoding: {
2009-
type: 'spki',
2010-
format: 'pem'
2011-
},
2012-
privateKeyEncoding: {
2013-
type: 'pkcs8',
2014-
format: 'pem',
2015-
cipher: 'aes-256-cbc',
2016-
passphrase: 'top secret'
2017-
}
2018-
});
2019-
```
2020-
2021-
The return value `{ publicKey, privateKey }` represents the generated key pair.
2022-
When PEM encoding was selected, the respective key will be a string, otherwise
2023-
it will be a buffer containing the data encoded as DER.
2024-
20251899
### crypto.getCiphers()
20261900
<!-- YAML
20271901
added: v0.9.3

doc/api/errors.md

-5
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,6 @@ be called no more than one time per instance of a `Hash` object.
760760

761761
[`hash.update()`][] failed for any reason. This should rarely, if ever, happen.
762762

763-
<a id="ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS"></a>
764-
### ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS
765-
766-
The selected public or private key encoding is incompatible with other options.
767-
768763
<a id="ERR_CRYPTO_INVALID_DIGEST"></a>
769764
### ERR_CRYPTO_INVALID_DIGEST
770765

lib/crypto.js

-12
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ const {
5353
scrypt,
5454
scryptSync
5555
} = require('internal/crypto/scrypt');
56-
const {
57-
generateKeyPair,
58-
generateKeyPairSync
59-
} = require('internal/crypto/keygen');
60-
const {
61-
createSecretKey,
62-
createPublicKey,
63-
createPrivateKey,
64-
KeyObject,
65-
} = require('internal/crypto/keys');
6656
const {
6757
DiffieHellman,
6858
DiffieHellmanGroup,
@@ -163,8 +153,6 @@ module.exports = exports = {
163153
getHashes,
164154
pbkdf2,
165155
pbkdf2Sync,
166-
generateKeyPair,
167-
generateKeyPairSync,
168156
privateDecrypt,
169157
privateEncrypt,
170158
publicDecrypt,

lib/internal/errors.js

-2
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ E('ERR_CRYPTO_HASH_DIGEST_NO_UTF16', 'hash.digest() does not support UTF-16',
648648
Error);
649649
E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called', Error);
650650
E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed', Error);
651-
E('ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS', 'The selected key encoding %s %s.',
652-
Error);
653651
E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s', TypeError);
654652
E('ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE',
655653
'Invalid key object type %s, expected %s.', TypeError);

node.gyp

-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@
105105
'lib/internal/crypto/cipher.js',
106106
'lib/internal/crypto/diffiehellman.js',
107107
'lib/internal/crypto/hash.js',
108-
'lib/internal/crypto/keygen.js',
109-
'lib/internal/crypto/keys.js',
110108
'lib/internal/crypto/pbkdf2.js',
111109
'lib/internal/crypto/random.js',
112110
'lib/internal/crypto/scrypt.js',

src/async_wrap.h

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ namespace node {
7272
#if HAVE_OPENSSL
7373
#define NODE_ASYNC_CRYPTO_PROVIDER_TYPES(V) \
7474
V(PBKDF2REQUEST) \
75-
V(KEYPAIRGENREQUEST) \
7675
V(RANDOMBYTESREQUEST) \
7776
V(SCRYPTREQUEST) \
7877
V(TLSWRAP)

0 commit comments

Comments
 (0)