fix: code style

Signed-off-by: lwk <liuwenkai@huawei.com>
This commit is contained in:
lwk 2022-04-22 11:50:37 +08:00
parent fda5ad0e0d
commit 6a6f7997d8
19 changed files with 170 additions and 170 deletions

View File

@ -93,14 +93,14 @@ static void ProcessSessionMessageReceived(const uint8_t *data, uint32_t len)
}
QueueMsgData *queueData = (QueueMsgData *)data;
if (queueData->msgLen + sizeof(QueueMsgData) != len) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, invalid input");
SECURITY_LOG_ERROR("invalid input");
return;
}
DeviceSessionManager *instance = GetDeviceSessionManagerInstance();
DeviceMessageReceiver messageReceiver = instance->messageReceiver;
if (messageReceiver == NULL) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, messageReceiver is null");
SECURITY_LOG_ERROR("messageReceiver is null");
return;
}
messageReceiver(&queueData->srcIdentity, queueData->msgdata, queueData->msgLen);
@ -112,36 +112,36 @@ static void OnSessionMessageReceived(const DeviceIdentify *devId, const uint8_t
DeviceSessionManager *instance = GetDeviceSessionManagerInstance();
WorkQueue *queue = instance->queue;
if (queue == NULL) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, queue is null");
SECURITY_LOG_ERROR("queue is null");
return;
}
DeviceMessageReceiver messageReceiver = instance->messageReceiver;
if (messageReceiver == NULL) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, messageReceiver is null");
SECURITY_LOG_ERROR("messageReceiver is null");
return;
}
uint32_t queueDataLen = sizeof(QueueMsgData) + msgLen;
QueueMsgData *queueData = MALLOC(queueDataLen);
if (queueData == NULL) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, malloc result null");
SECURITY_LOG_ERROR("malloc result null");
return;
}
uint32_t ret = (uint32_t)memcpy_s(&queueData->srcIdentity, sizeof(DeviceIdentify), devId, sizeof(DeviceIdentify));
if (ret != EOK) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, memcpy failed");
SECURITY_LOG_ERROR("memcpy failed");
FREE(queueData);
return;
}
ret = (uint32_t)memcpy_s(queueData->msgdata, msgLen, msg, msgLen);
if (ret != EOK) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, memcpy failed");
SECURITY_LOG_ERROR("memcpy failed");
FREE(queueData);
return;
}
queueData->msgLen = msgLen;
ret = QueueWork(queue, ProcessSessionMessageReceived, (uint8_t *)queueData, queueDataLen);
if (ret != WORK_QUEUE_OK) {
SECURITY_LOG_ERROR("ProcessSessionMessageReceived, QueueWork failed, ret is %{public}u", ret);
SECURITY_LOG_ERROR("QueueWork failed, ret is %{public}u", ret);
FREE(queueData);
return;
}
@ -155,14 +155,14 @@ static bool GetDeviceIdentityFromSessionId(int sessionId, DeviceIdentify *identi
char deviceName[DEVICE_ID_MAX_LEN + 1] = {0};
int ret = GetPeerDeviceId(sessionId, deviceName, DEVICE_ID_MAX_LEN + 1);
if (ret != 0) {
SECURITY_LOG_INFO("GetDeviceIdentityFromSessionId %{public}d failed, result is %{public}d", sessionId, ret);
SECURITY_LOG_INFO("GetPeerDeviceId failed, sessionId is %{public}d, result is %{public}d", sessionId, ret);
return false;
}
char udid[UDID_BUF_LEN] = {0};
DeviceSessionManager *instance = GetDeviceSessionManagerInstance();
if (GetNodeKeyInfo(instance->pkgName, deviceName, NODE_KEY_UDID, (uint8_t *)udid, UDID_BUF_LEN) != 0) {
SECURITY_LOG_ERROR("MessengerGetSelfDeviceIdentify GetNodeKeyInfo error.");
SECURITY_LOG_ERROR("GetNodeKeyInfo failed");
return false;
}
@ -175,7 +175,7 @@ static bool GetDeviceIdentityFromSessionId(int sessionId, DeviceIdentify *identi
static int MessengerOnSessionOpened(int sessionId, int result)
{
int side = GetSessionSide(sessionId);
SECURITY_LOG_INFO("MessengerOnSessionOpened id=%{public}d, side=%{public}s, result=%{public}d", sessionId,
SECURITY_LOG_INFO("sessionId=%{public}d, side=%{public}s, result=%{public}d", sessionId,
(side == IS_SERVER) ? "server" : "client", result);
if (side == IS_SERVER) {
@ -189,13 +189,13 @@ static int MessengerOnSessionOpened(int sessionId, int result)
uint32_t maskId;
bool ret = GetDeviceIdentityFromSessionId(sessionId, &identity, &maskId);
if (ret == false) {
SECURITY_LOG_ERROR("MessengerOnSessionOpened GetDeviceIdentityFromSessionId failed");
SECURITY_LOG_ERROR("GetDeviceIdentityFromSessionId failed");
return 0;
}
SessionInfo *sessionInfo = MALLOC(sizeof(SessionInfo));
if (sessionInfo == NULL) {
SECURITY_LOG_ERROR("MessengerOnSessionOpened malloc failed");
SECURITY_LOG_ERROR("malloc failed, sessionInfo is null");
return 0;
}
sessionInfo->sessionId = sessionId;
@ -218,7 +218,7 @@ static int MessengerOnSessionOpened(int sessionId, int result)
RemoveListNode(node);
int ret = SendBytes(sessionId, msgData->msgdata, msgData->msgLen);
if (ret != 0) {
SECURITY_LOG_ERROR("MessengerSendMsgTo SendBytes error code = %{public}d", ret);
SECURITY_LOG_ERROR("SendBytes error code = %{public}d", ret);
}
FREE(msgData);
}
@ -230,7 +230,7 @@ static int MessengerOnSessionOpened(int sessionId, int result)
static void MessengerOnSessionClosed(int sessionId)
{
int side = GetSessionSide(sessionId);
SECURITY_LOG_INFO("MessengerOnSessionClosed id=%{public}d, side=%{public}s", sessionId,
SECURITY_LOG_INFO("sessionId=%{public}d, side=%{public}s", sessionId,
(side == IS_SERVER) ? "server" : "client");
if (side == IS_SERVER) {
@ -244,7 +244,7 @@ static void MessengerOnSessionClosed(int sessionId)
FOREACH_LIST_NODE_SAFE (node, &instance->openedSessionList, temp) {
SessionInfo *info = LIST_ENTRY(node, SessionInfo, link);
if (info->sessionId == sessionId) {
SECURITY_LOG_INFO("MessengerOnSessionClosed device=%{public}x", info->maskId);
SECURITY_LOG_INFO("device=%{public}x", info->maskId);
RemoveListNode(node);
FREE(info);
}
@ -261,7 +261,7 @@ static void MessengerOnBytesReceived(int sessionId, const void *data, unsigned i
if (ret == false) {
return;
}
SECURITY_LOG_INFO("MessengerOnBytesReceived from device(%{public}x***, data length is %{public}u", maskId, dataLen);
SECURITY_LOG_INFO("device=%{public}x***, data length is %{public}u", maskId, dataLen);
OnSessionMessageReceived(&identity, (const uint8_t *)data, (uint32_t)dataLen);
}
@ -291,11 +291,11 @@ bool InitDeviceSessionManager(WorkQueue *queue, const char *pkgName, const char
}
if (ret != 0) {
SECURITY_LOG_ERROR("InitSessionManager CreateSessionServer failed = %{public}d", ret);
SECURITY_LOG_ERROR("CreateSessionServer failed = %{public}d", ret);
return false;
}
SECURITY_LOG_INFO("InitSessionManager CreateSessionServer success");
SECURITY_LOG_INFO("CreateSessionServer success");
return true;
}
@ -304,7 +304,7 @@ bool DeInitDeviceSessionManager(void)
DeviceSessionManager *instance = GetDeviceSessionManagerInstance();
int ret = RemoveSessionServer(instance->pkgName, instance->sessionName);
if (ret != 0) {
SECURITY_LOG_ERROR("DeInitSessionManager RemoveSessionServer failed = %{public}d", ret);
SECURITY_LOG_ERROR("RemoveSessionServer failed = %{public}d", ret);
return false;
}
LockMutex(&instance->mutex);
@ -332,7 +332,7 @@ bool DeInitDeviceSessionManager(void)
DestroyWorkQueue(instance->queue);
UnlockMutex(&instance->mutex);
SECURITY_LOG_INFO("DeInitSessionManager RemoveSessionServer success");
SECURITY_LOG_INFO("RemoveSessionServer success");
return true;
}
@ -357,7 +357,7 @@ static bool GetOpenedSessionId(const DeviceIdentify *devId, int32_t *sessionId)
}
}
UnlockMutex(&instance->mutex);
SECURITY_LOG_DEBUG("GetOpenedSessionId for device %{public}x %{public}s", mask, find ? "exist" : "no exist");
SECURITY_LOG_DEBUG("device %{public}x %{public}s", mask, find ? "exist" : "no exist");
return find;
}
@ -365,7 +365,7 @@ static void PushMsgDataToPendingList(uint32_t transNo, const DeviceIdentify *dev
{
PendingMsgData *data = MALLOC(sizeof(PendingMsgData) + msgLen);
if (data == NULL) {
SECURITY_LOG_ERROR("PushMsgDataToPendingList malloc error");
SECURITY_LOG_ERROR("malloc failed, data is null");
return;
}
data->transNo = transNo;
@ -384,7 +384,7 @@ static void CreateNewDeviceSession(const DeviceIdentify *devId)
char deviceName[DEVICE_ID_MAX_LEN + 1] = {0};
bool succ = MessengerGetDeviceNetworkId(devId, deviceName, DEVICE_ID_MAX_LEN + 1);
if (!succ) {
SECURITY_LOG_ERROR("CreateNewDeviceSession get network id error");
SECURITY_LOG_ERROR("get network id failed");
return;
}
@ -397,13 +397,13 @@ static void CreateNewDeviceSession(const DeviceIdentify *devId)
// open failed, need to try again.
ret = OpenSession(instance->sessionName, instance->sessionName, deviceName, "", &attr);
}
SECURITY_LOG_INFO("CreateNewDeviceSession for device %{public}x ret is %{public}d", mask, ret);
SECURITY_LOG_INFO("device %{public}x ret is %{public}d", mask, ret);
}
void MessengerSendMsgTo(uint64_t transNo, const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen)
{
if (devId == NULL || msg == NULL || msgLen == 0) {
SECURITY_LOG_ERROR("MessengerSendMsgTo error for invalid para");
SECURITY_LOG_ERROR("invalid params");
return;
}
@ -412,7 +412,7 @@ void MessengerSendMsgTo(uint64_t transNo, const DeviceIdentify *devId, const uin
MessengerGetSelfDeviceIdentify(&self, &devType);
if (IsSameDevice(&self, devId)) {
SECURITY_LOG_DEBUG("MessengerSendMsgTo loopback msg");
SECURITY_LOG_DEBUG("loopback msg");
OnSessionMessageReceived(devId, msg, msgLen);
return;
}
@ -422,7 +422,7 @@ void MessengerSendMsgTo(uint64_t transNo, const DeviceIdentify *devId, const uin
if (find) {
int ret = SendBytes(sessionId, msg, msgLen);
if (ret != 0) {
SECURITY_LOG_ERROR("MessengerSendMsgTo SendBytes error code = %{public}d", ret);
SECURITY_LOG_ERROR("SendBytes error code = %{public}d", ret);
}
} else {
PushMsgDataToPendingList(transNo, devId, msg, msgLen);

View File

@ -37,7 +37,7 @@ typedef struct Messenger {
Messenger *CreateMessengerImpl(const MessengerConfig *config)
{
if (config == NULL) {
SECURITY_LOG_ERROR("CreateMessengerImpl error para");
SECURITY_LOG_ERROR("config is null");
return NULL;
}
@ -73,7 +73,7 @@ Messenger *CreateMessengerImpl(const MessengerConfig *config)
void DestroyMessengerImpl(Messenger *messenger)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("DestroyMessengerImpl error para");
SECURITY_LOG_ERROR("invalid params");
return;
}
DeInitDeviceStatusManager();
@ -86,7 +86,7 @@ void DestroyMessengerImpl(Messenger *messenger)
bool IsMessengerReadyImpl(const Messenger *messenger)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("IsMessengerReadyImpl error para");
SECURITY_LOG_ERROR("invalid params");
return false;
}
return true;
@ -96,7 +96,7 @@ void SendMsgToImpl(const Messenger *messenger, uint64_t transNo, const DeviceIde
uint32_t msgLen)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("SendMsgToImpl error para");
SECURITY_LOG_ERROR("invalid params");
return;
}
MessengerSendMsgTo(transNo, devId, msg, msgLen);
@ -105,7 +105,7 @@ void SendMsgToImpl(const Messenger *messenger, uint64_t transNo, const DeviceIde
bool GetDeviceOnlineStatusImpl(const Messenger *messenger, const DeviceIdentify *devId, uint32_t *devType)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("GetDeviceOnlineStatusImpl error para");
SECURITY_LOG_ERROR("invalid params");
return false;
}
@ -115,7 +115,7 @@ bool GetDeviceOnlineStatusImpl(const Messenger *messenger, const DeviceIdentify
bool GetSelfDeviceIdentifyImpl(const Messenger *messenger, DeviceIdentify *devId, uint32_t *devType)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("GetSelfDeviceIdentifyImpl error para");
SECURITY_LOG_ERROR("invalid params");
return false;
}
@ -125,7 +125,7 @@ bool GetSelfDeviceIdentifyImpl(const Messenger *messenger, DeviceIdentify *devId
void ForEachDeviceProcessImpl(const Messenger *messenger, const DeviceProcessor processor, void *para)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("ForEachDeviceProcessImpl error para");
SECURITY_LOG_ERROR("invalid params");
return;
}
@ -135,7 +135,7 @@ void ForEachDeviceProcessImpl(const Messenger *messenger, const DeviceProcessor
bool GetDeviceStatisticInfoImpl(const Messenger *messenger, const DeviceIdentify *devId, StatisticInformation *info)
{
if (messenger == NULL || messenger->magicHead != MESSENGER_MAGIC_HEAD) {
SECURITY_LOG_ERROR("GetDeviceStatisticInfoImpl error para");
SECURITY_LOG_ERROR("invalid params");
return false;
}
(void)devId;

View File

@ -45,7 +45,7 @@ inline static void InitMutex(Mutex *mutex)
{
int ret = pthread_mutex_init(&mutex->mutex, NULL);
if (ret != 0) {
SECURITY_LOG_ERROR("InitMutex pthread_mutex_init error");
SECURITY_LOG_ERROR("pthread_mutex_init error");
}
}
@ -56,7 +56,7 @@ inline static void InitRecursiveMutex(Mutex *mutex)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
int ret = pthread_mutex_init(&mutex->mutex, &attr);
if (ret != 0) {
SECURITY_LOG_ERROR("InitRecursiveMutex pthread_mutex_init error");
SECURITY_LOG_ERROR("pthread_mutex_init error");
}
}
@ -64,7 +64,7 @@ inline static void LockMutex(Mutex *mutex)
{
int ret = pthread_mutex_lock(&(mutex->mutex));
if (ret != 0) {
SECURITY_LOG_ERROR("LockMutex pthread_mutex_lock error");
SECURITY_LOG_ERROR("pthread_mutex_lock error");
}
}
@ -72,7 +72,7 @@ inline static void UnlockMutex(Mutex *mutex)
{
int ret = pthread_mutex_unlock(&(mutex->mutex));
if (ret != 0) {
SECURITY_LOG_ERROR("UnlockMutex pthread_mutex_unlock error");
SECURITY_LOG_ERROR("pthread_mutex_unlock error");
}
}

View File

@ -159,24 +159,24 @@ static int32_t Base64Decode(const uint8_t *from, uint8_t *to, uint32_t toCheckLe
uint8_t *Base64EncodeApp(const uint8_t *from, uint32_t fromLen)
{
if (from == NULL) {
SECURITY_LOG_DEBUG("Unexpected nullptr!");
SECURITY_LOG_DEBUG("invalid param, from is null");
return NULL;
}
uint32_t outSize = (fromLen + 2) / 3 * 4; // get base64 encode size
if (outSize + 1 > MAX_MALLOC_LEN) {
SECURITY_LOG_DEBUG("Invalid MALLOC length!");
SECURITY_LOG_DEBUG("invalid MALLOC length");
return NULL;
}
uint8_t *out = (uint8_t *)MALLOC(outSize + 1);
if (out == NULL) {
SECURITY_LOG_DEBUG("Memory allocation failed!");
SECURITY_LOG_DEBUG("malloc failed, out is null");
return NULL;
}
int realLen = Base64Encode(from, fromLen, out, outSize);
if (realLen < 0) {
SECURITY_LOG_DEBUG("Base64EncodeApp fail");
SECURITY_LOG_DEBUG("Base64EncodeApp failed");
FREE(out);
return NULL;
}
@ -187,25 +187,25 @@ uint8_t *Base64EncodeApp(const uint8_t *from, uint32_t fromLen)
int32_t Base64DecodeApp(const uint8_t *src, uint8_t **to)
{
if ((src == NULL) || (to == NULL)) {
SECURITY_LOG_DEBUG("Unexpected nullptr!");
SECURITY_LOG_DEBUG("invalid params");
return 0;
}
uint32_t decodedLen = strlen((char *)src) / 4 * 3; /* Base64 Decode size */
if (decodedLen + 1 > MAX_MALLOC_LEN) {
SECURITY_LOG_DEBUG("Base64DecodeApp decodedLen err");
SECURITY_LOG_DEBUG("decodedLen error");
return 0;
}
uint8_t *decoded = (uint8_t *)MALLOC(decodedLen + 1);
if (decoded == NULL) {
SECURITY_LOG_DEBUG("Base64DecodeApp MALLOC fail");
SECURITY_LOG_DEBUG("malloc failed, decoded is null");
return 0;
}
int realLen = Base64Decode(src, decoded, decodedLen);
if (realLen < 0) {
SECURITY_LOG_DEBUG("Base64DecodeApp fail");
SECURITY_LOG_DEBUG("Base64Decode failed");
FREE(decoded);
return 0;
}
@ -218,7 +218,7 @@ int32_t Base64DecodeApp(const uint8_t *src, uint8_t **to)
int32_t Base64UrlDecodeApp(const uint8_t *src, uint8_t **to)
{
if ((src == NULL) || (to == NULL)) {
SECURITY_LOG_DEBUG("Unexpected nullptr!");
SECURITY_LOG_DEBUG("invalid params");
return 0;
}
@ -226,7 +226,7 @@ int32_t Base64UrlDecodeApp(const uint8_t *src, uint8_t **to)
uint32_t alignLen = RESIZE4(sourceLen);
uint8_t *base64Str = (uint8_t *)malloc(alignLen + 1);
if (base64Str == NULL) {
SECURITY_LOG_DEBUG("Base64UrlDecodeApp MALLOC fail");
SECURITY_LOG_DEBUG("Base64UrlDecodeApp malloc failed");
return 0;
}
(void)memset_s(base64Str, alignLen + 1, '=', alignLen + 1);

View File

@ -55,7 +55,7 @@ int32_t HexStringToByte(const char *str, uint32_t strLen, uint8_t *hex, uint32_t
uint32_t outLen = strLen / BYTE_TO_HEX_OPER_LENGTH;
if (hexLen < outLen) { /* test the length */
SECURITY_LOG_DEBUG("HexStringToByte length error");
SECURITY_LOG_DEBUG("length error");
return ERR;
}

View File

@ -77,7 +77,7 @@ void ScheduleMachine(const StateNode *nodes, uint32_t nodeCnt, StateMachine *mac
{
// EventPara could be null, need not to check
if ((nodes == NULL) || (nodeCnt == 0) || (machine == NULL)) {
SECURITY_LOG_ERROR("nodes or context is null");
SECURITY_LOG_ERROR("invlid params, nodes or context is null");
return;
}
LockMutex(&machine->mutex);

View File

@ -95,14 +95,14 @@ int32_t EcdsaVerify(const struct DataBuffer *srcData, const struct DataBuffer *s
int32_t VerifyDslmCredential(const char *credentialString, DslmCredInfo *credentialInfo, AttestationList *list)
{
if (credentialString == NULL || credentialInfo == NULL) {
SECURITY_LOG_ERROR("VerifyDslmCredential input error");
SECURITY_LOG_ERROR("invalid prams, credentialString or credentialInfo is null");
return ERR_PARSE_CLOUD_CRED_DATA;
}
CredentialCb credentialCb = {0};
bool ret = CreateCredentialCb(credentialString, &credentialCb);
if (!ret) {
SECURITY_LOG_ERROR("CredentialStringToCredentialCb error");
SECURITY_LOG_ERROR("CreateCredentialCb error");
return ERR_PARSE_CLOUD_CRED_DATA;
}
@ -153,7 +153,6 @@ static bool CreateCredentialCb(const char *credentialString, CredentialCb *credC
SECURITY_LOG_ERROR("SplitCredentialAttestationList failed");
break;
}
SECURITY_LOG_INFO("CreateCredentialCb success");
result = true;
} while (0);
@ -161,6 +160,7 @@ static bool CreateCredentialCb(const char *credentialString, CredentialCb *credC
DestroyCredentialCb(credCb);
}
SECURITY_LOG_INFO("success");
return result;
}
@ -174,26 +174,26 @@ static bool VerifyCredentialCb(const CredentialCb *credCb)
// rootkey, signed by self
int32_t ret = EcdsaVerify(&root->publicKey, &root->signature, &root->publicKey, root->algorithm);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredentialCb root not success, ret is %{public}d", ret);
SECURITY_LOG_ERROR("verify root key failed, ret is %{public}d", ret);
return false;
}
SECURITY_LOG_INFO("VerifyCredentialCb root success");
SECURITY_LOG_INFO("verify root success");
// intermediate key, signed by root key
ret = EcdsaVerify(&intermediate->publicKey, &intermediate->signature, &root->publicKey, intermediate->algorithm);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredentialCb intermediate not success, ret is %{public}d", ret);
SECURITY_LOG_ERROR("verify intermediate key failed, ret is %{public}d", ret);
return false;
}
SECURITY_LOG_INFO("VerifyCredentialCb intermediate success");
SECURITY_LOG_INFO("verify intermediate success");
// last key, signed by intermediate key
ret = EcdsaVerify(&last->publicKey, &last->signature, &intermediate->publicKey, last->algorithm);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredentialCb last not success, ret is %{public}d", ret);
SECURITY_LOG_ERROR("verify last key failed, ret is %{public}d", ret);
return false;
}
SECURITY_LOG_INFO("VerifyCredentialCb last success");
SECURITY_LOG_INFO("verify last success");
// payload, signed by last key
ret = EcdsaVerify(&payload->payload, &payload->signature, &last->publicKey, TYPE_ECDSA_SHA_384);
@ -201,11 +201,11 @@ static bool VerifyCredentialCb(const CredentialCb *credCb)
ret = EcdsaVerify(&payload->payload, &payload->signature, &last->publicKey, TYPE_ECDSA_SHA_256);
}
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredentialCb payload not success, ret is %{public}d", ret);
SECURITY_LOG_ERROR("verify payload failed, ret is %{public}d", ret);
return false;
}
SECURITY_LOG_INFO("VerifyCredentialCb payload success");
SECURITY_LOG_INFO("verify payload success");
return true;
}
@ -398,12 +398,12 @@ static bool SplitCredentialAttestationList(CredentialCb *credCb)
bool result = false;
do {
if (!ParsePayloadAttestation(credCb, &credCb->load)) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList ParsePayloadAttestation failed");
SECURITY_LOG_ERROR("ParsePayloadAttestation failed");
break;
}
Base64DecodeApp((uint8_t *)credCb->attestionInfo, &buffer);
if (buffer == NULL) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList Base64DecodeApp failed");
SECURITY_LOG_ERROR("Base64DecodeApp failed");
break;
}
json = CreateJson((char *)buffer);
@ -411,19 +411,19 @@ static bool SplitCredentialAttestationList(CredentialCb *credCb)
break;
}
if (GetJsonFieldJsonArraySize(json) != PK_ATTEST_LIST_LEN) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList GetJsonFieldJsonArraySize failed");
SECURITY_LOG_ERROR("GetJsonFieldJsonArraySize failed");
break;
}
if (!ParsePublicKeyAttestation(json, PK_ATTEST_INDEX_ROOT, &credCb->root)) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList ParsePublicKeyAttestation root failed");
SECURITY_LOG_ERROR("ParsePublicKeyAttestation root failed");
break;
}
if (!ParsePublicKeyAttestation(json, PK_ATTEST_INDEX_INTER, &credCb->intermediate)) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList ParsePublicKeyAttestation intermediate failed");
SECURITY_LOG_ERROR("ParsePublicKeyAttestation intermediate failed");
break;
}
if (!ParsePublicKeyAttestation(json, PK_ATTEST_INDEX_LAST, &credCb->last)) {
SECURITY_LOG_ERROR("SplitCredentialAttestationList ParsePublicKeyAttestation last failed");
SECURITY_LOG_ERROR("ParsePublicKeyAttestation last failed");
break;
}
@ -528,29 +528,29 @@ int32_t EcdsaVerify(const struct DataBuffer *srcData, const struct DataBuffer *s
const EVP_MD *type = (algorithm == TYPE_ECDSA_SHA_256) ? EVP_sha256() : EVP_sha384();
EVP_PKEY *pkey = d2i_PUBKEY(NULL, &publicKey, pbkData->length);
if (pkey == NULL) {
SECURITY_LOG_ERROR("EcdsaVerify d2i_PUBKEY failed, length = %{public}d", pbkData->length);
SECURITY_LOG_ERROR("d2i_PUBKEY failed, length = %{public}d", pbkData->length);
return ERR_ECC_VERIFY_ERR;
}
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
SECURITY_LOG_ERROR("EcdsaVerify EVP_MD_CTX_new failed");
SECURITY_LOG_ERROR("EVP_MD_CTX_new failed");
EVP_PKEY_free(pkey);
return ERR_ECC_VERIFY_ERR;
}
do {
if (EVP_DigestVerifyInit(ctx, NULL, type, NULL, pkey) <= 0) {
SECURITY_LOG_ERROR("EcdsaVerify EVP_DigestVerifyInit failed");
SECURITY_LOG_ERROR("EVP_DigestVerifyInit failed");
break;
}
if (EVP_DigestUpdate(ctx, srcData->data, srcData->length) <= 0) {
SECURITY_LOG_ERROR("EcdsaVerify EVP_DigestUpdate failed");
SECURITY_LOG_ERROR("EVP_DigestUpdate failed");
break;
}
if (EVP_DigestVerifyFinal(ctx, sigData->data, sigData->length) <= 0) {
SECURITY_LOG_ERROR("EcdsaVerify EVP_DigestVerifyFinal failed");
SECURITY_LOG_ERROR("EVP_DigestVerifyFinal failed");
break;
}
} while (0);

View File

@ -25,21 +25,21 @@
int32_t InitOhosDslmCred(DslmCredInfo *credInfo)
{
SECURITY_LOG_INFO("Invoke InitOhosDslmCred");
SECURITY_LOG_INFO("start");
char credStr[DSLM_CRED_STR_LEN_MAX] = {0};
int32_t ret = GetCredFromCurrentDevice(credStr, DSLM_CRED_STR_LEN_MAX);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("InitOhosDslmCred, Read cred data from file failed!");
SECURITY_LOG_ERROR("read cred data from file failed");
return ret;
}
ret = VerifyDslmCredential(credStr, credInfo, NULL);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("InitOhosDslmCred, VerifyCredData failed!");
SECURITY_LOG_ERROR("verifyCredData failed!");
return ret;
}
credInfo->credType = CRED_TYPE_STANDARD;
SECURITY_LOG_INFO("InitOhosDslmCred success, self security level is %{public}d", credInfo->credLevel);
SECURITY_LOG_INFO("success, self security level is %{public}d", credInfo->credLevel);
return SUCCESS;
}

View File

@ -114,11 +114,11 @@ static int32_t RequestSmallDslmCred(uint8_t *data, uint32_t dataLen, DslmCredBuf
{
DslmCredBuff *out = CreateDslmCred(CRED_TYPE_SMALL, dataLen, data);
if (out == NULL) {
SECURITY_LOG_ERROR("RequestSmallDslmCred, CreateDslmCred failed");
SECURITY_LOG_ERROR("CreateDslmCred failed");
return ERR_MEMORY_ERR;
}
*credBuff = out;
SECURITY_LOG_INFO("RequestSmallDslmCred success!");
SECURITY_LOG_INFO("success");
return SUCCESS;
}
@ -129,18 +129,18 @@ static int32_t RequestStandardDslmCred(const DeviceIdentify *device, const Reque
uint32_t certChainLen = 0;
int32_t ret = GenerateDslmCertChain(device, obj, credStr, &certChain, &certChainLen);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("RequestStandardDslmCred, GenerateDslmCertChain failed");
SECURITY_LOG_ERROR("GenerateDslmCertChain failed");
return ret;
}
DslmCredBuff *out = CreateDslmCred(CRED_TYPE_STANDARD, certChainLen, certChain);
if (out == NULL) {
FREE(certChain);
SECURITY_LOG_ERROR("RequestStandardDslmCred, CreateDslmCred failed");
SECURITY_LOG_ERROR("CreateDslmCred failed");
return ERR_MEMORY_ERR;
}
FREE(certChain);
*credBuff = out;
SECURITY_LOG_INFO("RequestStandardDslmCred success!");
SECURITY_LOG_INFO("success");
return SUCCESS;
}
@ -152,18 +152,18 @@ int32_t GetCredFromCurrentDevice(char *credStr, uint32_t maxLen)
FILE *fp = NULL;
fp = fopen(DSLM_CRED_CFG_FILE_POSITION, "r");
if (fp == NULL) {
SECURITY_LOG_ERROR("fopen cred file failed!");
SECURITY_LOG_ERROR("fopen cred file failed");
return ERR_INVALID_PARA;
}
int32_t ret = fscanf_s(fp, "%s", credStr, maxLen);
if (ret == -1) {
SECURITY_LOG_ERROR("fscanf_s cred file failed!");
SECURITY_LOG_ERROR("fscanf_s cred file failed");
ret = ERR_INVALID_PARA;
} else {
ret = SUCCESS;
}
if (fclose(fp) != 0) {
SECURITY_LOG_ERROR("fclose cred file failed!");
SECURITY_LOG_ERROR("fclose cred file failed");
ret = ERR_INVALID_PARA;
}
return ret;
@ -171,17 +171,17 @@ int32_t GetCredFromCurrentDevice(char *credStr, uint32_t maxLen)
int32_t RequestOhosDslmCred(const DeviceIdentify *device, const RequestObject *obj, DslmCredBuff **credBuff)
{
SECURITY_LOG_INFO("Invoke RequestOhosDslmCred");
SECURITY_LOG_INFO("start");
uint32_t credType = 0;
char credStr[DSLM_CRED_STR_LEN_MAX] = {0};
int32_t ret = GetCredFromCurrentDevice(credStr, DSLM_CRED_STR_LEN_MAX);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("Read cred data from file failed!");
SECURITY_LOG_ERROR("read cred data from file failed");
return ret;
}
ret = SelectDslmCredType(device, obj, &credType);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("SelectDslmCredType failed!");
SECURITY_LOG_ERROR("SelectDslmCredType failed");
return ret;
}
switch (credType) {
@ -190,7 +190,7 @@ int32_t RequestOhosDslmCred(const DeviceIdentify *device, const RequestObject *o
case CRED_TYPE_STANDARD:
return RequestStandardDslmCred(device, obj, credStr, credBuff);
default:
SECURITY_LOG_ERROR("Invalid cred type!");
SECURITY_LOG_ERROR("invalid cred type");
return ERR_INVALID_PARA;
}

View File

@ -45,14 +45,14 @@ struct NonceOfCertChain {
static int32_t CheckCredInfo(const struct DeviceIdentify *device, DslmCredInfo *info, uint32_t maxLevel)
{
SECURITY_LOG_DEBUG("CheckCredInfo start!");
SECURITY_LOG_DEBUG("start");
if (info->credLevel > maxLevel) {
SECURITY_LOG_ERROR("Cred level = %{public}d check error.", info->credLevel);
SECURITY_LOG_ERROR("cred level = %{public}d check error", info->credLevel);
info->credLevel = 0;
return ERR_CHECK_CRED_INFO;
}
if (strlen(info->udid) == 0) {
SECURITY_LOG_DEBUG("Current cred has no udid, skip CheckCredInfo.");
SECURITY_LOG_DEBUG("current cred has no udid, skip CheckCredInfo");
return SUCCESS;
}
if (strncmp(info->releaseType, CRED_VALUE_TYPE_DEBUG, strlen(CRED_VALUE_TYPE_DEBUG)) == 0) {
@ -61,7 +61,7 @@ static int32_t CheckCredInfo(const struct DeviceIdentify *device, DslmCredInfo *
}
return ERR_CHECK_CRED_INFO;
}
SECURITY_LOG_DEBUG("CheckCredInfo SUCCESS!");
SECURITY_LOG_DEBUG("success");
return SUCCESS;
}
@ -154,13 +154,13 @@ static int32_t FindCommonPkInfo(const char *bufferA, const char *bufferB)
static int32_t CheckNonceOfCertChain(const struct NonceOfCertChain *nonce, uint64_t challenge, const char *pbkInfoList)
{
if (challenge != nonce->challenge) {
SECURITY_LOG_ERROR("compare nonce challenge failed!");
SECURITY_LOG_ERROR("compare nonce challenge failed");
return ERR_CHALLENGE_ERR;
}
int32_t ret = FindCommonPkInfo((char *)pbkInfoList, (char *)nonce->pbkInfoList);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("compare nonce public key info failed!");
SECURITY_LOG_ERROR("compare nonce public key info failed");
return ret;
}
return SUCCESS;
@ -181,22 +181,22 @@ static int32_t VerifyNonceOfCertChain(const char *jsonStr, const struct DeviceId
do {
ret = ParseNonceOfCertChain(jsonStr, &nonce);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("ParseNonceOfCertChain failed!");
SECURITY_LOG_ERROR("ParseNonceOfCertChain failed");
break;
}
ret = GetPkInfoListStr(false, udidStr, &pkInfoListStr);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("GetPkInfoListStr failed!");
SECURITY_LOG_ERROR("GetPkInfoListStr failed");
break;
}
ret = CheckNonceOfCertChain(&nonce, challenge, pkInfoListStr);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("CheckNonceOfCertChain failed!");
SECURITY_LOG_ERROR("CheckNonceOfCertChain failed");
break;
}
SECURITY_LOG_DEBUG("VerifyNonceOfCertChain success!");
SECURITY_LOG_DEBUG("success");
} while (0);
FreeNonceOfCertChain(&nonce);
@ -213,13 +213,13 @@ static int32_t verifySmallDslmCred(const DeviceIdentify *device, const DslmCredB
int32_t ret = VerifyDslmCredential(credStr, credInfo, NULL);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredData failed!");
SECURITY_LOG_ERROR("VerifyDslmCredential failed");
return ret;
}
ret = CheckCredInfo(device, credInfo, CRED_MAX_LEVEL_TYPE_SMALL);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("CheckCredInfo failed!");
SECURITY_LOG_ERROR("CheckCredInfo failed");
return ret;
}
@ -232,7 +232,7 @@ static int32_t verifyStandardDslmCred(const DeviceIdentify *device, uint64_t cha
struct DslmInfoInCertChain resultInfo;
int32_t ret = InitDslmInfoInCertChain(&resultInfo);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("InitDslmInfoInCertChain failed!");
SECURITY_LOG_ERROR("InitDslmInfoInCertChain failed");
return ret;
}
@ -240,33 +240,33 @@ static int32_t verifyStandardDslmCred(const DeviceIdentify *device, uint64_t cha
// 1. Verify the certificate chain, get data in the certificate chain(nonce + UDID + cred).
ret = ValidateCertChainAdapter(credBuff->credVal, credBuff->credLen, &resultInfo);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("ValidateCertChainAdapter failed!");
SECURITY_LOG_ERROR("ValidateCertChainAdapter failed");
break;
}
// 2. Parses the NONCE into CHALLENGE and PK_INFO_LIST, verifies them separtely.
ret = VerifyNonceOfCertChain(resultInfo.nonceStr, device, challenge);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("verifyNonceOfCertChain failed!");
SECURITY_LOG_ERROR("verifyNonceOfCertChain failed");
break;
}
// 3. The cred content is "<header>.<payload>.<signature>.<attestion>", parse and verify it.
ret = VerifyDslmCredential(resultInfo.credStr, credInfo, NULL);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyCredData failed!");
SECURITY_LOG_ERROR("VerifyDslmCredential failed");
break;
}
ret = CheckCredInfo(device, credInfo, CRED_MAX_LEVEL_TYPE_STANDARD);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("CheckCredInfo failed!");
SECURITY_LOG_ERROR("CheckCredInfo failed");
break;
}
} while (0);
DestroyDslmInfoInCertChain(&resultInfo);
if (ret == SUCCESS) {
SECURITY_LOG_INFO("VerifyOhosDslmCred success, cred level = %{public}d", credInfo->credLevel);
SECURITY_LOG_INFO("success, cred level = %{public}d", credInfo->credLevel);
}
return ret;
}
@ -278,7 +278,7 @@ int32_t VerifyOhosDslmCred(const DeviceIdentify *device, uint64_t challenge, con
return ERR_INVALID_PARA;
}
SECURITY_LOG_INFO("Invoke VerifyOhosDslmCred");
SECURITY_LOG_INFO("start");
credInfo->credType = credBuff->type;
switch (credBuff->type) {
case CRED_TYPE_SMALL:
@ -286,7 +286,7 @@ int32_t VerifyOhosDslmCred(const DeviceIdentify *device, uint64_t challenge, con
case CRED_TYPE_STANDARD:
return verifyStandardDslmCred(device, challenge, credBuff, credInfo);
default:
SECURITY_LOG_ERROR("Invalid cred type!");
SECURITY_LOG_ERROR("invalid cred type");
break;
}
return ERR_INVALID_PARA;

View File

@ -43,7 +43,7 @@ const char *pkInfoBase = "[{\"groupId\" : \"0\",\"publicKey\" : \"0\"}]";
int32_t GetPkInfoListStr(bool isSelf, const char *udidStr, char **pkInfoList)
{
SECURITY_LOG_INFO("GetPkInfoListStr start");
SECURITY_LOG_INFO("start");
char paramJson[DEVICE_AUTH_INPUT_PARAM_STRING_LENGTH] = {0};
char *resultBuffer = NULL;
@ -58,12 +58,12 @@ int32_t GetPkInfoListStr(bool isSelf, const char *udidStr, char **pkInfoList)
const DeviceGroupManager *interface = GetGmInstance();
ret = interface->getPkInfoList(ANY_OS_ACCOUNT, "dslm_service", paramJson, &resultBuffer, &resultNum);
if (ret != SUCCESS) {
SECURITY_LOG_INFO("getPkInfoList failed! ret = %{public}d", ret);
SECURITY_LOG_INFO("getPkInfoList failed, ret = %{public}d", ret);
return ERR_CALL_EXTERNAL_FUNC;
}
if (memcmp(resultBuffer, pkInfoEmpty, strlen(pkInfoEmpty)) == 0) {
SECURITY_LOG_INFO("Current pkInfoList is null");
SECURITY_LOG_INFO("current pkInfoList is null");
*pkInfoList = (char *)MALLOC(strlen(pkInfoBase) + 1);
if (strcpy_s(*pkInfoList, strlen(pkInfoBase) + 1, pkInfoBase) != EOK) {
ret = ERR_MEMORY_ERR;
@ -80,11 +80,11 @@ int32_t GetPkInfoListStr(bool isSelf, const char *udidStr, char **pkInfoList)
int32_t DslmCredAttestAdapter(struct DslmInfoInCertChain *info, uint8_t **certChain, uint32_t *certChainLen)
{
SECURITY_LOG_INFO("DslmCredAttestAdapter start");
SECURITY_LOG_INFO("start");
struct HksBlob keyAlias = {sizeof(g_dslmKey), (uint8_t *)g_dslmKey};
if (HksGenerateKeyAdapter(&keyAlias) != SUCCESS) {
SECURITY_LOG_ERROR("HksGenerateKeyAdapter failed!");
SECURITY_LOG_ERROR("HksGenerateKeyAdapter failed");
return ERR_HUKS_ERR;
}
struct HksParam inputData[] = {
@ -101,11 +101,11 @@ int32_t DslmCredAttestAdapter(struct DslmInfoInCertChain *info, uint8_t **certCh
int32_t ret = ConstructHksCertChain(&hksCertChain, &certParam);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("ConstructHksCertChain ret = %{public}d ", ret);
SECURITY_LOG_ERROR("ConstructHksCertChain failed, ret = %{public}d ", ret);
return ret;
}
if (FillHksParamSet(&inputParam, inputData, sizeof(inputData) / sizeof(inputData[0])) != SUCCESS) {
SECURITY_LOG_ERROR("DslmCredAttestAdapter, FillHksParamSet failed.");
SECURITY_LOG_ERROR("FillHksParamSet failed");
DestroyHksCertChain(hksCertChain);
return ERR_CALL_EXTERNAL_FUNC;
}
@ -118,7 +118,7 @@ int32_t DslmCredAttestAdapter(struct DslmInfoInCertChain *info, uint8_t **certCh
}
ret = HksCertChainToBuffer(hksCertChain, certChain, certChainLen);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("HksCertChainToHksBlob failed!");
SECURITY_LOG_ERROR("HksCertChainToHksBlob failed");
HksFreeParamSet(&inputParam);
DestroyHksCertChain(hksCertChain);
FREE(*certChain);
@ -127,13 +127,13 @@ int32_t DslmCredAttestAdapter(struct DslmInfoInCertChain *info, uint8_t **certCh
}
HksFreeParamSet(&inputParam);
DestroyHksCertChain(hksCertChain);
SECURITY_LOG_DEBUG("DslmCredAttestAdapter success, certChainLen = %{public}d ", *certChainLen);
SECURITY_LOG_DEBUG("success, certChainLen = %{public}d ", *certChainLen);
return SUCCESS;
}
int32_t ValidateCertChainAdapter(const uint8_t *data, uint32_t dataLen, struct DslmInfoInCertChain *resultInfo)
{
SECURITY_LOG_INFO("ValidateCertChainAdapter start");
SECURITY_LOG_INFO("start");
char nonceStr[DSLM_INFO_MAX_LEN_NONCE] = {0};
char credStr[DSLM_INFO_MAX_LEN_CRED] = {0};
@ -149,16 +149,16 @@ int32_t ValidateCertChainAdapter(const uint8_t *data, uint32_t dataLen, struct D
struct HksCertChain hksCertChain = {&certBlob[0], CERT_CHAIN_CERT_NUM};
if (BufferToHksCertChain(data, dataLen, &hksCertChain) != SUCCESS) {
SECURITY_LOG_ERROR("BufferToHksCertChain failed.");
SECURITY_LOG_ERROR("BufferToHksCertChain failed");
return ERR_CALL_EXTERNAL_FUNC;
}
if (FillHksParamSet(&outputParam, outputData, sizeof(outputData) / sizeof(outputData[0])) != SUCCESS) {
SECURITY_LOG_ERROR("ValidateCertChainAdapter, FillHksParamSet failed.");
SECURITY_LOG_ERROR("FillHksParamSet failed");
return ERR_CALL_EXTERNAL_FUNC;
}
if (HksValidateCertChain(&hksCertChain, outputParam) != HKS_SUCCESS) {
SECURITY_LOG_ERROR("HksValidateCertChain failed!");
SECURITY_LOG_ERROR("HksValidateCertChain failed");
HksFreeParamSet(&outputParam);
return ERR_CALL_EXTERNAL_FUNC;
}
@ -181,7 +181,7 @@ int32_t ValidateCertChainAdapter(const uint8_t *data, uint32_t dataLen, struct D
return ERR_MEMORY_ERR;
}
SECURITY_LOG_INFO("ValidateCertChainAdapter success!");
SECURITY_LOG_INFO("success");
HksFreeParamSet(&outputParam);
return SUCCESS;
}
@ -189,7 +189,7 @@ int32_t ValidateCertChainAdapter(const uint8_t *data, uint32_t dataLen, struct D
int32_t HksAttestIsReadyAdapter(void)
{
if (HcmIsDeviceKeyExist(NULL) != HKS_SUCCESS) {
SECURITY_LOG_ERROR("Hks attest not ready!");
SECURITY_LOG_ERROR("Hks attest not ready");
return ERR_CALL_EXTERNAL_FUNC;
}
return SUCCESS;

View File

@ -63,7 +63,7 @@ int32_t FillHksParamSet(struct HksParamSet **paramSet, struct HksParam *param, i
int32_t HksGenerateKeyAdapter(const struct HksBlob *keyAlias)
{
if (keyAlias == NULL) {
SECURITY_LOG_ERROR("keyAlias is null.");
SECURITY_LOG_ERROR("keyAlias is null");
return ERR_INVALID_PARA;
}
struct HksParam tmpParams[] = {
@ -78,7 +78,7 @@ int32_t HksGenerateKeyAdapter(const struct HksBlob *keyAlias)
};
struct HksParamSet *paramSet = NULL;
if (FillHksParamSet(&paramSet, tmpParams, sizeof(tmpParams) / sizeof(tmpParams[0])) != SUCCESS) {
SECURITY_LOG_ERROR("HksGenerateKeyAdapter, FillHksParamSet failed.");
SECURITY_LOG_ERROR("FillHksParamSet failed");
return ERR_HUKS_ERR;
}
int32_t ret = HksGenerateKey(keyAlias, paramSet, NULL);

View File

@ -43,7 +43,7 @@ int32_t OnPeerMsgRequestInfoReceived(const DeviceIdentify *deviceId, const uint8
return ERR_INVALID_PARA;
}
SECURITY_LOG_DEBUG("OnPeerMsgRequestInfoReceived msg is %s", (char *)msg);
SECURITY_LOG_DEBUG("msg is %s", (char *)msg);
MessageBuff buff = {.length = len, .buff = (uint8_t *)msg};
RequestObject reqObject;
@ -79,11 +79,11 @@ int32_t OnPeerMsgResponseInfoReceived(const DeviceIdentify *deviceId, const uint
if (deviceId == NULL || msg == NULL || len == 0) {
return ERR_INVALID_PARA;
}
SECURITY_LOG_DEBUG("OnPeerMsgResponseInfoReceived msg is %s", (char *)msg);
SECURITY_LOG_DEBUG("msg is %s", (char *)msg);
DslmDeviceInfo *deviceInfo = GetDslmDeviceInfo(deviceId);
if (deviceInfo == NULL) {
SECURITY_LOG_ERROR("OnPeerMsgResponseInfoReceived no existed device");
SECURITY_LOG_ERROR("no existed device");
return ERR_NOEXIST_DEVICE;
}
@ -99,7 +99,7 @@ int32_t OnPeerMsgResponseInfoReceived(const DeviceIdentify *deviceId, const uint
int32_t OnMsgSendResultNotifier(const DeviceIdentify *deviceId, uint64_t transNo, uint32_t result)
{
SECURITY_LOG_INFO("OnMsgSendResultNotifier msg trans is %{public}u result %{public}u", (uint32_t)transNo, result);
SECURITY_LOG_INFO("msg trans is %{public}u result %{public}u", (uint32_t)transNo, result);
if (result == SUCCESS) {
return SUCCESS;
@ -128,12 +128,12 @@ int32_t OnRequestDeviceSecLevelInfo(const DeviceIdentify *deviceId, const Reques
uint32_t cookie, RequestCallback callback)
{
if (deviceId == NULL || option == NULL || callback == NULL) {
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo invalid para");
SECURITY_LOG_ERROR("invalid params");
return ERR_INVALID_PARA;
}
if (GetMessengerStatus() != true) {
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo softbus service not startup complete");
SECURITY_LOG_ERROR("softbus service not startup complete");
return ERR_MSG_NOT_INIT;
}
@ -141,19 +141,19 @@ int32_t OnRequestDeviceSecLevelInfo(const DeviceIdentify *deviceId, const Reques
DslmDeviceInfo *deviceInfo = GetDslmDeviceInfo(curr);
if (deviceInfo == NULL) {
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo input device not exist");
SECURITY_LOG_ERROR("input device not exist");
return ERR_NOEXIST_DEVICE;
}
ReportHiEventAppInvoke(deviceInfo);
if (deviceInfo->onlineStatus != ONLINE_STATUS_ONLINE) {
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo input device not online");
SECURITY_LOG_ERROR("input device not online");
return ERR_NOT_ONLINE;
}
DslmNotifyListNode *notifyNode = MALLOC(sizeof(DslmNotifyListNode));
if (notifyNode == NULL) {
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo malloc error");
SECURITY_LOG_ERROR("malloc failed, notifyNode is null");
return ERR_NO_MEMORY;
}
notifyNode->owner = owner;
@ -186,13 +186,13 @@ bool InitSelfDeviceSecureLevel(void)
uint32_t devType = 0;
const DeviceIdentify *device = GetSelfDevice(&devType);
if (device->length == 0) {
SECURITY_LOG_ERROR("InitDeviceSecLevel, GetSelfDevice failed");
SECURITY_LOG_ERROR("GetSelfDevice failed");
return false;
}
DslmDeviceInfo *info = CreatOrGetDslmDeviceInfo(device);
if (info == NULL) {
SECURITY_LOG_ERROR("InitDeviceSecLevel, CreatOrGetDslmDeviceInfo failed");
SECURITY_LOG_ERROR("CreatOrGetDslmDeviceInfo failed");
return false;
}
@ -215,7 +215,7 @@ bool InitSelfDeviceSecureLevel(void)
ret = OnPeerStatusReceiver(device, ONLINE_STATUS_ONLINE, devType);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("InitDeviceSecLevel, make self online failed");
SECURITY_LOG_ERROR("make self online failed");
}
return true;
}

View File

@ -37,7 +37,7 @@ bool InitDslmCredentialFunctions(const ProcessDslmCredFunctions *funcs)
}
ProcessDslmCredFunctions *cb = GetFunctionCb();
(void)memcpy_s(cb, sizeof(ProcessDslmCredFunctions), funcs, sizeof(ProcessDslmCredFunctions));
SECURITY_LOG_INFO("InitDslmCredentialFunctions success");
SECURITY_LOG_INFO("success");
return true;
}
@ -48,7 +48,7 @@ int32_t DefaultRequestDslmCred(const DeviceIdentify *device, const RequestObject
if (request != NULL) {
return request(device, obj, credBuff);
}
SECURITY_LOG_INFO("invoke DefaultRequestDslmCred");
SECURITY_LOG_INFO("failed");
return -1;
}

View File

@ -110,7 +110,7 @@ DslmDeviceInfo *CreatOrGetDslmDeviceInfo(const DeviceIdentify *device)
AddListNode(&info->linkNode, GetDeviceList());
InitListHead(&info->notifyList);
UnlockMutex(GetDeviceListMutex());
SECURITY_LOG_INFO("Create new DslmDeviceInfo %{public}x", info->machine.machineId);
SECURITY_LOG_INFO("create new DslmDeviceInfo %{public}x", info->machine.machineId);
return info;
}

View File

@ -65,8 +65,8 @@ int32_t SendDeviceInfoRequest(DslmDeviceInfo *device)
device->transNum++;
SendMsgToDevice(device->transNum, &device->identity, buff->buff, buff->length);
SECURITY_LOG_DEBUG("SendDeviceInfoRequest %s", (char *)buff->buff);
SECURITY_LOG_INFO("SendDeviceInfoRequest challenge is %{public}x***, transNum is %{public}u.",
SECURITY_LOG_DEBUG("buff is %s", (char *)buff->buff);
SECURITY_LOG_INFO("challenge is %{public}x***, transNum is %{public}u",
(uint32_t)device->nonce, (uint32_t)device->transNum);
FreeMessageBuff(buff);
return SUCCESS;
@ -87,20 +87,20 @@ int32_t VerifyDeviceInfoResponse(DslmDeviceInfo *device, const MessageBuff *buff
// Parse the msg
ret = ParseDeviceSecInfoResponse(buff, &nonce, &version, &cred);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("VerifyDeviceInfoResponse error %{public}d.", ret);
SECURITY_LOG_ERROR("ParseDeviceSecInfoResponse failed, ret is %{public}d", ret);
break;
}
device->version = version;
if (nonce != device->nonce || nonce == 0) {
ret = ERR_CHALLENGE_ERR;
SECURITY_LOG_ERROR("VerifyDeviceInfoResponse nonce not equal.");
SECURITY_LOG_ERROR("nonce not equal");
DestroyDslmCred(cred);
break;
}
uint64_t curr = GetMillisecondSinceBoot();
if ((curr <= device->nonceTimeStamp) || (curr - device->nonceTimeStamp > NONCE_ALIVE_TIME)) {
ret = ERR_CHALLENGE_ERR;
SECURITY_LOG_ERROR("VerifyDeviceInfoResponse nonce expired.");
SECURITY_LOG_ERROR("nonce expired");
DestroyDslmCred(cred);
break;
}
@ -109,7 +109,7 @@ int32_t VerifyDeviceInfoResponse(DslmDeviceInfo *device, const MessageBuff *buff
DestroyDslmCred(cred);
} while (0);
SECURITY_LOG_INFO("VerifyDeviceInfoResponse challenge is %{public}x***, ret is %{public}d.", (uint32_t)nonce, ret);
SECURITY_LOG_INFO("challenge is %{public}x***, ret is %{public}d", (uint32_t)nonce, ret);
return ret;
}

View File

@ -28,7 +28,7 @@
int32_t OnPeerMsgReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t len)
{
if (devId == NULL || msg == NULL || len == 0) {
SECURITY_LOG_ERROR("OnPeerMsgReceived params is NULL, len = %{public}u", len);
SECURITY_LOG_ERROR("invalid params, len = %{public}u", len);
return ERR_INVALID_PARA;
}
@ -36,12 +36,12 @@ int32_t OnPeerMsgReceived(const DeviceIdentify *devId, const uint8_t *msg, uint3
int32_t ret = SUCCESS;
MessagePacket *packet = ParseMessage(&buff);
if (packet == NULL) {
SECURITY_LOG_ERROR("OnPeerMsgReceived packet is NULL");
SECURITY_LOG_ERROR("packet is null");
return ERR_INVALID_PARA;
}
if (packet->payload == NULL) {
FreeMessagePacket(packet);
SECURITY_LOG_ERROR("OnPeerMsgReceived packet->payload is NULL");
SECURITY_LOG_ERROR("packet->payload is null");
return ERR_INVALID_PARA;
}
@ -56,7 +56,7 @@ int32_t OnPeerMsgReceived(const DeviceIdentify *devId, const uint8_t *msg, uint3
break;
}
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("OnPeerMsgReceived ret = %{public}d, packet->type = %{public}u", ret, packet->type);
SECURITY_LOG_ERROR("ret = %{public}d, packet->type = %{public}u", ret, packet->type);
}
FreeMessagePacket(packet);
return ret;
@ -72,7 +72,7 @@ uint32_t InitService(void)
uint32_t times = 0;
uint32_t ret = InitMessenger(OnPeerMsgReceived, OnPeerStatusReceiver, OnSendResultNotifier);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("InitService InitMessenger ret = %{public}u", ret);
SECURITY_LOG_ERROR("InitMessenger ret = %{public}u", ret);
return ret;
}

View File

@ -42,13 +42,13 @@ static void ProcessCallback(uint32_t owner, uint32_t cookie, uint32_t result, co
}
auto object = Singleton<DslmIpcProcess::RemoteHolder>::GetInstance().Pop(owner, cookie);
if (object == nullptr) {
SECURITY_LOG_ERROR("ProcessCallback Pop error.");
SECURITY_LOG_ERROR("Pop failed");
return;
}
auto proxy = iface_cast<DslmCallbackProxy>(object);
if (object == nullptr) {
SECURITY_LOG_ERROR("ProcessCallback iface_cast error.");
SECURITY_LOG_ERROR("iface_cast failed");
return;
}
DslmCallbackProxy::ResponseInfo resInfo = {result, info->level, info->extraBuff, info->extraLen};
@ -69,7 +69,7 @@ int32_t DslmIpcProcess::DslmGetRequestFromParcel(MessageParcel &data, DeviceIden
uint32_t expected = sizeof(DeviceIdentify) + sizeof(RequestOption) + sizeof(uint32_t);
uint32_t actual = data.GetReadableBytes();
if (expected >= actual) {
SECURITY_LOG_ERROR("DslmGetRequestFromParcel unexpected input, length error");
SECURITY_LOG_ERROR("unexpected input, length error");
return ERR_INVALID_PARA;
}
@ -77,11 +77,11 @@ int32_t DslmIpcProcess::DslmGetRequestFromParcel(MessageParcel &data, DeviceIden
const uint8_t *dataRead = data.ReadBuffer(DEVICE_ID_MAX_LEN);
if (dataRead == nullptr) {
SECURITY_LOG_ERROR("DslmGetRequestFromParcel unexpected input, buffer error");
SECURITY_LOG_ERROR("unexpected input, buffer error");
return ERR_INVALID_PARA;
}
if (memcpy_s(identify.identity, DEVICE_ID_MAX_LEN, dataRead, DEVICE_ID_MAX_LEN) != EOK) {
SECURITY_LOG_ERROR("DslmGetRequestFromParcel unexpected input, buffer copy error");
SECURITY_LOG_ERROR("unexpected input, buffer copy error");
return ERR_INVALID_PARA;
}
@ -95,12 +95,12 @@ int32_t DslmIpcProcess::DslmGetRequestFromParcel(MessageParcel &data, DeviceIden
object = data.ReadRemoteObject();
if (object == nullptr) {
SECURITY_LOG_ERROR("DslmGetRequestFromParcel unexpected input, callback ipc error");
SECURITY_LOG_ERROR("unexpected input, callback ipc error");
return ERR_INVALID_PARA;
}
cookie = data.ReadUint32();
if (cookie == 0) {
SECURITY_LOG_ERROR("DslmGetRequestFromParcel unexpected input, cookie error");
SECURITY_LOG_ERROR("unexpected input, cookie error");
return ERR_INVALID_PARA;
}
@ -125,7 +125,7 @@ int32_t DslmIpcProcess::DslmProcessGetDeviceSecurityLevel(MessageParcel &data, M
int32_t ret = DslmGetRequestFromParcel(data, identity, option, callback, cookie);
if (ret != SUCCESS) {
SECURITY_LOG_ERROR("ProcessGetDeviceSecurityLevel DslmGetRequestFromParcel failed, ret = %{public}d", ret);
SECURITY_LOG_ERROR("DslmGetRequestFromParcel failed, ret = %{public}d", ret);
return ret;
}
@ -135,14 +135,14 @@ int32_t DslmIpcProcess::DslmProcessGetDeviceSecurityLevel(MessageParcel &data, M
ret = OnRequestDeviceSecLevelInfo(&identity, &option, owner, cookie, ProcessCallback);
if (ret != SUCCESS) {
Singleton<RemoteHolder>::GetInstance().Pop(owner, cookie);
SECURITY_LOG_ERROR("ProcessGetDeviceSecurityLevel OnRequestDeviceSecLevelInfo failed, ret = %{public}d", ret);
SECURITY_LOG_ERROR("OnRequestDeviceSecLevelInfo failed, ret = %{public}d", ret);
return ret;
}
ret = DslmSetResponseToParcel(reply, cookie);
if (ret != SUCCESS) {
Singleton<RemoteHolder>::GetInstance().Pop(owner, cookie);
SECURITY_LOG_ERROR("ProcessGetDeviceSecurityLevel DslmSetResponseToParcel failed, ret = %{public}d", ret);
SECURITY_LOG_ERROR("DslmSetResponseToParcel failed, ret = %{public}d", ret);
return ret;
}
return SUCCESS;
@ -162,7 +162,7 @@ bool DslmIpcProcess::RemoteHolder::Push(uint32_t owner, uint32_t cookie, const s
uint64_t key = (static_cast<uint64_t>(owner) << COOKIE_SHIFT) | cookie;
map_[key] = object;
if (map_.size() > WARNING_GATE) {
SECURITY_LOG_WARN("DslmIpcProcess remote objects max warning");
SECURITY_LOG_WARN("remote objects max warning");
}
return true;
}

View File

@ -30,19 +30,19 @@ REGISTER_SYSTEM_ABILITY_BY_ID(DslmService, DEVICE_SECURITY_LEVEL_MANAGER_SA_ID,
DslmService::DslmService(int32_t saId, bool runOnCreate) : SystemAbility(saId, runOnCreate)
{
SECURITY_LOG_INFO("DslmService::DslmService");
SECURITY_LOG_INFO("object initialization");
}
void DslmService::OnStart()
{
SECURITY_LOG_INFO("DslmService::OnStart service");
SECURITY_LOG_INFO("start");
if (!Publish(this)) {
SECURITY_LOG_ERROR("DslmService::OnStart Publish service failed.");
SECURITY_LOG_ERROR("publish service failed");
}
std::thread t([this]() {
if (InitService() == SUCCESS) {
SECURITY_LOG_INFO("DslmService::OnStart InitService success.");
SECURITY_LOG_INFO("init service success");
return;
}
});
@ -52,7 +52,7 @@ void DslmService::OnStart()
void DslmService::OnStop()
{
UnInitService();
SECURITY_LOG_INFO("DslmService::OnStop service stop.");
SECURITY_LOG_INFO("stop service");
}
int32_t DslmService::Dump(int fd, const std::vector<std::u16string> &args)