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 16 #ifndef SIGNATRUETOOLS_SIGN_CONTENT_INFO_H 17 #define SIGNATRUETOOLS_SIGN_CONTENT_INFO_H 18 19 #include <vector> 20 #include <cstdint> 21 #include <string> 22 #include <list> 23 24 namespace OHOS { 25 namespace SignatureTools { 26 class SignContentHash { 27 public: 28 SignContentHash(const char type, const char tag, const short algId, 29 const int length, const std::vector<int8_t>& hash); 30 31 public: 32 static const int CONTENT_HEAD_SIZE = 8; 33 char m_type; 34 char m_tag; 35 short m_algId; 36 int m_length; 37 std::vector<int8_t> m_hash; 38 int m_contentHashLen; 39 }; 40 41 class SignContentInfo { 42 public: 43 SignContentInfo(); 44 45 public: 46 void AddContentHashData(const char type, const char tag, const short algId, 47 const int length, const std::vector<int8_t> &hash); 48 void AddHashData(const SignContentHash &signInfo); 49 std::vector<int8_t> GetByteContent(); 50 51 private: 52 std::string m_version; 53 short m_size; 54 short m_numOfBlocks; 55 std::list<SignContentHash> m_hashData; 56 }; 57 } // namespace SignatureTools 58 } // namespace OHOS 59 #endif