1 /* 2 * Copyright (C) 2021-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 #include "hc_dev_info.h" 17 #include "hal_error.h" 18 #include "hc_log.h" 19 #include "parameter.h" 20 #include "securec.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 HcGetUdid(uint8_t * udid,int32_t udidLen)26int32_t HcGetUdid(uint8_t *udid, int32_t udidLen) 27 { 28 if (udid == NULL || udidLen < INPUT_UDID_LEN || udidLen > MAX_INPUT_UDID_LEN) { 29 return HAL_ERR_INVALID_PARAM; 30 } 31 int32_t res = GetDevUdid((char *)udid, udidLen); 32 if (res != 0) { 33 LOGE("[UDID]: GetDevUdid fail. [Res]: %" LOG_PUB "d", res); 34 return HAL_FAILED; 35 } 36 return HAL_SUCCESS; 37 } 38 GetStoragePath(void)39const char *GetStoragePath(void) 40 { 41 #ifndef LITE_DEVICE 42 const char *storageFile = "/data/service/el1/public/deviceauth/hcgroup.dat"; 43 #else 44 const char *storageFile = "/storage/deviceauth/hcgroup.dat"; 45 #endif 46 return storageFile; 47 } 48 GetStorageDirPathCe(void)49const char *GetStorageDirPathCe(void) 50 { 51 return "/data/service/el2"; 52 } 53 GetStorageDirPath(void)54const char *GetStorageDirPath(void) 55 { 56 #ifndef LITE_DEVICE 57 const char *storageFile = "/data/service/el1/public/deviceauth"; 58 #else 59 const char *storageFile = "/storage/deviceauth"; 60 #endif 61 return storageFile; 62 } 63 GetAccountStoragePath(void)64const char *GetAccountStoragePath(void) 65 { 66 #ifndef LITE_DEVICE 67 const char *storageFile = "/data/service/el1/public/deviceauth/account"; 68 #else 69 const char *storageFile = "/storage/deviceauth/account"; 70 #endif 71 return storageFile; 72 } 73 GetPseudonymStoragePath(void)74const char *GetPseudonymStoragePath(void) 75 { 76 #ifndef LITE_DEVICE 77 const char *storageFile = "/data/service/el1/public/deviceauth/pseudonym"; 78 #else 79 const char *storageFile = "/storage/deviceauth/pseudonym"; 80 #endif 81 return storageFile; 82 } 83 84 #ifdef __cplusplus 85 } 86 #endif 87