@SuppressWarnings("UnusedException") // Proto parsing error adds no relevant information
  private static AesCmacPrfKey parseKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to AesCmacPrfProtoSerialization.parseKey");
    }
    try {
      com.google.crypto.tink.proto.AesCmacPrfKey protoKey =
          com.google.crypto.tink.proto.AesCmacPrfKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      if (serialization.getIdRequirementOrNull() != null) {
        throw new GeneralSecurityException("ID requirement must be null.");
      }
      AesCmacPrfParameters parameters = AesCmacPrfParameters.create(protoKey.getKeyValue().size());
      return AesCmacPrfKey.create(
          parameters,
          SecretBytes.copyFrom(
              protoKey.getKeyValue().toByteArray(), SecretKeyAccess.requireAccess(access)));

    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing AesCmacPrfKey failed");
    }
  }
Methods to serialize and parse {@link AesCmacPrfKey} objects and {@link AesCmacPrfParameters}
objects.
java_src/src/main/java/com/google/crypto/tink/prf/internal/AesCmacPrfProtoSerialization.java