code: public static boolean emsa_pss_verify(SignatureParamSpec spec, byte[] msg, byte[] EM, int emBits) {
          int emLen = emBits >> 3;
          if ((emBits & 7) != 0) {
              emLen++;
          }
  
          byte[] mHash = hash(spec, msg);
          // System.out.println("mHash: "+Utils.bytes2String(mHash));
  
          MessageDigest dig = getMessageDigest(spec);
          int hLen = dig.getDigestLength();
          // System.out.println("hLen: "+hLen);
  
          int sLen = hLen;
          if (EM[EM.length - 1] != (byte) 0xBC) {
              // System.out.println("no BC at the end");
              return false;
          }
  
          byte[] maskedDB = new byte[emLen - hLen - 1];
          byte[] H = new byte[hLen];
          System.arraycopy(EM, 0, maskedDB, 0, emLen - hLen - 1);
          System.arraycopy(EM, emLen - hLen - 1, H, 0, hLen);
  
          // TODO: verify if first X bits of maskedDB are zero
  
          byte[] dbMask = mgf1(spec, H, emLen - hLen - 1);
          byte[] DB = xor_os(maskedDB, dbMask);
  
          // set leftmost X bits of DB to zero
          int tooMuchBits = (emLen << 3) - emBits;
          byte mask = (byte) (0xFF >>> tooMuchBits);
          DB[0] &= mask;
  
          // TODO: another consistency check
  
          byte[] salt = new byte[sLen];
          System.arraycopy(DB, DB.length - sLen, salt, 0, sLen);
  
          byte[] zeroes = new byte[8];
          byte[] m2 = concat(concat(zeroes, mHash), salt);
          byte[] H2 = hash(spec, m2);
  
          return Arrays.equals(H, H2);
      }
docs: --- stuff from the PKCS#1-PSS specification ---------------------------