private static HmacParameters parseParameters(ProtoParametersSerialization serialization)
      throws GeneralSecurityException {
    if (!serialization.getKeyTemplate().getTypeUrl().equals(TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to HmacProtoSerialization.parseParameters: "
              + serialization.getKeyTemplate().getTypeUrl());
    }
    com.google.crypto.tink.proto.HmacKeyFormat format;
    try {
      format =
          com.google.crypto.tink.proto.HmacKeyFormat.parseFrom(
              serialization.getKeyTemplate().getValue(), ExtensionRegistryLite.getEmptyRegistry());
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing HmacParameters failed: ", e);
    }
    if (format.getVersion() != 0) {
      throw new GeneralSecurityException(
          "Parsing HmacParameters failed: unknown Version " + format.getVersion());
    }
    return HmacParameters.builder()
        .setKeySizeBytes(format.getKeySize())
        .setTagSizeBytes(format.getParams().getTagSize())
        .setHashType(HASH_TYPE_CONVERTER.fromProtoEnum(format.getParams().getHash()))
        .setVariant(
            OUTPUT_PREFIX_TYPE_CONVERTER.fromProtoEnum(
                serialization.getKeyTemplate().getOutputPrefixType()))
        .build();
  }
Methods to serialize and parse {@link HmacKey} objects and {@link HmacParameters} objects.
java_src/src/main/java/com/google/crypto/tink/mac/internal/HmacProtoSerialization.java