Cordio: Add API to set the local identity address.

pull/13759/head
Vincent Coubard 2020-09-10 17:12:44 +01:00
parent 9eac36879a
commit f897729d5c
4 changed files with 87 additions and 2 deletions

View File

@ -3035,6 +3035,18 @@ void DmSecSetLocalCsrk(uint8_t *pCsrk);
/*************************************************************************************************/
void DmSecSetLocalIrk(uint8_t *pIrk);
/*************************************************************************************************/
/*!
* \brief This function sets the local identity address used by the device.
*
* \param pAddr Pointer to the address.
* \param type Type of the address.
*
* \return None.
*/
/*************************************************************************************************/
void DmSecSetLocalIdentityAddr(const uint8_t *pAddr, uint8_t type);
/*************************************************************************************************/
/*!
* \brief This function generates an ECC key for use with LESC security.
@ -3345,6 +3357,25 @@ uint8_t *DmSecGetLocalCsrk(void);
/*************************************************************************************************/
uint8_t *DmSecGetLocalIrk(void);
/*************************************************************************************************/
/*!
* \brief For internal use only. This function gets the local identity address used by the device.
*
* \return Pointer to the identity address.
*/
/*************************************************************************************************/
uint8_t *DmSecGetLocalIdentityAddr(void);
/*************************************************************************************************/
/*!
* \brief For internal use only. This function gets the local identity address type used by the
* device.
*
* \return The identity address type.
*/
/*************************************************************************************************/
uint8_t DmSecGetLocalIdentityAddrType(void);
/*************************************************************************************************/
/*!
* \brief For internal use only. Read the features of the remote device.

View File

@ -329,6 +329,7 @@ void DmSecInit(void)
dmFcnIfTbl[DM_ID_SEC] = (dmFcnIf_t *) &dmSecFcnIf;
dmSecCb.pCsrk = dmSecCb.pIrk = (uint8_t *) calc128Zeros;
dmSecCb.addrType = DM_ADDR_NONE;
}
/*************************************************************************************************/
@ -363,6 +364,24 @@ void DmSecSetLocalIrk(uint8_t *pIrk)
WsfTaskUnlock();
}
/*************************************************************************************************/
/*!
* \brief This function sets the local identity address used by the device.
*
* \param pAddr Pointer to the address.
* \param type Type of the address.
*
* \return None.
*/
/*************************************************************************************************/
void DmSecSetLocalIdentityAddr(const uint8_t *pAddr, uint8_t type)
{
WsfTaskLock();
dmSecCb.addrType = type;
BdaCpy(dmSecCb.bdAddr, pAddr);
WsfTaskUnlock();
}
/*************************************************************************************************/
/*!
* \brief This function gets the local CSRK used by the device.
@ -387,6 +406,39 @@ uint8_t *DmSecGetLocalIrk(void)
return dmSecCb.pIrk;
}
/*************************************************************************************************/
/*!
* \brief For internal use only. This function gets the local identity address used by the device.
*
* \return Pointer to the identity address.
*/
/*************************************************************************************************/
uint8_t *DmSecGetLocalIdentityAddr(void)
{
if (dmSecCb.addrType != DM_ADDR_NONE) {
return dmSecCb.bdAddr;
} else {
return HciGetBdAddr();
}
}
/*************************************************************************************************/
/*!
* \brief For internal use only. This function gets the local identity address type used by the
* device.
*
* \return The identity address type.
*/
/*************************************************************************************************/
uint8_t DmSecGetLocalIdentityAddrType(void)
{
if (dmSecCb.addrType != DM_ADDR_NONE) {
return dmSecCb.addrType;
} else {
return DM_ADDR_PUBLIC;
}
}
/*************************************************************************************************/
/*!
* \brief Reset the sec module.

View File

@ -83,6 +83,8 @@ typedef struct
{
uint8_t *pIrk;
uint8_t *pCsrk;
bdAddr_t bdAddr;
uint8_t addrType;
} dmSecCb_t;
/**************************************************************************************************

View File

@ -567,8 +567,8 @@ bool_t smpSendKey(smpCcb_t *pCcb, uint8_t keyDist)
{
/* send second part of IRK */
UINT8_TO_BSTREAM(p, SMP_CMD_ID_ADDR_INFO);
UINT8_TO_BSTREAM(p, DM_ADDR_PUBLIC);
BDA_TO_BSTREAM(p, HciGetBdAddr());
UINT8_TO_BSTREAM(p, DmSecGetLocalIdentityAddrType());
BDA_TO_BSTREAM(p, DmSecGetLocalIdentityAddr());
}
else if ((keyDist & SMP_KEY_DIST_SIGN) &&