deriveKey method
Derive key from given input and put it in out
at offset outOff
.
Implementation
@override
int deriveKey(Uint8List inp, int inpOff, Uint8List out, int outOff) {
var dkLen = _params.desiredKeyLength;
var hLen = _mac.macSize;
var l = (dkLen + hLen - 1) ~/ hLen;
var iBuf = Uint8List(4);
var outBytes = Uint8List(l * hLen);
var outPos = 0;
CipherParameters param = KeyParameter(inp.sublist(inpOff));
_mac.init(param);
for (var i = 1; i <= l; i++) {
// Increment the value in 'iBuf'
for (var pos = 3;; pos--) {
iBuf[pos]++;
if (iBuf[pos] != 0) break;
}
_f(_params.salt, _params.iterationCount, iBuf, outBytes, outPos);
outPos += hLen;
}
out.setRange(outOff, outOff + dkLen, outBytes);
return keySize;
}