Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Cipheriv.setAutoPadding #21804

Closed
littledivy opened this issue Jan 5, 2024 · 2 comments · Fixed by #24940
Closed

Implement Cipheriv.setAutoPadding #21804

littledivy opened this issue Jan 5, 2024 · 2 comments · Fixed by #24940
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto node API polyfill Related to various "node:*" modules APIs node compat

Comments

@littledivy
Copy link
Member

#18455 (comment)

@mllnd stumbled upon missing method when using npm:ethereum-cryptography.
https://github.com/ethereum/js-ethereum-cryptography/blob/cbb283febc4641bf1c5c365a2a16037032f2d23e/src/aes.ts#L69-L71

Error: Not implemented: crypto.Cipheriv.prototype.setAutoPadding
    at notImplemented (ext:deno_node/_utils.ts:9:11)
    at Cipheriv.setAutoPadding (ext:deno_node/internal/crypto/cipher.ts:46:9)
@littledivy littledivy added bug Something isn't working correctly node compat crypto Related to node:crypto or WebCrypto labels Jan 5, 2024
@littledivy littledivy changed the title Implement Decipheriv.setAutoPadding Implement Cipheriv.setAutoPadding Jan 5, 2024
@barthuijgen
Copy link

barthuijgen commented Jan 14, 2024

This method is definitely not just used by crypto(currency) libraries. I've had a project that I needed to implement a specific decryption logic to work with a 3rd party and this method was needed, so I was forced to switch to nodejs.

I couldn't find any other way to implement this in Deno either, the web subtle crypto api that Deno uses has no support for this.

Please prioritize the issue! 🙏

@littledivy
Copy link
Member Author

Rough outline on how to implement this:

  • Add a autoPadding: boolean = true default field to the class Cipher in ext/node/polyfills/internal/crypto/cipher.ts.
  • During final(), pass this flag to Rust.
  • fn r#final(self, input: &[u8], output: &mut [u8]) -> Result<Tag, AnyError> {

    When auto padding is disabled, divide final data into blocks of cipher's block size and call encrypt_blocks_b2b_mut.

Similar logic can be applied for Decipher

@bartlomieju bartlomieju added the node API polyfill Related to various "node:*" modules APIs label Mar 4, 2024
littledivy added a commit that referenced this issue Aug 8, 2024
Co-Authored-By: Luca Casonato <[email protected]>

Fixes #21804
Ref #20924

---------

Signed-off-by: Divy Srivastava <[email protected]>
Co-authored-by: Luca Casonato <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto node API polyfill Related to various "node:*" modules APIs node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants