fill len bytes of the output buffer with bytes generated from
the derivation function.
byte[] hashBuf = new byte[hLen];
byte[] C = new byte[4];
int counter = 0;
digest.reset();
do
{
ItoOSP(counter, C);
digest.update(seed, 0, seed.length);
digest.update(C, 0, C.length);
digest.doFinal(hashBuf, 0);
System.arraycopy(hashBuf, 0, out, outOff + counter * hLen, hLen);
}
while (++counter < (len / hLen));
if ((counter * hLen) < len)
{
ItoOSP(counter, C);
digest.update(seed, 0, seed.length);
digest.update(C, 0, C.length);
digest.doFinal(hashBuf, 0);
System.arraycopy(hashBuf, 0, out, outOff + counter * hLen, len - (counter * hLen));
}
return len;