Skip to content

Commit

Permalink
Port Cordio LE Secure Connections check from PacketCraft
Browse files Browse the repository at this point in the history
This change is provided by Packetcraft (which maintains the
Cordio BLE stack) to address possible Sweyntooth vulnerabilities.
  • Loading branch information
LDong-Arm committed Apr 9, 2020
1 parent 0402fe4 commit c927773
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (c) 2009-2019 Arm Limited
* Copyright (c) 2019-2020 Packetcraft, Inc.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -252,6 +253,17 @@ void SmpDmMsgSend(smpDmMsg_t *pMsg);
/*************************************************************************************************/
void SmpDmEncryptInd(wsfMsgHdr_t *pMsg);

/*************************************************************************************************/
/*!
* \brief Check if LE Secure Connections is enabled on the connection.
*
* \param connId Connection identifier.
*
* \return TRUE is Secure Connections is enabled, else FALSE
*/
/*************************************************************************************************/
bool_t SmpDmLescEnabled(dmConnId_t connId);

/*************************************************************************************************/
/*!
* \brief Return the STK for the given connection.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (c) 2009-2019 Arm Limited
* Copyright (c) 2019-2020 Packetcraft, Inc.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -117,6 +118,12 @@ void dmSecHciHandler(hciEvt_t *pEvent)
return;
}
}
else if (SmpDmLescEnabled(pCcb->connId) == TRUE)
{
/* EDIV and Rand must be zero in LE Secure Connections */
HciLeLtkReqNegReplCmd(pEvent->hdr.param);
return;
}

/* call callback to get key from app */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,27 @@ uint8_t smpGetScSecLevel(smpCcb_t *pCcb)
return secLevel;
}

/*************************************************************************************************/
/*!
* \brief Check if LE Secure Connections is enabled on the connection.
*
* \param connId Connection identifier.
*
* \return TRUE is Secure Connections is enabled, else FALSE
*/
/*************************************************************************************************/
bool_t SmpDmLescEnabled(dmConnId_t connId)
{
smpCcb_t *pCcb = smpCcbByConnId(connId);

if (pCcb == NULL || pCcb->pScCcb == NULL)
{
return FALSE;
}

return pCcb->pScCcb->lescEnabled;
}

/*************************************************************************************************/
/*!
* \brief Return the STK for the given connection.
Expand Down

0 comments on commit c927773

Please sign in to comment.