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

Commit 696fda5

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 87adb79 commit 696fda5

8 files changed

Lines changed: 0 additions & 440 deletions

File tree

doc/api/crypto.md

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

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

doc/api/errors.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,6 @@ be called no more than one time per instance of a `Hash` object.
763763

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

766-
<a id="ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS"></a>
767-
### ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS
768-
769-
The selected public or private key encoding is incompatible with other options.
770-
771766
<a id="ERR_CRYPTO_INVALID_DIGEST"></a>
772767
### ERR_CRYPTO_INVALID_DIGEST
773768

lib/crypto.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +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-
} = require('internal/crypto/keys');
6556
const {
6657
DiffieHellman,
6758
DiffieHellmanGroup,
@@ -162,8 +153,6 @@ module.exports = exports = {
162153
getHashes,
163154
pbkdf2,
164155
pbkdf2Sync,
165-
generateKeyPair,
166-
generateKeyPairSync,
167156
privateDecrypt,
168157
privateEncrypt,
169158
publicDecrypt,

lib/internal/errors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@ E('ERR_CRYPTO_HASH_DIGEST_NO_UTF16', 'hash.digest() does not support UTF-16',
584584
Error);
585585
E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called', Error);
586586
E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed', Error);
587-
E('ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS', 'The selected key encoding %s %s.',
588-
Error);
589587
E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s', TypeError);
590588
E('ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE',
591589
'Invalid key object type %s, expected %s.', TypeError);

node.gyp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@
104104
'lib/internal/crypto/cipher.js',
105105
'lib/internal/crypto/diffiehellman.js',
106106
'lib/internal/crypto/hash.js',
107-
'lib/internal/crypto/keygen.js',
108-
'lib/internal/crypto/keys.js',
109107
'lib/internal/crypto/pbkdf2.js',
110108
'lib/internal/crypto/random.js',
111109
'lib/internal/crypto/scrypt.js',

src/async_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ namespace node {
7171
#if HAVE_OPENSSL
7272
#define NODE_ASYNC_CRYPTO_PROVIDER_TYPES(V) \
7373
V(PBKDF2REQUEST) \
74-
V(KEYPAIRGENREQUEST) \
7574
V(RANDOMBYTESREQUEST) \
7675
V(SCRYPTREQUEST) \
7776
V(TLSWRAP)

0 commit comments

Comments
 (0)