Skip to content

Commit

Permalink
fix(PeriphDrivers): MXC_SYS_GetUSN Checksum error (analogdevicesinc#1050
Browse files Browse the repository at this point in the history
)
  • Loading branch information
EricB-ADI authored Jun 24, 2024
1 parent 74a552e commit a8938a5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ void palCfgLoadLlParams(uint8_t *pConfig)
/*************************************************************************************************/
void palCfgLoadBdAddress(uint8_t *pDevAddr)
{
uint8_t id[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t id[MXC_SYS_USN_LEN] = {0};
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN] = {0};

if(MXC_SYS_GetUSN((uint8_t*)id, (uint8_t*)checksum) != E_NO_ERROR) {
PalSysAssertTrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ void palCfgLoadLlParams(uint8_t *pConfig)
/*************************************************************************************************/
void palCfgLoadBdAddress(uint8_t *pDevAddr)
{
uint8_t id[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t id[MXC_SYS_USN_LEN] = {0};
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN] = {0};

if(MXC_SYS_GetUSN(id, checksum) != E_NO_ERROR) {
PalSysAssertTrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ void palCfgLoadLlParams(uint8_t *pConfig)
/*************************************************************************************************/
void palCfgLoadBdAddress(uint8_t *pDevAddr)
{
uint8_t id[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN];
uint8_t id[MXC_SYS_USN_LEN] = {0};
uint8_t checksum[MXC_SYS_USN_CHECKSUM_LEN] = {0};

if(MXC_SYS_GetUSN((uint8_t*)id, (uint8_t*)checksum) != E_NO_ERROR) {
PalSysAssertTrap();
Expand Down
4 changes: 3 additions & 1 deletion Libraries/PeriphDrivers/Source/SYS/sys_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
// Set NULL Key
MXC_AES_SetExtKey((const void *)aes_key, MXC_AES_128BITS);

uint8_t usn_copy[MXC_SYS_USN_LEN] = { 0 };
memcpy(usn_copy, usn, MXC_SYS_USN_LEN);
// Compute Checksum
mxc_aes_req_t aes_req;
aes_req.length = MXC_SYS_USN_CHECKSUM_LEN / 4;
aes_req.inputData = (uint32_t *)usn;
aes_req.inputData = (uint32_t *)usn_copy;
aes_req.resultData = (uint32_t *)check_csum;
aes_req.keySize = MXC_AES_128BITS;
aes_req.encryption = MXC_AES_ENCRYPT_EXT_KEY;
Expand Down
5 changes: 4 additions & 1 deletion Libraries/PeriphDrivers/Source/SYS/sys_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
// Set NULL Key
MXC_AES_SetExtKey((const void *)aes_key, MXC_AES_128BITS);

uint8_t usn_copy[MXC_SYS_USN_LEN] = { 0 };
memcpy(usn_copy, usn, MXC_SYS_USN_LEN);

// Compute Checksum
mxc_aes_req_t aes_req;
aes_req.length = MXC_SYS_USN_CHECKSUM_LEN / 4;
aes_req.inputData = (uint32_t *)usn;
aes_req.inputData = (uint32_t *)usn_copy;
aes_req.resultData = (uint32_t *)check_csum;
aes_req.keySize = MXC_AES_128BITS;
aes_req.encryption = MXC_AES_ENCRYPT_EXT_KEY;
Expand Down
5 changes: 4 additions & 1 deletion Libraries/PeriphDrivers/Source/SYS/sys_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
// Set NULL Key
MXC_AES_SetExtKey((const void *)aes_key, MXC_AES_128BITS);

uint8_t usn_copy[MXC_SYS_USN_LEN] = { 0 };
memcpy(usn_copy, usn, MXC_SYS_USN_LEN);

// Compute Checksum
mxc_aes_req_t aes_req;
aes_req.length = MXC_SYS_USN_CHECKSUM_LEN / 4;
aes_req.inputData = (uint32_t *)usn;
aes_req.inputData = (uint32_t *)usn_copy;
aes_req.resultData = (uint32_t *)check_csum;
aes_req.keySize = MXC_AES_128BITS;
aes_req.encryption = MXC_AES_ENCRYPT_EXT_KEY;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/PeriphDrivers/Source/SYS/sys_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
/* Initialize key and plaintext */
memset(key, 0, MXC_SYS_USN_CHECKSUM_LEN);
memset(pt32, 0, MXC_SYS_USN_CHECKSUM_LEN);
memcpy(pt32, usn, MXC_SYS_USN_CHECKSUM_LEN);
memcpy(pt32, usn, MXC_SYS_USN_LEN);

/* Read the checksum from the info block */
/* Read the checksum from the inspfo block */
checksum[1] = ((infoblock[3] & 0x7F800000) >> 23);
checksum[0] = ((infoblock[4] & 0x007F8000) >> 15);

Expand Down
5 changes: 4 additions & 1 deletion Libraries/PeriphDrivers/Source/SYS/sys_me21.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
// Set NULL Key
MXC_AES_SetExtKey((const void *)aes_key, MXC_AES_128BITS);

uint8_t usn_copy[MXC_SYS_USN_LEN] = { 0 };
memcpy(usn_copy, usn, MXC_SYS_USN_LEN);

// Compute Checksum
mxc_aes_req_t aes_req;
aes_req.length = MXC_SYS_USN_CHECKSUM_LEN / 4;
aes_req.inputData = (uint32_t *)usn;
aes_req.inputData = (uint32_t *)usn_copy;
aes_req.resultData = (uint32_t *)check_csum;
aes_req.keySize = MXC_AES_128BITS;
aes_req.encryption = MXC_AES_ENCRYPT_EXT_KEY;
Expand Down

0 comments on commit a8938a5

Please sign in to comment.