I'm implementing encryption in my browser extension that will allow users to encrypt their data and then share them with others. And since shared links can be leaked, I want to protect the data as much as possible against brute force attacks.
I'm using PBKDF2 to derive 256 bits:
self.crypto.subtle.deriveBits({name, salt: new Uint8Array(salt), iterations, hash}, keyMaterial, 256)
I wanted to use SHA-512 to make algorithm harder (also for GPU) but it looks like it makes it also much harder for browsers, especially Firefox where I can do 6 times more iterations in the same time:
Firefox 118:
Hashing with: PBKDF2, SHA-512, 1,000,000 time: 819
Hashing with: PBKDF2, SHA-256, 6,000,000 time: 837
Chrome 119:
Hashing with: PBKDF2, SHA-512, 1,000,000 time: 307
Hashing with: PBKDF2, SHA-256, 6,000,000 time: 532
The question is:
- should I stick with SHA-256 and more iterations?
- should I use Argon2 instead? (but browsers doesn't support it so I would have to bundle the library which uses WASM which slightly complicates things for extensions).
- or it doesn't matter and I should force users to set longer passwords instead?