diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-08-26 10:45:37 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 10:45:37 +0530 |
commit | 1cb547d885906d557a63b2670c4b1b95a8626826 (patch) | |
tree | 64ef1e6f49fbecb44e51e24488f4ac544db10cd1 /ext/node/polyfills/internal/crypto | |
parent | 37292e74e1a986946ee73edaf81b05bc47b3a201 (diff) |
fix(node): propagate create cipher errors (#20280)
Fixes https://github.com/denoland/deno/issues/19002
Diffstat (limited to 'ext/node/polyfills/internal/crypto')
-rw-r--r-- | ext/node/polyfills/internal/crypto/cipher.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/node/polyfills/internal/crypto/cipher.ts b/ext/node/polyfills/internal/crypto/cipher.ts index 3a8b41f06..5622576cd 100644 --- a/ext/node/polyfills/internal/crypto/cipher.ts +++ b/ext/node/polyfills/internal/crypto/cipher.ts @@ -162,6 +162,9 @@ export class Cipheriv extends Transform implements Cipher { }); this.#cache = new BlockModeCache(false); this.#context = ops.op_node_create_cipheriv(cipher, toU8(key), toU8(iv)); + if (this.#context == 0) { + throw new TypeError("Unknown cipher"); + } } final(encoding: string = getDefaultEncoding()): Buffer | string { @@ -278,6 +281,9 @@ export class Decipheriv extends Transform implements Cipher { }); this.#cache = new BlockModeCache(true); this.#context = ops.op_node_create_decipheriv(cipher, toU8(key), toU8(iv)); + if (this.#context == 0) { + throw new TypeError("Unknown cipher"); + } } final(encoding: string = getDefaultEncoding()): Buffer | string { |