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