Skip to content

Commit 95d2cb0

Browse files
crypto: move createCipher and createDecipher to eol
1 parent 69866bf commit 95d2cb0

11 files changed

+10
-750
lines changed

benchmark/crypto/cipher-stream.js

-101
This file was deleted.

doc/api/crypto.md

+2-127
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ used in one of two ways:
319319
* Using the [`cipher.update()`][] and [`cipher.final()`][] methods to produce
320320
the encrypted data.
321321

322-
The [`crypto.createCipher()`][] or [`crypto.createCipheriv()`][] methods are
322+
The [`crypto.createCipheriv()`][] method is
323323
used to create `Cipher` instances. `Cipher` objects are not to be created
324324
directly using the `new` keyword.
325325

@@ -651,7 +651,7 @@ used in one of two ways:
651651
* Using the [`decipher.update()`][] and [`decipher.final()`][] methods to
652652
produce the unencrypted data.
653653

654-
The [`crypto.createDecipher()`][] or [`crypto.createDecipheriv()`][] methods are
654+
The [`crypto.createDecipheriv()`][] method is
655655
used to create `Decipher` instances. `Decipher` objects are not to be created
656656
directly using the `new` keyword.
657657

@@ -2954,77 +2954,6 @@ added: v15.8.0
29542954

29552955
Checks the primality of the `candidate`.
29562956

2957-
### `crypto.createCipher(algorithm, password[, options])`
2958-
2959-
<!-- YAML
2960-
added: v0.1.94
2961-
deprecated: v10.0.0
2962-
changes:
2963-
- version:
2964-
- v17.9.0
2965-
- v16.17.0
2966-
pr-url: https://github.com/nodejs/node/pull/42427
2967-
description: The `authTagLength` option is now optional when using the
2968-
`chacha20-poly1305` cipher and defaults to 16 bytes.
2969-
- version: v15.0.0
2970-
pr-url: https://github.com/nodejs/node/pull/35093
2971-
description: The password argument can be an ArrayBuffer and is limited to
2972-
a maximum of 2 ** 31 - 1 bytes.
2973-
- version: v10.10.0
2974-
pr-url: https://github.com/nodejs/node/pull/21447
2975-
description: Ciphers in OCB mode are now supported.
2976-
- version: v10.2.0
2977-
pr-url: https://github.com/nodejs/node/pull/20235
2978-
description: The `authTagLength` option can now be used to produce shorter
2979-
authentication tags in GCM mode and defaults to 16 bytes.
2980-
-->
2981-
2982-
> Stability: 0 - Deprecated: Use [`crypto.createCipheriv()`][] instead.
2983-
2984-
* `algorithm` {string}
2985-
* `password` {string|ArrayBuffer|Buffer|TypedArray|DataView}
2986-
* `options` {Object} [`stream.transform` options][]
2987-
* Returns: {Cipher}
2988-
2989-
Creates and returns a `Cipher` object that uses the given `algorithm` and
2990-
`password`.
2991-
2992-
The `options` argument controls stream behavior and is optional except when a
2993-
cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
2994-
`authTagLength` option is required and specifies the length of the
2995-
authentication tag in bytes, see [CCM mode][]. In GCM mode, the `authTagLength`
2996-
option is not required but can be used to set the length of the authentication
2997-
tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
2998-
For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
2999-
3000-
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
3001-
recent OpenSSL releases, `openssl list -cipher-algorithms` will
3002-
display the available cipher algorithms.
3003-
3004-
The `password` is used to derive the cipher key and initialization vector (IV).
3005-
The value must be either a `'latin1'` encoded string, a [`Buffer`][], a
3006-
`TypedArray`, or a `DataView`.
3007-
3008-
<strong class="critical">This function is semantically insecure for all
3009-
supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,
3010-
GCM, or CCM).</strong>
3011-
3012-
The implementation of `crypto.createCipher()` derives keys using the OpenSSL
3013-
function [`EVP_BytesToKey`][] with the digest algorithm set to MD5, one
3014-
iteration, and no salt. The lack of salt allows dictionary attacks as the same
3015-
password always creates the same key. The low iteration count and
3016-
non-cryptographically secure hash algorithm allow passwords to be tested very
3017-
rapidly.
3018-
3019-
In line with OpenSSL's recommendation to use a more modern algorithm instead of
3020-
[`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on
3021-
their own using [`crypto.scrypt()`][] and to use [`crypto.createCipheriv()`][]
3022-
to create the `Cipher` object. Users should not use ciphers with counter mode
3023-
(e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
3024-
they are used in order to avoid the risk of IV reuse that causes
3025-
vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting
3026-
Adversaries][] for details.
3027-
30282957
### `crypto.createCipheriv(algorithm, key, iv[, options])`
30292958

30302959
<!-- YAML
@@ -3099,55 +3028,6 @@ something has to be unpredictable and unique, but does not have to be secret;
30993028
remember that an attacker must not be able to predict ahead of time what a
31003029
given IV will be.
31013030

3102-
### `crypto.createDecipher(algorithm, password[, options])`
3103-
3104-
<!-- YAML
3105-
added: v0.1.94
3106-
deprecated: v10.0.0
3107-
changes:
3108-
- version:
3109-
- v17.9.0
3110-
- v16.17.0
3111-
pr-url: https://github.com/nodejs/node/pull/42427
3112-
description: The `authTagLength` option is now optional when using the
3113-
`chacha20-poly1305` cipher and defaults to 16 bytes.
3114-
- version: v10.10.0
3115-
pr-url: https://github.com/nodejs/node/pull/21447
3116-
description: Ciphers in OCB mode are now supported.
3117-
-->
3118-
3119-
> Stability: 0 - Deprecated: Use [`crypto.createDecipheriv()`][] instead.
3120-
3121-
* `algorithm` {string}
3122-
* `password` {string|ArrayBuffer|Buffer|TypedArray|DataView}
3123-
* `options` {Object} [`stream.transform` options][]
3124-
* Returns: {Decipher}
3125-
3126-
Creates and returns a `Decipher` object that uses the given `algorithm` and
3127-
`password` (key).
3128-
3129-
The `options` argument controls stream behavior and is optional except when a
3130-
cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
3131-
`authTagLength` option is required and specifies the length of the
3132-
authentication tag in bytes, see [CCM mode][].
3133-
For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
3134-
3135-
<strong class="critical">This function is semantically insecure for all
3136-
supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,
3137-
GCM, or CCM).</strong>
3138-
3139-
The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
3140-
function [`EVP_BytesToKey`][] with the digest algorithm set to MD5, one
3141-
iteration, and no salt. The lack of salt allows dictionary attacks as the same
3142-
password always creates the same key. The low iteration count and
3143-
non-cryptographically secure hash algorithm allow passwords to be tested very
3144-
rapidly.
3145-
3146-
In line with OpenSSL's recommendation to use a more modern algorithm instead of
3147-
[`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on
3148-
their own using [`crypto.scrypt()`][] and to use [`crypto.createDecipheriv()`][]
3149-
to create the `Decipher` object.
3150-
31513031
### `crypto.createDecipheriv(algorithm, key, iv[, options])`
31523032

31533033
<!-- YAML
@@ -6096,7 +5976,6 @@ See the [list of SSL OP Flags][] for details.
60965976
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
60975977
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
60985978
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
6099-
[Nonce-Disrespecting Adversaries]: https://github.com/nonce-disrespect/nonce-disrespect
61005979
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
61015980
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
61025981
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
@@ -6113,17 +5992,14 @@ See the [list of SSL OP Flags][] for details.
61135992
[`Buffer`]: buffer.md
61145993
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
61155994
[`DiffieHellmanGroup`]: #class-diffiehellmangroup
6116-
[`EVP_BytesToKey`]: https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html
61175995
[`KeyObject`]: #class-keyobject
61185996
[`Sign`]: #class-sign
61195997
[`String.prototype.normalize()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
61205998
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
61215999
[`Verify`]: #class-verify
61226000
[`cipher.final()`]: #cipherfinaloutputencoding
61236001
[`cipher.update()`]: #cipherupdatedata-inputencoding-outputencoding
6124-
[`crypto.createCipher()`]: #cryptocreatecipheralgorithm-password-options
61256002
[`crypto.createCipheriv()`]: #cryptocreatecipherivalgorithm-key-iv-options
6126-
[`crypto.createDecipher()`]: #cryptocreatedecipheralgorithm-password-options
61276003
[`crypto.createDecipheriv()`]: #cryptocreatedecipherivalgorithm-key-iv-options
61286004
[`crypto.createDiffieHellman()`]: #cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding
61296005
[`crypto.createECDH()`]: #cryptocreateecdhcurvename
@@ -6144,7 +6020,6 @@ See the [list of SSL OP Flags][] for details.
61446020
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
61456021
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
61466022
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
6147-
[`crypto.scrypt()`]: #cryptoscryptpassword-salt-keylen-options-callback
61486023
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray
61496024
[`crypto.webcrypto.subtle`]: webcrypto.md#class-subtlecrypto
61506025
[`decipher.final()`]: #decipherfinaloutputencoding

doc/api/deprecations.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,9 @@ Type: End-of-Life
21892189

21902190
<!-- YAML
21912191
changes:
2192+
- version: REPLACEME
2193+
pr-url: https://github.com/nodejs/node/pull/50973
2194+
description: End-of-Life.
21922195
- version: v11.0.0
21932196
pr-url: https://github.com/nodejs/node/pull/22089
21942197
description: Runtime deprecation.
@@ -2197,11 +2200,12 @@ changes:
21972200
description: Documentation-only deprecation.
21982201
-->
21992202

2200-
Type: Runtime
2203+
Type: End-of-Life
22012204

2202-
Using [`crypto.createCipher()`][] and [`crypto.createDecipher()`][] must be
2203-
avoided as they use a weak key derivation function (MD5 with no salt) and static
2204-
initialization vectors. It is recommended to derive a key using
2205+
`crypto.createCipher()` and `crypto.createDecipher()` have been removed
2206+
as they use a weak key derivation function (MD5 with no salt) and static
2207+
initialization vectors.
2208+
It is recommended to derive a key using
22052209
[`crypto.pbkdf2()`][] or [`crypto.scrypt()`][] with random salts and to use
22062210
[`crypto.createCipheriv()`][] and [`crypto.createDecipheriv()`][] to obtain the
22072211
[`Cipher`][] and [`Decipher`][] objects respectively.
@@ -3557,9 +3561,7 @@ The [`util.types.isWebAssemblyCompiledModule`][] API is deprecated. Please use
35573561
[`console.error()`]: console.md#consoleerrordata-args
35583562
[`console.log()`]: console.md#consolelogdata-args
35593563
[`crypto.Certificate()` constructor]: crypto.md#legacy-api
3560-
[`crypto.createCipher()`]: crypto.md#cryptocreatecipheralgorithm-password-options
35613564
[`crypto.createCipheriv()`]: crypto.md#cryptocreatecipherivalgorithm-key-iv-options
3562-
[`crypto.createDecipher()`]: crypto.md#cryptocreatedecipheralgorithm-password-options
35633565
[`crypto.createDecipheriv()`]: crypto.md#cryptocreatedecipherivalgorithm-key-iv-options
35643566
[`crypto.fips`]: crypto.md#cryptofips
35653567
[`crypto.pbkdf2()`]: crypto.md#cryptopbkdf2password-salt-iterations-keylen-digest-callback

lib/crypto.js

-20
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,10 @@ function createHash(algorithm, options) {
138138
return new Hash(algorithm, options);
139139
}
140140

141-
function createCipher(cipher, password, options) {
142-
return new Cipher(cipher, password, options);
143-
}
144-
145141
function createCipheriv(cipher, key, iv, options) {
146142
return new Cipheriv(cipher, key, iv, options);
147143
}
148144

149-
function createDecipher(cipher, password, options) {
150-
return new Decipher(cipher, password, options);
151-
}
152-
153145
function createDecipheriv(cipher, key, iv, options) {
154146
return new Decipheriv(cipher, key, iv, options);
155147
}
@@ -336,18 +328,6 @@ function getRandomBytesAlias(key) {
336328
}
337329

338330
ObjectDefineProperties(module.exports, {
339-
createCipher: {
340-
__proto__: null,
341-
enumerable: false,
342-
value: deprecate(createCipher,
343-
'crypto.createCipher is deprecated.', 'DEP0106'),
344-
},
345-
createDecipher: {
346-
__proto__: null,
347-
enumerable: false,
348-
value: deprecate(createDecipher,
349-
'crypto.createDecipher is deprecated.', 'DEP0106'),
350-
},
351331
// crypto.fips is deprecated. DEP0093. Use crypto.getFips()/crypto.setFips()
352332
fips: {
353333
__proto__: null,

0 commit comments

Comments
 (0)