154aa6d63Sopenharmony_ci/* 254aa6d63Sopenharmony_ci * Copyright (c) 2024-2024 Huawei Device Co., Ltd. 354aa6d63Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 454aa6d63Sopenharmony_ci * you may not use this file except in compliance with the License. 554aa6d63Sopenharmony_ci * You may obtain a copy of the License at 654aa6d63Sopenharmony_ci * 754aa6d63Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 854aa6d63Sopenharmony_ci * 954aa6d63Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1054aa6d63Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1154aa6d63Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1254aa6d63Sopenharmony_ci * See the License for the specific language governing permissions and 1354aa6d63Sopenharmony_ci * limitations under the License. 1454aa6d63Sopenharmony_ci */ 1554aa6d63Sopenharmony_ci 1654aa6d63Sopenharmony_ci#ifndef SIGNATRUETOOLS_SIGN_BIN_H 1754aa6d63Sopenharmony_ci#define SIGNATRUETOOLS_SIGN_BIN_H 1854aa6d63Sopenharmony_ci 1954aa6d63Sopenharmony_ci#include "signer_config.h" 2054aa6d63Sopenharmony_ci 2154aa6d63Sopenharmony_cinamespace OHOS { 2254aa6d63Sopenharmony_cinamespace SignatureTools { 2354aa6d63Sopenharmony_ciclass SignBin { 2454aa6d63Sopenharmony_cipublic: 2554aa6d63Sopenharmony_ci static bool Sign(SignerConfig& signerConfig, const std::map<std::string, std::string>& signParams); 2654aa6d63Sopenharmony_ci static std::vector<int8_t> GenerateFileDigest(const std::string& outputFile, 2754aa6d63Sopenharmony_ci const std::string& signAlg); 2854aa6d63Sopenharmony_ci 2954aa6d63Sopenharmony_ciprivate: 3054aa6d63Sopenharmony_ci static bool WriteBlockDataToFile(const std::string& inputFile, const std::string& outputFile, 3154aa6d63Sopenharmony_ci const std::string& profileFile, const std::string& profileSigned); 3254aa6d63Sopenharmony_ci static bool WriteSignDataToOutputFile(SignerConfig& SignerConfig, const std::string& outputFile, 3354aa6d63Sopenharmony_ci const std::string& signAlg); 3454aa6d63Sopenharmony_ci static bool WriteSignHeadDataToOutputFile(const std::string& inputFile, const std::string& outputFile); 3554aa6d63Sopenharmony_ci static bool CheckBinAndProfileLengthIsValid(int64_t binFileLen, int64_t profileDataLen); 3654aa6d63Sopenharmony_ci static bool IsLongOverflowInteger(int64_t num); 3754aa6d63Sopenharmony_ci static bool IsLongOverflowShort(int64_t num); 3854aa6d63Sopenharmony_ci static bool WriteSignedBin(const std::string& inputFile, const std::string& proBlockByte, 3954aa6d63Sopenharmony_ci const std::string& signBlockByte, const std::string& profileFile, 4054aa6d63Sopenharmony_ci const std::string& outputFile); 4154aa6d63Sopenharmony_ci}; 4254aa6d63Sopenharmony_ci} // namespace SignatureTools 4354aa6d63Sopenharmony_ci} // namespace OHOS 4454aa6d63Sopenharmony_ci#endif