• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 CODE_SIGN_HELPER_H
17 #define CODE_SIGN_HELPER_H
18 
19 #include "code_sign_block.h"
20 #include "code_sign_enable_multi_task.h"
21 
22 namespace OHOS {
23 namespace Security {
24 namespace CodeSign {
25 
26 class CodeSignHelper {
27 public:
28     /**
29      * @brief parse code sign block info
30      * @param realPath hap real path on disk
31      * @param entryMap map from entryname in hap to real path on disk
32      * @param FileType signature file type
33      * @return err code, see err_code.h
34      */
35     int32_t ParseCodeSignBlock(const std::string &realPath, const EntryMap &entryMap, FileType fileType);
36     /**
37      * @brief multithreading code signing enable task
38      * @param ownerId string to abtain owner ID from the signature file
39      * @param pluginId string to abtain plugin ID from the signature file
40      * @param path hap real path on disk
41      * @param CallbackFunc enforce code sign callback function address
42      * @param flag attributes of libs
43      * @return err code, see err_code.h
44      */
45     int32_t ProcessMultiTask(const std::string &ownerId, const std::string &pluginId,
46         const std::string &path, CallbackFunc &func, uint32_t flag);
47 private:
48     int32_t ProcessOneFile(uint32_t flag);
49     int32_t ExecuteMultiTask(const std::string &ownerId, const std::string &pluginId,
50         const std::string &path, CallbackFunc &func);
51     void ShowCodeSignInfo(const std::string &path, const struct code_sign_enable_arg &arg);
52 private:
53     CodeSignBlock codeSignBlock_;
54     CodeSignEnableMultiTask multiTask_;
55 };
56 }
57 }
58 }
59 
60 #endif