private static ProtoParametersSerialization serializeParameters(HmacParameters parameters)
      throws GeneralSecurityException {
    return ProtoParametersSerialization.create(
        KeyTemplate.newBuilder()
            .setTypeUrl(TYPE_URL)
            .setValue(
                com.google.crypto.tink.proto.HmacKeyFormat.newBuilder()
                    .setParams(getProtoParams(parameters))
                    .setKeySize(parameters.getKeySizeBytes())
                    .build()
                    .toByteString())
            .setOutputPrefixType(OUTPUT_PREFIX_TYPE_CONVERTER.toProtoEnum(parameters.getVariant()))
            .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