EciesAeadHkdfPrivateKeyManager extends PrivateKeyTypeManager<EciesAeadHkdfPrivateKey, EciesAeadHkdfPublicKey> { @Override public void validateKey(EciesAeadHkdfPrivateKey keyProto) throws GeneralSecurityException { if (keyProto.getKeyValue().isEmpty()) { throw new GeneralSecurityException("invalid ECIES private key"); } Validators.validateVersion(keyProto.getVersion(), getVersion()); HybridUtil.validate(keyProto.getPublicKey().getParams()); } EciesAeadHkdfPrivateKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override EciesAeadHkdfPublicKey getPublicKey(EciesAeadHkdfPrivateKey key); @Override KeyMaterialType keyMaterialType(); @Override EciesAeadHkdfPrivateKey parseKey(ByteString byteString); @Override void validateKey(EciesAeadHkdfPrivateKey keyProto); @Override KeyFactory<EciesAeadHkdfKeyFormat, EciesAeadHkdfPrivateKey> keyFactory(); static void registerPair(boolean newKeyAllowed); static final KeyTemplate eciesP256HkdfHmacSha256Aes128GcmTemplate(); static final KeyTemplate rawEciesP256HkdfHmacSha256Aes128GcmCompressedTemplate(); static final KeyTemplate eciesP256HkdfHmacSha256Aes128CtrHmacSha256Template(); static final KeyTemplate rawEciesP256HkdfHmacSha256Aes128CtrHmacSha256CompressedTemplate();  }
@Test public void validateKey_valid() throws Exception { manager.validateKey(createValidKey()); }
@Test public void validateKey_invalidVersion_throws() throws Exception { EciesAeadHkdfPrivateKey key = EciesAeadHkdfPrivateKey.newBuilder(createValidKey()).setVersion(1).build(); try { manager.validateKey(key); fail(); } catch (GeneralSecurityException e) { } }