!8071 bug fix: add get AesCtrCipherKey iv func

Merge pull request !8071 from ym/master
This commit is contained in:
openharmony_ci 2024-10-19 10:53:05 +00:00 committed by Gitee
commit 1d4a12cbe0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 34 additions and 4 deletions

View File

@ -70,6 +70,8 @@ bool JSON_AddBytesToObject(JsonObj *obj, const char *key, uint8_t *value, uint32
bool JSON_GetBytesFromObject(const JsonObj *obj, const char *key, uint8_t *value, uint32_t bufLen, uint32_t *size);
bool JSON_IsArrayExist(const JsonObj *obj, const char *key);
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -371,3 +371,22 @@ bool JSON_GetBytesFromObject(const JsonObj *obj, const char *key, uint8_t *value
*size = bytes.size();
return true;
}
bool JSON_IsArrayExist(const JsonObj *obj, const char *key)
{
if (obj == nullptr || key == nullptr) {
COMM_LOGE(COMM_ADAPTER, "input invalid");
return false;
}
nlohmann::json *json = reinterpret_cast<nlohmann::json *>(obj->context);
if (json == nullptr) {
COMM_LOGE(COMM_ADAPTER, "invaild json param");
return false;
}
if (!json->contains(key)) {
COMM_LOGW(COMM_ADAPTER, "key does not exist");
return false;
}
nlohmann::json item = (*json)[key];
return item.is_array();
}

View File

@ -35,9 +35,9 @@ typedef struct {
int32_t LnnInitCipherKeyManager(void);
void LnnDeinitCipherKeyManager(void);
bool GetCipherKeyByNetworkId(const char *networkId, int32_t seq, uint32_t tableIndex, unsigned char *key,
bool GetCipherKeyByNetworkId(const char *networkId, int32_t seq, uint32_t tableIndex, AesCtrCipherKey *cipherkey,
int32_t keyLen);
bool GetLocalCipherKey(int32_t seq, uint32_t *tableIndex, unsigned char *key, int32_t keyLen);
bool GetLocalCipherKey(int32_t seq, uint32_t *tableIndex, AesCtrCipherKey *cipherkey, int32_t keyLen);
void LoadBleBroadcastKey(void);
bool IsCipherManagerFindKey(const char *udid);
bool PackCipherKeySyncMsg(void *json);

View File

@ -29,14 +29,23 @@ void LnnDeinitCipherKeyManager(void)
LNN_LOGI(LNN_INIT, "Deinit virtual lnn cipherkey manager");
}
bool GetCipherKeyByNetworkId(const char *networkId, int32_t seq, uint32_t tableIndex, unsigned char *key,
bool GetCipherKeyByNetworkId(const char *networkId, int32_t seq, uint32_t tableIndex, AesCtrCipherKey *cipherkey,
int32_t keyLen)
{
(void)networkId;
(void)seq;
(void)tableIndex;
(void)cipherkey;
(void)keyLen;
return true;
}
bool GetLocalCipherKey(int32_t seq, uint32_t *tableIndex, unsigned char *key, int32_t keyLen)
bool GetLocalCipherKey(int32_t seq, uint32_t *tableIndex, AesCtrCipherKey *cipherkey, int32_t keyLen)
{
(void)seq;
(void)tableIndex;
(void)cipherkey;
(void)keyLen;
return true;
}