Skip to content
Open
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
12 changes: 2 additions & 10 deletions src/node/internal/crypto_cipher.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -209,11 +209,7 @@ Cipheriv.prototype.update = function (
let ret: ArrayBuffer;
if (typeof data === 'string') {
if (inputEncoding === undefined) {
throw new ERR_INVALID_ARG_VALUE(
'inputEncoding',
inputEncoding,
'If inputEncoding is not provided then the data must be a Buffer'
);
inputEncoding = 'utf8';
}
ret = this[kHandle].update(Buffer.from(data, inputEncoding));
} else if (isAnyArrayBuffer(data)) {
Expand DownExpand Up@@ -356,11 +352,7 @@ Decipheriv.prototype.update = function (
let ret: ArrayBuffer;
if (typeof data === 'string') {
if (inputEncoding === undefined) {
throw new ERR_INVALID_ARG_VALUE(
'inputEncoding',
inputEncoding,
'If inputEncoding is not provided then the data must be a Buffer'
);
inputEncoding = 'utf8';
}
ret = this[kHandle].update(Buffer.from(data, inputEncoding));
} else if (isAnyArrayBuffer(data)) {
Expand Down
4 changes: 1 addition & 3 deletions src/node/internal/crypto_hash.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -277,9 +277,7 @@ Hmac.prototype.digest = function (
): Buffer | string {
const state = this[kState];
if (state[kFinalized]) {
return !outputEncoding || outputEncoding === 'buffer'
? Buffer.from('')
: '';
throw new ERR_CRYPTO_HASH_FINALIZED();
}

// Explicit conversion for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion src/node/internal/internal_buffer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -447,7 +447,7 @@ function alloc(size: number, fill?: FillValue, encoding?: string): Buffer {
if (Number.isNaN(size)) {
throw new ERR_INVALID_ARG_VALUE.RangeError('size', size);
}
if (size >= kMaxLength) {
if (size > kMaxLength) {
throw new ERR_OUT_OF_RANGE('size', `0 to ${kMaxLength}`, size);
}

Expand Down