if (DEBUG && debuglevel > 8) { debug("EM (sign): " + Util.toString(EM)); }
if (Configuration.DEBUG) log.fine("EM (sign): " + Util.toString(EM));
  protected Object generateSignature() throws IllegalStateException  {    // 1. Apply the EMSA-PSS encoding operation to the message M to produce an    //    encoded message EM of length CEILING((modBits ? 1)/8) octets such    //    that the bit length of the integer OS2IP(EM) is at most modBits ? 1:    //    EM = EMSA-PSS-Encode(M,modBits ? 1).    //    Note that the octet length of EM will be one less than k if    //    modBits ? 1 is divisible by 8. If the encoding operation outputs    //    'message too long' or 'encoding error,' then output 'message too    //    long' or 'encoding error' and stop.    int modBits = ((RSAPrivateKey) privateKey).getModulus().bitLength();    byte[] salt = new byte[sLen];    this.nextRandomBytes(salt);    byte[] EM = pss.encode(md.digest(), modBits - 1, salt);    if (DEBUG && debuglevel > 8)      {        debug("EM (sign): " + Util.toString(EM));      }    // 2. Convert the encoded message EM to an integer message representative    //    m (see Section 1.2.2): m = OS2IP(EM).    BigInteger m = new BigInteger(1, EM);    // 3. Apply the RSASP signature primitive to the public key K and the    //    message representative m to produce an integer signature    //    representative s: s = RSASP(K,m).    BigInteger s = RSA.sign(privateKey, m);    // 4. Convert the signature representative s to a signature S of length k    //    octets (see Section 1.2.1): S = I2OSP(s, k).    // 5. Output the signature S.    int k = (modBits + 7) / 8;    //      return encodeSignature(s, k);    return RSA.I2OSP(s, k);  }