-
Notifications
You must be signed in to change notification settings - Fork 2
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
use pbkdf2 at instantiation #4
Conversation
Pull Request Test Coverage Report for Build 1080153385Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
I would strongly prefer this approach compared to #3. Deriving a new key for every I did have a few questions about the design. First, Putting the salt into the ciphertext isn't a good solution either because that then requires you re-derive the key for every Some other little questions about the implementation: this change in the use of - this._key = hash(decodeUTF8(password)).slice(0, secretbox.keyLength)
+ this._pass = hash(decodeUTF8(password)).slice(KEY_LENGTH) You set Finally, the number of iterations should probably be configurable through the constructor. 1000 isn't a particularly large value but is probably reasonable for running in the browser. |
In #3 you were also concerned about the bundle size resulting from importing let key = await crypto.subtle.deriveKey(
{ name: 'PBKDF2', hash: 'SHA-512', salt, iterations },
await crypto.subtle.importKey('raw', password, 'PBKDF2', false, ['deriveKey']),
{ name: 'AES-CBC', length: 256 },
true,
['encrypt']
);
// returns an ArrayBuffer
let extracted = await crypto.subtle.exportKey('raw', key); Maybe we could use this in the browser, use |
Great, glad to get this level of logical review.
Naturally. I'd like to expose an
Yes, this is a mistake. Thanks for spotting it.
It seemed like a sensible default but you're right that it's confusing to use such a value.
I agree. I'll update the constructor with an |
I tried this in #1 (comment) but bundling gets really complicated for the user so I'm keen to avoid I was just clued into https://github.com/Daninet/hash-wasm which seems exactly like what we want for this. |
I've added a configurable options parameter to the constructor and Speaking of the new lib, the bundled size of this version is 59.5 KB! Not bad for crypto, IMO. |
This looks really good -- that bundle size is much more in line with what I'd expect for something like this and avoids us having to deal with cross-platform stuff ourselves if I've also tried out |
I particularly like the opaque portable string method of transporting the internal state; it means users can get the default choices and not have to worry about internal configuration beyond setting a password. Such a value could easily be stored in a local doc in |
Great! I'm going to go ahead and merge this then and cut a new release :) |
Pull Request Test Coverage Report for Build 1080194719Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 1080153385Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Much like #3 this PR uses pbkdf2 to derive a cryptographic key from a password. Unlike that PR, this is only done once when Crypt is initialized. As a result, there is not a significant performance difference between this version and the master branch, which does not use pbkdf2.