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 CODE_SIGN_IOCTL_UTILS_H 17 #define CODE_SIGN_IOCTL_UTILS_H 18 19 #include <cstdint> 20 21 #define CERT_DEVICE_PATH "/dev/code_sign" 22 #define CERT_IOCTL_MAGIC_NUMBER 'k' 23 #define UDID_SIZE 65 24 25 struct CertPathInfo { 26 uint32_t signing_length; 27 uint32_t issuer_length; 28 uint64_t signing; 29 uint64_t issuer; 30 uint32_t path_len; 31 uint32_t path_type; 32 uint8_t __reserved[32]; 33 }; 34 35 #define ADD_CERT_PATH_CMD _IOW(CERT_IOCTL_MAGIC_NUMBER, 1, CertPathInfo) 36 #define REMOVE_CERT_PATH_CMD _IOW(CERT_IOCTL_MAGIC_NUMBER, 2, CertPathInfo) 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 int AddCertPath(const CertPathInfo &info); 41 int RemoveCertPath(const CertPathInfo &info); 42 bool IsDeveloperModeOn(); 43 int CodeSignGetUdid(char *udid); 44 #ifdef __cplusplus 45 } 46 #endif 47 48 #endif