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

Support decrypting empty ciphertext #374

Merged
merged 3 commits into from
Mar 4, 2022

Conversation

bespokebob
Copy link
Contributor

When encrypting an empty string/buffer in GCM mode, the resulting ciphertext is also empty. Trying to then decrypt this using compact decryption then throws an error because it converts the empty string to undefined and then throws an error.
This is probably an edge case, but it is valid to encrypt and decrypt an empty value. This is also not an issue in CBC mode, since the ciphertext of an empty value is a non-empty value.

When encrypting an empty string/buffer in GCM mode, the resulting ciphertext is also empty. Trying to then decrypt this using compact decryption then throws an error because it converts the empty string to undefined and then throws an error.
This is probably an edge case, but it is valid to encrypt and decrypt an empty value. This is also not an issue in CBC mode, since the ciphertext of an empty value is a non-empty value.
@panva panva added the full-ci label Mar 4, 2022
@github-actions github-actions bot removed the full-ci label Mar 4, 2022
@panva panva added the full-ci label Mar 4, 2022
@github-actions github-actions bot removed the full-ci label Mar 4, 2022
@panva panva merged commit 95fe597 into panva:main Mar 4, 2022
@panva
Copy link
Owner

panva commented Mar 4, 2022

@youngbob thank you for submitting a fix!

@bespokebob bespokebob deleted the encrypt-empty-string branch March 4, 2022 22:07
@github-actions github-actions bot locked and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants