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

Fix Node encryption of ArrayBuffer plaintext #1280

Merged

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented May 18, 2023

This fixes an error that is thrown in Node when attempting to encrypt a message whose data property is of type ArrayBuffer. See commit messages for more details.

Resolves #1281.

As described in [1], for small buffers, Buffer.buffer may contain data
unrelated to the Buffer instance.

This error seems to not yet have had any user-facing consequences — we
don’t actually use the Node version of toArrayBuffer anywhere.

[1] https://nodejs.org/api/buffer.html#bufbuffer
@github-actions github-actions bot temporarily deployed to staging/pull/1280/features May 18, 2023 20:15 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1280/bundle-report May 18, 2023 20:16 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1280/typedoc May 18, 2023 20:16 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the fix-node-encryption-of-ArrayBuffer-plaintext branch from fa9fd2e to 5592d04 Compare May 18, 2023 20:40
@github-actions github-actions bot temporarily deployed to staging/pull/1280/features May 18, 2023 20:40 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the fix-node-encryption-of-ArrayBuffer-plaintext branch from 5592d04 to 4734bff Compare May 18, 2023 20:41
@github-actions github-actions bot temporarily deployed to staging/pull/1280/features May 18, 2023 20:42 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1280/bundle-report May 18, 2023 20:43 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1280/typedoc May 18, 2023 20:43 Inactive
ArrayBuffer does not have a property named `length`, and also
Buffer.concat does not accept an argument of type ArrayBuffer.

As I understand it, the library is meant to be able to handle plaintext
of type `NodeBufferlike = Buffer | ArrayBuffer | TypedArray`.

Resolves #1281.
Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lawrence-forooghian lawrence-forooghian merged commit 75b9ce1 into main May 24, 2023
@lawrence-forooghian lawrence-forooghian deleted the fix-node-encryption-of-ArrayBuffer-plaintext branch May 24, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Node implementation of Crypto is unable to encrypt plaintext of type ArrayBuffer
2 participants