mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
fix(node): propagate create cipher errors (#20280)
Fixes https://github.com/denoland/deno/issues/19002
This commit is contained in:
parent
4dcb410b9d
commit
999bc870f6
2 changed files with 30 additions and 0 deletions
|
@ -199,3 +199,27 @@ Deno.test({
|
||||||
assertEquals(await text(stream), "foo".repeat(15));
|
assertEquals(await text(stream), "foo".repeat(15));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
name: "createCipheriv - invalid algorithm",
|
||||||
|
fn() {
|
||||||
|
assertThrows(
|
||||||
|
() =>
|
||||||
|
crypto.createCipheriv("foo", new Uint8Array(16), new Uint8Array(16)),
|
||||||
|
TypeError,
|
||||||
|
"Unknown cipher",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
name: "createDecipheriv - invalid algorithm",
|
||||||
|
fn() {
|
||||||
|
assertThrows(
|
||||||
|
() =>
|
||||||
|
crypto.createDecipheriv("foo", new Uint8Array(16), new Uint8Array(16)),
|
||||||
|
TypeError,
|
||||||
|
"Unknown cipher",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
@ -162,6 +162,9 @@ export class Cipheriv extends Transform implements Cipher {
|
||||||
});
|
});
|
||||||
this.#cache = new BlockModeCache(false);
|
this.#cache = new BlockModeCache(false);
|
||||||
this.#context = ops.op_node_create_cipheriv(cipher, toU8(key), toU8(iv));
|
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 {
|
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
||||||
|
@ -278,6 +281,9 @@ export class Decipheriv extends Transform implements Cipher {
|
||||||
});
|
});
|
||||||
this.#cache = new BlockModeCache(true);
|
this.#cache = new BlockModeCache(true);
|
||||||
this.#context = ops.op_node_create_decipheriv(cipher, toU8(key), toU8(iv));
|
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 {
|
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
||||||
|
|
Loading…
Reference in a new issue