From 1ad7162f064fd1831c3e0e8b815eb753fdf43f3d Mon Sep 17 00:00:00 2001 From: Zhenghuan Zhang Date: Fri, 10 Jan 2025 11:40:42 +0800 Subject: [PATCH] riscv: telink: fix error format Signed-off-by: Zhenghuan Zhang --- src/platform/telink/FactoryDataParser.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platform/telink/FactoryDataParser.c b/src/platform/telink/FactoryDataParser.c index 2f3cb564f23ca1..27f714cffa4f65 100644 --- a/src/platform/telink/FactoryDataParser.c +++ b/src/platform/telink/FactoryDataParser.c @@ -205,7 +205,8 @@ bool LoadDACCertAndKey(uint8_t * buffer, struct FactoryData * factoryData) { size_t dac_priv_key_len; uint8_t chip_id[16] = { 0 }; - dac_priv_key_len = buffer[0]; + bool chip_id_check_result; + dac_priv_key_len = buffer[0]; dac_priv_key_len |= (uint16_t) buffer[1] << 8; factoryData->dac_priv_key.len = dac_priv_key_len; if (!factoryData->dac_priv_key.len) @@ -214,11 +215,12 @@ bool LoadDACCertAndKey(uint8_t * buffer, struct FactoryData * factoryData) } #ifdef CONFIG_SOC_RISCV_TELINK_B92 - if (efuse_get_chip_id(chip_id)) + chip_id_check_result = efuse_get_chip_id(chip_id) ? true : false; #endif #ifdef CONFIG_SOC_RISCV_TELINK_TL321X - if (efuse_get_chip_id(chip_id) == DRV_API_SUCCESS) + chip_id_check_result = efuse_get_chip_id(chip_id) ? false : true; #endif + if (chip_id_check_result) { #ifdef CONFIG_SOC_RISCV_TELINK_B92 aes_decrypt(chip_id, buffer + 2, dac_key_decrypt); @@ -228,8 +230,7 @@ bool LoadDACCertAndKey(uint8_t * buffer, struct FactoryData * factoryData) ske_dig_en(); uint32_t r = core_interrupt_disable(); ske_lp_crypto(SKE_ALG_AES_128, SKE_MODE_ECB, SKE_CRYPTO_DECRYPT, chip_id, 0, NULL, buffer + 2, dac_key_decrypt, 16); - ske_lp_crypto(SKE_ALG_AES_128, SKE_MODE_ECB, SKE_CRYPTO_DECRYPT, chip_id, 0, NULL, buffer + 18, dac_key_decrypt + 16, - 16); + ske_lp_crypto(SKE_ALG_AES_128, SKE_MODE_ECB, SKE_CRYPTO_DECRYPT, chip_id, 0, NULL, buffer + 18, dac_key_decrypt + 16, 16); core_restore_interrupt(r); #endif factoryData->dac_priv_key.data = dac_key_decrypt;