1 /*
2  * Copyright (c) 2023 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 OHOS_LOCAL_CODE_SIGN_KIT_H
17 #define OHOS_LOCAL_CODE_SIGN_KIT_H
18 
19 #include <cstdint>
20 
21 #include "byte_buffer.h"
22 #include "errcode.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace CodeSign {
27 /**
28  * @brief Declares LocalCodeSignKit class
29  */
30 class LocalCodeSignKit {
31 public:
32     /**
33      * @brief init local certificate and obtain it
34      * @param cert certificate from local code sign SA
35      * @return err code, see err_code.h
36      */
37     static int32_t InitLocalCertificate(ByteBuffer &cert);
38     /**
39      * @brief sign local code
40      * @param filePath file path to sign
41      * @param signature signature from local code sign SA
42      * @return err code, see err_code.h
43      */
44     static int32_t SignLocalCode(const std::string &filePath, ByteBuffer &signature);
45     /**
46      * @brief sign local code with owner ID to the signature, so we can identify signature files using owner ID
47      * @param ownerID owner ID written to the signature
48      * @param filePath file path to sign
49      * @param signature signature from local code sign SA
50      * @return err code, see err_code.h
51      */
52     static int32_t SignLocalCode(const std::string &ownerID, const std::string &filePath, ByteBuffer &signature);
53 };
54 }
55 }
56 }
57 #endif