//
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

package chromeos_update_engine;
option optimize_for = LITE_RUNTIME;

message CompressionAlgorithm {
  enum Type {
    UNCOMPRESSED = 0;
    LZ4 = 1;
    LZ4HC = 2;
  }
  Type type = 1;
  int32 level = 2;
}

message CompressedBlockInfo {
  // Require fields
  uint64 uncompressed_offset = 1;
  uint64 uncompressed_length = 2;
  uint64 compressed_length = 3;

  // optional SHA256 hash of re-compressed blob
  bytes sha256_hash = 4;
  // Patch to apply to re-compressed blob
  bytes postfix_bspatch = 5;
}

enum InnerPatchType {
  BSDIFF = 0;
  PUFFDIFF = 1;
}

message CompressionInfo {
  CompressionAlgorithm algo = 1;
  repeated CompressedBlockInfo block_info = 2;
  bool zero_padding_enabled = 3;
}

message Lz4diffHeader {
  CompressionInfo src_info = 1;
  CompressionInfo dst_info = 2;
  InnerPatchType inner_type = 3;
}
