1 /* 2 * Copyright (C) 2022 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 DEV_SLINFO_ADPT_H 17 #define DEV_SLINFO_ADPT_H 18 19 #include "device_security_info.h" 20 #include "dev_slinfo_mgr.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #define DEFAULT_DEV_SEC_LEVEL 0 27 #define DEV_SEC_LEVEL1 1 /* sl1 */ 28 #define DEV_SEC_LEVEL2 2 /* sl2 */ 29 #define DEV_SEC_LEVEL3 3 /* sl3 */ 30 #define DEV_SEC_LEVEL4 4 /* sl4 */ 31 #define DEV_SEC_LEVEL5 5 /* sl5 */ 32 33 typedef int32_t (*RequestDeviceSecurityInfoFunction)(const DeviceIdentify *identify, 34 const RequestOption *option, 35 DeviceSecurityInfo **info); 36 37 typedef int32_t (*RequestDeviceSecurityInfoAsyncFunction)(const DeviceIdentify *identify, 38 const RequestOption *option, 39 DeviceSecurityInfoCallback callback); 40 41 typedef void (*FreeDeviceSecurityInfoFunction)(DeviceSecurityInfo *info); 42 43 typedef uint32_t (*GetDeviceSecurityLevelValueFunction)(const DeviceSecurityInfo *info, int32_t *level); 44 45 typedef struct { 46 RequestDeviceSecurityInfoFunction requestDeviceSecurityInfo; 47 RequestDeviceSecurityInfoAsyncFunction requestDeviceSecurityInfoAsync; 48 FreeDeviceSecurityInfoFunction freeDeviceSecurityInfo; 49 GetDeviceSecurityLevelValueFunction getDeviceSecurityLevelValue; 50 int32_t version; 51 } DeviceSecEnv; 52 53 int32_t StartDevslEnv(void); 54 55 void FinishDevslEnv(void); 56 57 int32_t GetDeviceSecLevelByUdid(const uint8_t *udid, uint32_t udidLen, int32_t *devLevel); 58 59 int32_t CompareUdid(DEVSLQueryParams *queryParamsL, DEVSLQueryParams *queryParamsR); 60 61 int32_t GetDeviceSecLevelByUdidAsync(const uint8_t *udid, uint32_t udidLen); 62 63 uint32_t GetDataSecLevelByDevSecLevel(int32_t devLevel); 64 65 int32_t UpdateCallbackListParams(DEVSLQueryParams *queryParams, HigestSecInfoCallback *callback); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 #endif