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_HAP_INFO_SEGMENT_H 16#define SIGNATRUETOOLS_HAP_INFO_SEGMENT_H 17 18#include <vector> 19#include <string> 20#include <cstdint> 21 22#include "sign_info.h" 23#include "byte_buffer.h" 24#include "signature_tools_log.h" 25 26namespace OHOS { 27namespace SignatureTools { 28 29class HapInfoSegment { 30public: 31 HapInfoSegment(); 32 HapInfoSegment(int32_t magic, const SignInfo& signInfo); 33 void SetSignInfo(const SignInfo& signInfo); 34 SignInfo& GetSignInfo(); 35 int32_t GetSize(); 36 void ToByteArray(std::vector<int8_t>& ret); 37 static HapInfoSegment FromByteArray(std::vector<int8_t>& bytes); 38 39private: 40 static const int32_t MAGIC_NUM_BYTES = 4; 41 static const int32_t MAGIC_NUM = (0xC1B5 << 16) + 0xCC66; 42 static const int32_t CHUNK_SIZE = 4096; 43 int32_t magic; 44 SignInfo signInfo; 45}; 46} // namespace SignatureTools 47} // namespace OHOS 48#endif // SIGNATRUETOOLS_HAP_INFO_SEGMENT_H 49