@Test
public void createPrimitive() throws Exception {

  if (TestUtil.isTsan()) {
    // factory.createKey is too slow in Tsan.
    return;
  }
  RsaSsaPkcs1KeyFormat format = createKeyFormat(HashType.SHA256, 3072, RSAKeyGenParameterSpec.F4);
  RsaSsaPkcs1PrivateKey key = factory.createKey(format);
  PublicKeySign signer = manager.getPrimitive(key, PublicKeySign.class);
  KeyFactory kf = EngineFactory.KEY_FACTORY.getInstance("RSA");
  BigInteger modulus = new BigInteger(1, key.getPublicKey().getN().toByteArray());
  BigInteger exponent = new BigInteger(1, key.getPublicKey().getE().toByteArray());
  RSAPublicKey publicKey =
      (RSAPublicKey) kf.generatePublic(new RSAPublicKeySpec(modulus, exponent));
  PublicKeyVerify verifier = new RsaSsaPkcs1VerifyJce(
      publicKey, SigUtil.toHashType(key.getPublicKey().getParams().getHashType()));
  byte[] message = Random.randBytes(135);
  verifier.verify(signer.sign(message), message);
}