{
  private byte[] MGF(byte[] Z, int l)  {    // 1. If l > (2**32).hLen, output 'mask too long' and stop.    if (l < 1 || (l & 0xFFFFFFFFL) > ((hLen & 0xFFFFFFFFL) << 32L))      {        throw new IllegalArgumentException("mask too long");      }    // 2. Let T be the empty octet string.    byte[] result = new byte[l];    // 3. For i = 0 to CEILING(l/hLen) ? 1, do    int limit = ((l + hLen - 1) / hLen) - 1;    IMessageDigest hashZ = null;    hashZ = (IMessageDigest) hash.clone();    hashZ.digest();    hashZ.update(Z, 0, Z.length);    IMessageDigest hashZC = null;    byte[] t;    int sofar = 0;    int length;    for (int i = 0; i < limit; i++)      {        //    3.1 Convert i to an octet string C of length 4 with the primitive        //        I2OSP: C = I2OSP(i, 4).        //    3.2 Concatenate the hash of the seed Z and C to the octet string T:        //        T = T || Hash(Z || C)        hashZC = (IMessageDigest) hashZ.clone();        hashZC.update((byte) (i >>> 24));        hashZC.update((byte) (i >>> 16));        hashZC.update((byte) (i >>> 8));        hashZC.update((byte) i);        t = hashZC.digest();        length = l - sofar;        length = (length > hLen ? hLen : length);        System.arraycopy(t, 0, result, sofar, length);        sofar += length;      }    // 4. Output the leading l octets of T as the octet string mask.    return result;  }