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