fill len bytes of the output buffer with bytes generated from
the derivation function.
if ((out.length - len) < outOff)
{
throw new DataLengthException("output buffer too small");
}
byte[] hashBuf = new byte[hLen];
byte[] C = new byte[4];
int counter = 0;
digest.reset();
if (len > hLen)
{
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;