Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: remove DEFAULT_ENCODING #47182

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2878,26 +2878,6 @@ An object containing commonly used constants for crypto and security related
operations. The specific constants currently defined are described in
[Crypto constants][].

### `crypto.DEFAULT_ENCODING`

<!-- YAML
added: v0.9.3
deprecated: v10.0.0
-->

> Stability: 0 - Deprecated

The default encoding to use for functions that can take either strings
or [buffers][`Buffer`]. The default value is `'buffer'`, which makes methods
default to [`Buffer`][] objects.

The `crypto.DEFAULT_ENCODING` mechanism is provided for backward compatibility
with legacy programs that expect `'latin1'` to be the default encoding.

New applications should expect the default to be `'buffer'`.

This property is deprecated.

### `crypto.fips`

<!-- YAML
Expand Down
9 changes: 6 additions & 3 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1864,14 +1864,18 @@ bits are allowed. Authentication tags of other lengths are invalid per

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47182
description: End-of-Life.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18333
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

The [`crypto.DEFAULT_ENCODING`][] property is deprecated.
The `crypto.DEFAULT_ENCODING` property only existed for compatibility with
Node.js releases prior to versions 0.9.3 and has been removed.

### DEP0092: Top-level `this` bound to `module.exports`

Expand Down Expand Up @@ -3385,7 +3389,6 @@ be added when a function is bound to an `AsyncResource`.
[`console.error()`]: console.md#consoleerrordata-args
[`console.log()`]: console.md#consolelogdata-args
[`crypto.Certificate()` constructor]: crypto.md#legacy-api
[`crypto.DEFAULT_ENCODING`]: crypto.md#cryptodefault_encoding
[`crypto.createCipher()`]: crypto.md#cryptocreatecipheralgorithm-password-options
[`crypto.createCipheriv()`]: crypto.md#cryptocreatecipherivalgorithm-key-iv-options
[`crypto.createDecipher()`]: crypto.md#cryptocreatedecipheralgorithm-password-options
Expand Down
11 changes: 0 additions & 11 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ const {
const {
getCiphers,
getCurves,
getDefaultEncoding,
getHashes,
setDefaultEncoding,
setEngine,
secureHeapUsed,
} = require('internal/crypto/util');
Expand Down Expand Up @@ -356,15 +354,6 @@ ObjectDefineProperties(module.exports, {
get: getFips,
set: setFips,
},
DEFAULT_ENCODING: {
__proto__: null,
enumerable: false,
configurable: true,
get: deprecate(getDefaultEncoding,
'crypto.DEFAULT_ENCODING is deprecated.', 'DEP0091'),
set: deprecate(setDefaultEncoding,
'crypto.DEFAULT_ENCODING is deprecated.', 'DEP0091'),
},
constants: {
__proto__: null,
configurable: false,
Expand Down
10 changes: 2 additions & 8 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,9 @@ const {
const kHandle = Symbol('kHandle');
const kKeyObject = Symbol('kKeyObject');

let defaultEncoding = 'buffer';

function setDefaultEncoding(val) {
defaultEncoding = val;
}

// TODO(tniessen): remove all call sites and this function
function getDefaultEncoding() {
return defaultEncoding;
return 'buffer';
}

// This is here because many functions accepted binary strings without
Expand Down Expand Up @@ -561,7 +556,6 @@ module.exports = {
getHashes,
kHandle,
kKeyObject,
setDefaultEncoding,
setEngine,
toBuf,

Expand Down
3 changes: 0 additions & 3 deletions test/parallel/test-crypto-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const crypto = require('crypto');
const { inspect } = require('util');
const fixtures = require('../common/fixtures');

crypto.DEFAULT_ENCODING = 'buffer';

//
// Test authenticated encryption modes.
//
Expand Down Expand Up @@ -74,7 +72,6 @@ const expectedWarnings = common.hasFipsCrypto ?
];

const expectedDeprecationWarnings = [
['crypto.DEFAULT_ENCODING is deprecated.', 'DEP0091'],
['crypto.createCipher is deprecated.', 'DEP0106'],
];

Expand Down
Loading