RsaSsaPkcs1SignKeyManager extends PrivateKeyTypeManager<RsaSsaPkcs1PrivateKey, RsaSsaPkcs1PublicKey> { @Override public RsaSsaPkcs1PublicKey getPublicKey(RsaSsaPkcs1PrivateKey privKeyProto) throws GeneralSecurityException { return privKeyProto.getPublicKey(); } RsaSsaPkcs1SignKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override RsaSsaPkcs1PublicKey getPublicKey(RsaSsaPkcs1PrivateKey privKeyProto); @Override KeyMaterialType keyMaterialType(); @Override RsaSsaPkcs1PrivateKey parseKey(ByteString byteString); @Override void validateKey(RsaSsaPkcs1PrivateKey privKey); @Override KeyFactory<RsaSsaPkcs1KeyFormat, RsaSsaPkcs1PrivateKey> keyFactory(); static void registerPair(boolean newKeyAllowed); static final KeyTemplate rsa3072SsaPkcs1Sha256F4Template(); static final KeyTemplate rawRsa3072SsaPkcs1Sha256F4Template(); static final KeyTemplate rsa4096SsaPkcs1Sha512F4Template(); static final KeyTemplate rawRsa4096SsaPkcs1Sha512F4Template();  }
@Test public void getPublicKey_correctValues() throws Exception { if (TestUtil.isTsan()) { return; } RsaSsaPkcs1KeyFormat format = createKeyFormat(HashType.SHA256, 3072, RSAKeyGenParameterSpec.F4); RsaSsaPkcs1PrivateKey key = factory.createKey(format); assertThat(manager.getPublicKey(key)).isEqualTo(key.getPublicKey()); }
@Test public void createPrimitive() throws Exception { if (TestUtil.isTsan()) { 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); }