@Test
public void testBasicAgainstJce() throws Exception {

  int keySize = 2048;
  KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
  keyGen.initialize(keySize);
  KeyPair keyPair = keyGen.generateKeyPair();
  RSAPublicKey pub = (RSAPublicKey) keyPair.getPublic();
  RSAPrivateCrtKey priv = (RSAPrivateCrtKey) keyPair.getPrivate();
  // Sign with RsaSsaPkcs1SignJce.
  String message = "Hello";
  RsaSsaPkcs1SignJce signer = new RsaSsaPkcs1SignJce(priv, HashType.SHA256);
  byte[] signature = signer.sign(message.getBytes("UTF-8"));
  // Verify with JCE's Signature.
  Signature verifier = Signature.getInstance("SHA256withRSA");
  verifier.initVerify(pub);
  verifier.update(message.getBytes("UTF-8"));
  assertTrue(verifier.verify(signature));
}