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

Crypto Is Non-deterministic #719

Open
sinanspd opened this issue Dec 18, 2023 · 0 comments
Open

Crypto Is Non-deterministic #719

sinanspd opened this issue Dec 18, 2023 · 0 comments

Comments

@sinanspd
Copy link

sinanspd commented Dec 18, 2023

I didn't know if this should go in discussion or here as I imagine this was part intentional.

Because IvParameterSpec is generated on random bytes, whenever you run the application the spec changes between runs, resulting in different encrypted strings on the same raw string (this is the whole point of initialization vectors). This means if you have an EncryptedPassword already saved in the database, you won't be able login using the same password if the application restarts. crypto.encrypt("mypassword") will result in a different EncryptedPassword than what is in the database.

This doesn't seem like a very desirable behavior. What are your thoughts?

Steps to reproduce:

  1. Run the application and create a user
  2. login with the created user --> 200 Ok
  3. Restart the application
  4. Try logging in with the same user --> 403 Forbidden

To work around this, IV needs to be stored in the users table as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant