Skip to content

Commit 568c1f9

Browse files
committed
Port Cordio LE Secure Connections check from PacketCraft
This change is provided by Packetcraft (which maintains the Cordio BLE stack) to address possible Sweyntooth vulnerabilities. (cherry picked from commit c927773)
1 parent 421becc commit 568c1f9

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/include/smp_api.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2009-2019 Arm Limited
2+
* Copyright (c) 2019-2020 Packetcraft, Inc.
23
* SPDX-License-Identifier: Apache-2.0
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -252,6 +253,17 @@ void SmpDmMsgSend(smpDmMsg_t *pMsg);
252253
/*************************************************************************************************/
253254
void SmpDmEncryptInd(wsfMsgHdr_t *pMsg);
254255

256+
/*************************************************************************************************/
257+
/*!
258+
* \brief Check if LE Secure Connections is enabled on the connection.
259+
*
260+
* \param connId Connection identifier.
261+
*
262+
* \return TRUE is Secure Connections is enabled, else FALSE
263+
*/
264+
/*************************************************************************************************/
265+
bool_t SmpDmLescEnabled(dmConnId_t connId);
266+
255267
/*************************************************************************************************/
256268
/*!
257269
* \brief Return the STK for the given connection.

features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_sec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2009-2019 Arm Limited
2+
* Copyright (c) 2019-2020 Packetcraft, Inc.
23
* SPDX-License-Identifier: Apache-2.0
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -117,6 +118,12 @@ void dmSecHciHandler(hciEvt_t *pEvent)
117118
return;
118119
}
119120
}
121+
else if (SmpDmLescEnabled(pCcb->connId) == TRUE)
122+
{
123+
/* EDIV and Rand must be zero in LE Secure Connections */
124+
HciLeLtkReqNegReplCmd(pEvent->hdr.param);
125+
return;
126+
}
120127

121128
/* call callback to get key from app */
122129

features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/smp/smp_main.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,27 @@ uint8_t smpGetScSecLevel(smpCcb_t *pCcb)
695695
return secLevel;
696696
}
697697

698+
/*************************************************************************************************/
699+
/*!
700+
* \brief Check if LE Secure Connections is enabled on the connection.
701+
*
702+
* \param connId Connection identifier.
703+
*
704+
* \return TRUE is Secure Connections is enabled, else FALSE
705+
*/
706+
/*************************************************************************************************/
707+
bool_t SmpDmLescEnabled(dmConnId_t connId)
708+
{
709+
smpCcb_t *pCcb = smpCcbByConnId(connId);
710+
711+
if (pCcb == NULL || pCcb->pScCcb == NULL)
712+
{
713+
return FALSE;
714+
}
715+
716+
return pCcb->pScCcb->lescEnabled;
717+
}
718+
698719
/*************************************************************************************************/
699720
/*!
700721
* \brief Return the STK for the given connection.

0 commit comments

Comments
 (0)