@Test public void validateKey_wrongVersion() throws Exception { RsaSsaPkcs1PublicKey publicKey = nistTestVectors[0].publicKeyProto; RsaSsaPkcs1PublicKey invalidKey = RsaSsaPkcs1PublicKey.newBuilder(publicKey).setVersion(1).build(); try { verifyManager.validateKey(invalidKey); fail(); } catch (GeneralSecurityException e) { } }
@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);  }