PBKDF2 (v34)

Revision 34 of this benchmark created by Calvin Metcalf on


Description

PBKDF2 (hmacSHA1) for JavaScript

Compares the PBKDF2 methods of the Stanford Javascript Crypto Library with the ones from CryptoJS and Anandam.

Setup

var hmacSHA1 = function(key) {
          var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha1);
          this.encrypt = function() {
            return hasher.encrypt.apply(hasher, arguments);
          };
          };
    
      // from http://stackoverflow.com/questions/3745666/
    
      function hex2a(hex) {
        var str = '';
        for (var i = 0; i < hex.length; i += 2)
        str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
        return str;
      }
      var iterations = 500;
      var password = 'password';
      var hexSalt = '29EEE7AA9C0E9315';
      var keySizeBits = 256;
      var sjclSalt = sjcl.codec.hex.toBits(hexSalt);
      var cryptoSalt = CryptoJS.enc.Hex.parse(hexSalt);
      var anandamSalt = hex2a(hexSalt);
      var browserifySalt = new browserifyCrypto.Buffer(hexSalt, 'hex');

Test runner

Ready to run.

Testing in
TestOps/sec
SJCL 0.8
// async test
sjcl.misc.pbkdf2(password, sjclSalt, iterations, keySizeBits, hmacSHA1);
deferred.resolve()
ready
CryptoJS 3.1.2
// async test
CryptoJS.PBKDF2(password, cryptoSalt, {
  keySize: keySizeBits / 32,
  iterations: iterations
});
deferred.resolve()
ready
Anandam 1.4
// async test
var pbkdf2 = new PBKDF2(password, anandamSalt, iterations, keySizeBits / 8);
pbkdf2.deriveKey(function() {}, function() {
  deferred.resolve()
});
ready
browserify
// async test
browserifyCrypto.pbkdf2Sync(password, browserifySalt, iterations, 256/8);
deferred.resolve();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.