public static boolean verify(final String data, final @Nullable String signature) throws GeneralSecurityException {
		final KeyStore keystore = getAndroidKeyStore();
		final Certificate certificate = keystore.getCertificate(KEYPAIR_ALIAS);
		if (certificate == null) {
			Log.w(TAG, "Cannot verify due to certificate not found.");
			return false;
		}
		final Signature verifier = Signature.getInstance("SHA512withRSA");
		verifier.initVerify(certificate);			// Even if signature is null, we init the verification first and throw GeneralSecurityException if failed.
		verifier.update(data.getBytes(ISO_8859_1));	// So we could skip the verification when initialization failed, but reject the null signature otherwise.
		return signature != null && verifier.verify(signature.getBytes(ISO_8859_1));
	}
Utility for signing and verification with Android Keystore.

Created by Oasis on 2017/9/22.
engine/src/main/java/com/oasisfeng/island/util/Cryptography.java