I wrote this usage method using Java security (plain J2SE):
public static boolean validateRSAKeyPair(RSAPrivateCrtKey privateKey, RSAPublicKey publicKey) { BigInteger n = publicKey.getModulus(); BigInteger e = publicKey.getPublicExponent(); BigInteger d = privateKey.getPrivateExponent(); BigInteger p = privateKey.getPrimeP(); BigInteger q = privateKey.getPrimeQ(); BigInteger pq = p.multiply(q);
It checks the RSA key pair against the parameters of the RSA algorithm.
source share