mirror of
https://github.com/openharmony/security_deviceauth.git
synced 2026-07-21 03:15:26 -04:00
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hc_dev_info.h"
|
||||
#include "common_util.h"
|
||||
#include "hc_error.h"
|
||||
#include "hc_log.h"
|
||||
#include "hc_types.h"
|
||||
|
||||
#define UDID_BYTE_LEN_IN_L0_DEVICE 32
|
||||
|
||||
extern uint8_t GetUdid(uint8_t *buf, uint8_t length);
|
||||
|
||||
int32_t HcGetUdid(uint8_t *udid, int32_t udidLen)
|
||||
{
|
||||
if (udid == NULL || udidLen < INPUT_UDID_LEN || udidLen > MAX_INPUT_UDID_LEN) {
|
||||
return HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint8_t *udidInner = (uint8_t *)HcMalloc(UDID_BYTE_LEN_IN_L0_DEVICE, 0);
|
||||
if (udidInner == NULL) {
|
||||
return HAL_ERR_BAD_ALLOC;
|
||||
}
|
||||
uint8_t resultLen = GetUdid(udidInner, UDID_BYTE_LEN_IN_L0_DEVICE);
|
||||
if (resultLen != UDID_BYTE_LEN_IN_L0_DEVICE) {
|
||||
HcFree(udidInner);
|
||||
LOGE("GetUdid in L0 device failed, resultLen:%u", resultLen);
|
||||
return HAL_FAILED;
|
||||
}
|
||||
int32_t result = ByteToHexString(udidInner, UDID_BYTE_LEN_IN_L0_DEVICE, udid, udidLen);
|
||||
HcFree(udidInner);
|
||||
if (result != HAL_SUCCESS) {
|
||||
LOGE("ByteToHexString for udid failed, result:%d", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *GetStoragePath(void)
|
||||
{
|
||||
return "user/Hichain/hcgroup.dat";
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HC_DEV_INFO_H
|
||||
#define HC_DEV_INFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define INPUT_UDID_LEN 65
|
||||
#define MAX_INPUT_UDID_LEN 200
|
||||
#define MAX_SESSION_COUNT 10
|
||||
|
||||
/*
|
||||
* Get the unique device ID of the device(UDID).
|
||||
* udid: It is used to store the UDID finally obtained.
|
||||
* udidLen: The size of array to store UDID. Its value is the real udid size + 1 (including '\0').
|
||||
* In liteos and linux, the udidLen must be 65.
|
||||
* Return 0 if the UDID is successfully obtained, other returns an error code.
|
||||
*/
|
||||
int32_t HcGetUdid(uint8_t *udid, int32_t udidLen);
|
||||
|
||||
const char *GetStoragePath(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user