• 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 path hap real path on disk
40      * @param CallbackFunc enforce code sign callback function address
41      * @return err code, see err_code.h
42      */
43     int32_t ProcessMultiTask(const std::string &ownerId, const std::string &path, CallbackFunc &func);
44 private:
45     int32_t ProcessOneFile();
46     int32_t ExecuteMultiTask(const std::string &ownerId, const std::string &path, CallbackFunc &func);
47     void ShowCodeSignInfo(const std::string &path, const struct code_sign_enable_arg &arg);
48 private:
49     CodeSignBlock codeSignBlock_;
50     CodeSignEnableMultiTask multiTask_;
51 };
52 }
53 }
54 }
55 
56 #endif