@Test
public void validateKey_notValid_throws() throws Exception {

  HmacPrfKey validKey = factory.createKey(makeHmacPrfKeyFormat(16, HashType.SHA1));
  try {
    manager.validateKey(
        HmacPrfKey.newBuilder(validKey)
            .setKeyValue(ByteString.copyFrom(Random.randBytes(15)))
            .build());
    fail();
  } catch (GeneralSecurityException e) {
    // expected
  }
  try {
    manager.validateKey(
        HmacPrfKey.newBuilder(validKey)
            .setParams(
                HmacPrfParams.newBuilder(validKey.getParams())
                    .setHash(HashType.UNKNOWN_HASH)
                    .build())
            .build());
    fail();
  } catch (GeneralSecurityException e) {
    // expected
  }
}