1 PBKDF2 versus many decrypts
JavaScript performance comparison
Info
I can use PBKDF2 to authentication a password before I try using it or just decrypt and see if the reuslt is valid. So either I PBKDF2 once or do a lot of possibly failing decryptions. I want to see where the break-even is.
Preparation code
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/core.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/cipher-core.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/sha1.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/hmac.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/pbkdf2.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/aes.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/mode-ecb.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/pad-nopadding.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64.js">
</script>
<script>
Benchmark.prototype.setup = function() {
var salt = CryptoJS.lib.WordArray.random(32 / 8);
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
return (randomstring);
}
var key = randomString();
var keyWordArray = CryptoJS.lib.WordArray.random(128 / 8); //128bytes
var toDecryptIv = [];
var toDecryptCipher = [];
while (toDecryptIv.length < 1500) {
toDecryptIv.push(CryptoJS.lib.WordArray.random(128 / 8));
toDecryptCipher.push(CryptoJS.lib.WordArray.random(128 / 8));
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
1 PBKDF2-256 run |
|
pending… |
1PBKDF2-128 + many decryptions |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Eyal
- Revision 2: published by Samuel Reed
- Revision 3: published by Samuel Reed
- Revision 4: published by Samuel Reed
- Revision 6: published
- Revision 7: published
0 comments