@Test public void validateKey_smallModulus() throws Exception { RsaSsaPssPublicKey publicKey = nistTestVectors[0].publicKeyProto; RsaSsaPssPublicKey invalidKey = RsaSsaPssPublicKey.newBuilder(publicKey) .setN(ByteString.copyFrom(TestUtil.hexDecode("23"))) .setE(ByteString.copyFrom(TestUtil.hexDecode("03"))) .build(); try { verifyManager.validateKey(invalidKey); fail(); } catch (GeneralSecurityException e) { } }
@Override public void validateKey(RsaSsaPssPublicKey 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.validateRsaSsaPssParams(pubKey.getParams()); }
RsaSsaPssVerifyKeyManager extends KeyTypeManager<RsaSsaPssPublicKey> { @Override public void validateKey(RsaSsaPssPublicKey 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.validateRsaSsaPssParams(pubKey.getParams()); } }
RsaSsaPssVerifyKeyManager extends KeyTypeManager<RsaSsaPssPublicKey> { @Override public void validateKey(RsaSsaPssPublicKey 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.validateRsaSsaPssParams(pubKey.getParams()); } RsaSsaPssVerifyKeyManager(); }
RsaSsaPssVerifyKeyManager extends KeyTypeManager<RsaSsaPssPublicKey> { @Override public void validateKey(RsaSsaPssPublicKey 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.validateRsaSsaPssParams(pubKey.getParams()); } RsaSsaPssVerifyKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override RsaSsaPssPublicKey parseKey(ByteString byteString); @Override void validateKey(RsaSsaPssPublicKey pubKey); }
RsaSsaPssVerifyKeyManager extends KeyTypeManager<RsaSsaPssPublicKey> { @Override public void validateKey(RsaSsaPssPublicKey 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.validateRsaSsaPssParams(pubKey.getParams()); } RsaSsaPssVerifyKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override RsaSsaPssPublicKey parseKey(ByteString byteString); @Override void validateKey(RsaSsaPssPublicKey pubKey);  }