-
Notifications
You must be signed in to change notification settings - Fork 103
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
Performance Issues #399
Comments
The performance problem you are noticing is the cost of running the scrypt PBKDF on the user passphrase, which is automatically set at encryption time to a hardness level of at least 1 second of computation on the current machine (and due to the granularity of the hardness setting could be anywhere between 1 and 2 seconds). This is a security measure used by all password-based encryption mechanisms, and thus you'll likely see the same performance issues with any other library. Additionally, when used this way, the passphrase is run through PBKDF with a unique salt for each encryption (as a defense against security issues related to passphrase reuse), which means the 1-2 seconds of PBKDF cost are paid per row. [Obligatory "I Am Not Your Cryptographer" disclaimer] Instead of encrypting every row with the user's passphrase, a more performant approach would be to encrypt every row with a native age key, and encrypt that with the user's passphrase. Then on start, your application could decrypt the native age key into memory, and then use that for on-the-fly encryption and decryption of rows. |
@str4d is there a way for me to use a "native age key" directly to encrypt a stream of data?
|
I think it's currently impossible to do that right now because |
What were you trying to do
Right now I'm trying to create a note taking application. Every note is a row in the database and the contents are encrypted by a password based encryption method.
What happened
It's quite slow, for example encrypting a small struct takes about ~1.5 second. Decryption also has a similar runtime. Is there a way to speed this process up?
Below is the function I used to encrypt data.
This is the function I used to test how long it take to encrypt it.
Printed:
Encryption Duration: 1.841529562s
I'm also aware of #148, seems like it's abandoned for now (?).
Questions
If this is currently unsolvable, forgive me if I'm being rude, but do you have a suggestion about other encryption libraries that could do a passphrase based encryption upon a stream of data? Similar to what
with_user_passphrase()
offers. I'm also interested in helping this, but I doubt my current understanding of encryption is good enough to help you guys.The text was updated successfully, but these errors were encountered: