@Test public void validateKey_generated() throws Exception { if (TestUtil.isTsan()) { return; } RsaSsaPkcs1KeyFormat keyFormat = RsaSsaPkcs1KeyFormat.newBuilder() .setParams(RsaSsaPkcs1Params.newBuilder().setHashType(HashType.SHA256)) .setModulusSizeInBits(3072) .setPublicExponent(ByteString.copyFrom(RSAKeyGenParameterSpec.F4.toByteArray())) .build(); RsaSsaPkcs1PrivateKey privateKey = factory.createKey(keyFormat); RsaSsaPkcs1PublicKey publicKey = signManager.getPublicKey(privateKey); verifyManager.validateKey(publicKey); }
@Override public void validateKey(RsaSsaPkcs1PublicKey pubKey) throws GeneralSecurityException { Validators.validateVersion(pubKey.getVersion(), getVersion()); Validators.validateRsaModulusSize((new BigInteger(1, pubKey.getN().toByteArray())).bitLength()); Validators.validateRsaPublicExponent(new BigInteger(1, pubKey.getE().toByteArray())); SigUtil.validateRsaSsaPkcs1Params(pubKey.getParams()); }
RsaSsaPkcs1VerifyKeyManager extends KeyTypeManager<RsaSsaPkcs1PublicKey> { @Override public void validateKey(RsaSsaPkcs1PublicKey pubKey) throws GeneralSecurityException { Validators.validateVersion(pubKey.getVersion(), getVersion()); Validators.validateRsaModulusSize((new BigInteger(1, pubKey.getN().toByteArray())).bitLength()); Validators.validateRsaPublicExponent(new BigInteger(1, pubKey.getE().toByteArray())); SigUtil.validateRsaSsaPkcs1Params(pubKey.getParams()); } }
RsaSsaPkcs1VerifyKeyManager extends KeyTypeManager<RsaSsaPkcs1PublicKey> { @Override public void validateKey(RsaSsaPkcs1PublicKey pubKey) throws GeneralSecurityException { Validators.validateVersion(pubKey.getVersion(), getVersion()); Validators.validateRsaModulusSize((new BigInteger(1, pubKey.getN().toByteArray())).bitLength()); Validators.validateRsaPublicExponent(new BigInteger(1, pubKey.getE().toByteArray())); SigUtil.validateRsaSsaPkcs1Params(pubKey.getParams()); } RsaSsaPkcs1VerifyKeyManager(); }
RsaSsaPkcs1VerifyKeyManager extends KeyTypeManager<RsaSsaPkcs1PublicKey> { @Override public void validateKey(RsaSsaPkcs1PublicKey pubKey) throws GeneralSecurityException { Validators.validateVersion(pubKey.getVersion(), getVersion()); Validators.validateRsaModulusSize((new BigInteger(1, pubKey.getN().toByteArray())).bitLength()); Validators.validateRsaPublicExponent(new BigInteger(1, pubKey.getE().toByteArray())); SigUtil.validateRsaSsaPkcs1Params(pubKey.getParams()); } RsaSsaPkcs1VerifyKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override RsaSsaPkcs1PublicKey parseKey(ByteString byteString); @Override void validateKey(RsaSsaPkcs1PublicKey pubKey); }
RsaSsaPkcs1VerifyKeyManager extends KeyTypeManager<RsaSsaPkcs1PublicKey> { @Override public void validateKey(RsaSsaPkcs1PublicKey pubKey) throws GeneralSecurityException { Validators.validateVersion(pubKey.getVersion(), getVersion()); Validators.validateRsaModulusSize((new BigInteger(1, pubKey.getN().toByteArray())).bitLength()); Validators.validateRsaPublicExponent(new BigInteger(1, pubKey.getE().toByteArray())); SigUtil.validateRsaSsaPkcs1Params(pubKey.getParams()); } RsaSsaPkcs1VerifyKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override RsaSsaPkcs1PublicKey parseKey(ByteString byteString); @Override void validateKey(RsaSsaPkcs1PublicKey pubKey);  }