if (DEBUG && debuglevel > 8) { debug("EM (verify): " + Util.toString(EM)); }
if (Configuration.DEBUG) log.fine("EM (verify): " + Util.toString(EM));
  protected boolean verifySignature(Object sig) throws IllegalStateException  {    if (publicKey == null)      {        throw new IllegalStateException();      }    //      byte[] S = decodeSignature(sig);    byte[] S = (byte[]) sig;    // 1. If the length of the signature S is not k octets, output 'signature    //    invalid' and stop.    int modBits = ((RSAPublicKey) publicKey).getModulus().bitLength();    int k = (modBits + 7) / 8;    if (S.length != k)      {        return false;      }    // 2. Convert the signature S to an integer signature representative s:    //    s = OS2IP(S).    BigInteger s = new BigInteger(1, S);    // 3. Apply the RSAVP verification primitive to the public key (n, e) and    //    the signature representative s to produce an integer message    //    representative m: m = RSAVP((n, e), s).    //    If RSAVP outputs 'signature representative out of range,' then    //    output 'signature invalid' and stop.    BigInteger m = null;    try      {        m = RSA.verify(publicKey, s);      }    catch (IllegalArgumentException x)      {        return false;      }    // 4. Convert the message representative m to an encoded message EM of    //    length emLen = CEILING((modBits - 1)/8) octets, where modBits is    //    equal to the bit length of the modulus: EM = I2OSP(m, emLen).    //    Note that emLen will be one less than k if modBits - 1 is divisible    //    by 8. If I2OSP outputs 'integer too large,' then output 'signature    //    invalid' and stop.    int emBits = modBits - 1;    int emLen = (emBits + 7) / 8;    byte[] EM = m.toByteArray();    if (DEBUG && debuglevel > 8)      {        debug("EM (verify): " + Util.toString(EM));      }    if (EM.length > emLen)      {        return false;      }    else if (EM.length < emLen)      {        byte[] newEM = new byte[emLen];        System.arraycopy(EM, 0, newEM, emLen - EM.length, EM.length);        EM = newEM;      }    // 5. Apply the EMSA-PSS decoding operation to the message M and the    //    encoded message EM: Result = EMSA-PSS-Decode(M, EM, emBits). If    //    Result = 'consistent,' output 'signature verified.' Otherwise,    //    output 'signature invalid.'    byte[] mHash = md.digest();    boolean result = false;    try      {        result = pss.decode(mHash, EM, emBits, sLen);      }    catch (IllegalArgumentException x)      {        result = false;      }    return result;  }