• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef SIGNATRUETOOLS_SEGMENT_HEADER_H
16 #define SIGNATRUETOOLS_SEGMENT_HEADER_H
17 
18 #include <vector>
19 #include <string>
20 
21 #include "byte_buffer.h"
22 #include "signature_tools_log.h"
23 
24 namespace OHOS {
25 namespace SignatureTools {
26 
27 class SegmentHeader {
28 public:
29     static const int32_t SEGMENT_HEADER_LENGTH = 12;
30     static const int32_t CSB_FSVERITY_INFO_SEG = 0x1;
31     static const int32_t CSB_HAP_META_SEG = 0x2;
32     static const int32_t CSB_NATIVE_LIB_INFO_SEG = 0x3;
33     SegmentHeader();
34     SegmentHeader(int32_t type, int32_t segmentSize);
35     SegmentHeader(int32_t type, int32_t segmentOffset,
36                   int32_t segmentSize);
37     static std::unique_ptr<SegmentHeader> FromByteArray(std::vector<int8_t> bytes);
38     int32_t GetType();
39     void SetSegmentOffset(int32_t offset);
40     int32_t GetSegmentOffset();
41     int32_t GetSegmentSize();
42     void ToByteArray(std::vector<int8_t> &ret);
43 
44 private:
45     int32_t type;
46     int32_t segmentOffset;
47     int32_t segmentSize;
48 };
49 } // namespace SignatureTools
50 } // namespace OHOS
51 #endif // SIGNATRUETOOLS_SEGMENT_HEADER_H