@Override
  public Prf getPrimitive(ByteString serializedKey) throws GeneralSecurityException {
    try {
      HmacPrfKey keyProto =
          HmacPrfKey.parseFrom(serializedKey, ExtensionRegistryLite.getEmptyRegistry());
      validate(keyProto);
      HashType hash = keyProto.getParams().getHash();
      byte[] keyValue = keyProto.getKeyValue().toByteArray();
      SecretKeySpec keySpec = new SecretKeySpec(keyValue, "HMAC");
      switch (hash) {
        case SHA1:
          return new PrfHmacJce("HMACSHA1", keySpec);
        case SHA224:
          return new PrfHmacJce("HMACSHA224", keySpec);
        case SHA256:
          return new PrfHmacJce("HMACSHA256", keySpec);
        case SHA384:
          return new PrfHmacJce("HMACSHA384", keySpec);
        case SHA512:
          return new PrfHmacJce("HMACSHA512", keySpec);
        default:
          throw new GeneralSecurityException("unknown hash");
      }
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("expected serialized HmacPrfKey proto", e);
    }
  }
@param serializedKey serialized {@code HmacPrfKey} proto
java_src/src/main/java/com/google/crypto/tink/prf/internal/LegacyHmacPrfTestKeyManager.java