summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/cipher.ts
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2023-03-24 22:29:14 +0900
committerGitHub <noreply@github.com>2023-03-24 22:29:14 +0900
commit3d75fb2be758772ab9d538ef40243e8317878e84 (patch)
treed38fca0225f80379b6792aaac73389e0466e7802 /ext/node/polyfills/internal/crypto/cipher.ts
parent94ef428b564f8ba60c2752fb7ca64f804f88baf2 (diff)
fix(ext/node): make cipher/decipher transform stream (#18408)
Diffstat (limited to 'ext/node/polyfills/internal/crypto/cipher.ts')
-rw-r--r--ext/node/polyfills/internal/crypto/cipher.ts24
1 files changed, 22 insertions, 2 deletions
diff --git a/ext/node/polyfills/internal/crypto/cipher.ts b/ext/node/polyfills/internal/crypto/cipher.ts
index d40978cf6..670c1bcce 100644
--- a/ext/node/polyfills/internal/crypto/cipher.ts
+++ b/ext/node/polyfills/internal/crypto/cipher.ts
@@ -129,7 +129,17 @@ export class Cipheriv extends Transform implements Cipher {
iv: BinaryLike | null,
options?: TransformOptions,
) {
- super(options);
+ super({
+ transform(chunk, encoding, cb) {
+ this.push(this.update(chunk, encoding));
+ cb();
+ },
+ final(cb) {
+ this.push(this.final());
+ cb();
+ },
+ ...options,
+ });
this.#cache = new BlockModeCache(false);
this.#context = ops.op_node_create_cipheriv(cipher, key, iv);
}
@@ -235,7 +245,17 @@ export class Decipheriv extends Transform implements Cipher {
iv: BinaryLike | null,
options?: TransformOptions,
) {
- super(options);
+ super({
+ transform(chunk, encoding, cb) {
+ this.push(this.update(chunk, encoding));
+ cb();
+ },
+ final(cb) {
+ this.push(this.final());
+ cb();
+ },
+ ...options,
+ });
this.#cache = new BlockModeCache(true);
this.#context = ops.op_node_create_decipheriv(cipher, key, iv);
}