summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/cipher.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/internal/crypto/cipher.ts')
-rw-r--r--ext/node/polyfills/internal/crypto/cipher.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/crypto/cipher.ts b/ext/node/polyfills/internal/crypto/cipher.ts
index a1449cd87..c1c5ce890 100644
--- a/ext/node/polyfills/internal/crypto/cipher.ts
+++ b/ext/node/polyfills/internal/crypto/cipher.ts
@@ -306,6 +306,10 @@ class BlockModeCache {
this.cache = this.cache.subarray(len);
return out;
}
+
+ set lastChunkIsNonZero(value: boolean) {
+ this.#lastChunkIsNonZero = value;
+ }
}
export class Decipheriv extends Transform implements Cipher {
@@ -338,7 +342,7 @@ export class Decipheriv extends Transform implements Cipher {
},
...options,
});
- this.#cache = new BlockModeCache(true);
+ this.#cache = new BlockModeCache(this.#autoPadding);
this.#context = op_node_create_decipheriv(cipher, toU8(key), toU8(iv));
this.#needsBlockCache =
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
@@ -386,6 +390,7 @@ export class Decipheriv extends Transform implements Cipher {
setAutoPadding(autoPadding?: boolean): this {
this.#autoPadding = Boolean(autoPadding);
+ this.#cache.lastChunkIsNonZero = this.#autoPadding;
return this;
}