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 #ifndef ECMASCRIPT_COMPILER_APP_CRYPTO_H
16 #define ECMASCRIPT_COMPILER_APP_CRYPTO_H
17 #include "ecmascript/common.h"
18 
19 namespace panda::ecmascript::ohos {
20 // After referencing the kernel header file, need to remove it
21 #ifndef PAGE_SIZE
22 #define PAGE_SIZE 0x1000
23 #endif
24 #define DEV_APP_CRYPTO_PATH "/dev/code_decrypt"
25 
26 #define CODE_DECRYPT_CMD_SET_KEY  _IOW('c', 0x01, struct code_decrypto_arg)
27 #define CODE_DECRYPT_CMD_REMOVE_KEY  _IOW('c', 0x02, struct code_decrypto_arg)
28 #define CODE_DECRYPT_CMD_SET_ASSOCIATE_KEY  _IOW('c', 0x03, struct code_decrypto_arg)
29 #define CODE_DECRYPT_CMD_REMOVE_ASSOCIATE_KEY  _IOW('c', 0x04, struct code_decrypto_arg)
30 #define CODE_DECRYPT_CMD_CLEAR_CACHE_BY_KEY  _IOW('c', 0x05, struct code_decrypto_arg)
31 #define CODE_DECRYPT_CMD_CLEAR_CACHE_BY_FILE  _IOW('c', 0x06, struct code_decrypto_arg)
32 #define CODE_DECRYPT_CMD_CLEAR_SPECIFIC_CACHE  _IOW('c', 0x07, struct code_decrypto_arg)
33 
34 struct code_decrypto_arg {
35     int arg1_len;
36     int arg2_len;
37     void *arg1;
38     void *arg2;
39 };
40 #if defined(CODE_ENCRYPTION_ENABLE)
41 int PUBLIC_API DecryptSetKey(int fd, int srcAppId);
42 int PUBLIC_API DecrypRemoveKey(int fd, int srcAppId);
43 int PUBLIC_API DecryptAssociateKey(int fd, int dstAppId, int srcAppId);
44 int DecrypRemoveAssociateKey(int fd, int dstAppId, int srcAppId);
45 #endif
46 }  // namespace panda::ecmascript::kungfu
47 #endif  // ECMASCRIPT_COMPILER_APP_CRYPTO_H
48