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

Commit 2d861c0

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 6f7b38e commit 2d861c0

File tree

8 files changed

+0
-470
lines changed

8 files changed

+0
-470
lines changed

doc/api/crypto.md

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,128 +1893,6 @@ Use [`crypto.getHashes()`][] to obtain an array of names of the available
18931893
signing algorithms. Optional `options` argument controls the
18941894
`stream.Writable` behavior.
18951895

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

doc/api/errors.md

Lines changed: 0 additions & 5 deletions
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

Lines changed: 0 additions & 12 deletions
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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,6 @@ E('ERR_CRYPTO_HASH_DIGEST_NO_UTF16', 'hash.digest() does not support UTF-16',
597597
Error);
598598
E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called', Error);
599599
E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed', Error);
600-
E('ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS', 'The selected key encoding %s %s.',
601-
Error);
602600
E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s', TypeError);
603601
E('ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE',
604602
'Invalid key object type %s, expected %s.', TypeError);

node.gyp

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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)