diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-08-08 06:04:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 18:34:10 +0530 |
commit | 0d1beed2e3633d71d5e288e0382b85be361ec13d (patch) | |
tree | ed02258b19695bff1ab3ccaeafd78786406bb832 /ext/node/ops/crypto/mod.rs | |
parent | 2f6da40bd609ebda8f30d748427d325d80e58274 (diff) |
fix(ext/node): add `CipherIv.setAutoPadding()` (#24940)
Co-Authored-By: Luca Casonato <hello@lcas.dev>
Fixes https://github.com/denoland/deno/issues/21804
Ref https://github.com/denoland/deno/issues/20924
---------
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'ext/node/ops/crypto/mod.rs')
-rw-r--r-- | ext/node/ops/crypto/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs index 567affd52..8780495a4 100644 --- a/ext/node/ops/crypto/mod.rs +++ b/ext/node/ops/crypto/mod.rs @@ -262,13 +262,14 @@ pub fn op_node_cipheriv_encrypt( pub fn op_node_cipheriv_final( state: &mut OpState, #[smi] rid: u32, + auto_pad: bool, #[buffer] input: &[u8], - #[buffer] output: &mut [u8], + #[anybuffer] output: &mut [u8], ) -> Result<Option<Vec<u8>>, AnyError> { let context = state.resource_table.take::<cipher::CipherContext>(rid)?; let context = Rc::try_unwrap(context) .map_err(|_| type_error("Cipher context is already in use"))?; - context.r#final(input, output) + context.r#final(auto_pad, input, output) } #[op2(fast)] @@ -317,17 +318,29 @@ pub fn op_node_decipheriv_decrypt( } #[op2(fast)] +pub fn op_node_decipheriv_take( + state: &mut OpState, + #[smi] rid: u32, +) -> Result<(), AnyError> { + let context = state.resource_table.take::<cipher::DecipherContext>(rid)?; + Rc::try_unwrap(context) + .map_err(|_| type_error("Cipher context is already in use"))?; + Ok(()) +} + +#[op2] pub fn op_node_decipheriv_final( state: &mut OpState, #[smi] rid: u32, + auto_pad: bool, #[buffer] input: &[u8], - #[buffer] output: &mut [u8], + #[anybuffer] output: &mut [u8], #[buffer] auth_tag: &[u8], ) -> Result<(), AnyError> { let context = state.resource_table.take::<cipher::DecipherContext>(rid)?; let context = Rc::try_unwrap(context) .map_err(|_| type_error("Cipher context is already in use"))?; - context.r#final(input, output, auth_tag) + context.r#final(auto_pad, input, output, auth_tag) } #[op2] |