Eto pa isa galing sa SALTED hint ni boss jerome
PS di ko rin maintindihan..,haha
saltedPassword: function(password, salt, iterations) {
return CryptoJS.PBKDF2(password, salt, {
keySize: this.cfg.keySize,
iterations:iterations,
hasher: this.cfg.hasher
});
},
/**
* ClientKey = HMAC(saltPwd, "Client Key")
*/
clientKey: function(saltPwd) {
return this.cfg.hmac(saltPwd, "Client Key");
},
/**
* ServerKey = HMAC(saltPwd, "Server Key")
*/
serverKey: function(saltPwd) {
return this.cfg.hmac(saltPwd, "Server Key");
},
/**
* StoredKey = HASH(ClientKey)
*/
storedKey: function(clientKey) {
var hasher = this.cfg.hasher.create();
hasher.update(clientKey);
return hasher.finalize();
},
/**
* Signature = HMAC(StoredKey, AuthMessage)
*/
signature: function(storedKey, authMessage) {
return this.cfg.hmac(storedKey, authMessage);
},
/**
* ClientProof = ClientKey ^ ClientSignature
*/
clientProof: function (password, salt, iterations, authMessage) {
var spwd = this.saltedPassword(password, salt, iterations);
var ckey = this.clientKey(spwd);
var skey = this.storedKey(ckey);
var csig = this.signature(skey, authMessage);
for (var i = 0; i < ckey.sigBytes/4; i += 1) {
ckey.words
= ckey.words ^ csig.words
}
return ckey.toString();
},
/**
* ServerProof = HMAC(ServerKey, AuthMessage)
*/
serverProof: function (password, salt, iterations, authMessage) {
var spwd = this.saltedPassword(password, salt, iterations);
var skey = this.serverKey(spwd);
var sig = this.signature(skey, authMessage);
return sig.toString();
}
});
View attachment 842213