Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99f458d6 authored by Chris Manton's avatar Chris Manton
Browse files

Test and reduce obfuscation stack::btm::BTM_LE_SEC_

Bug: 256040207
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I6e9e9d4d6983bf80618ce7af5c7ad565b9248fa6
parent 80150f5d
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include "stack/include/l2cap_security_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/smp_api.h"
#include "stack/include/smp_api_types.h"
#include "types/raw_address.h"

extern tBTM_CB btm_cb;
@@ -1274,7 +1275,7 @@ void btm_ble_link_sec_check(const RawAddress& bd_addr,
                            tBTM_LE_AUTH_REQ auth_req,
                            tBTM_BLE_SEC_REQ_ACT* p_sec_req_act) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  uint8_t req_sec_level = BTM_LE_SEC_NONE, cur_sec_level = BTM_LE_SEC_NONE;
  uint8_t req_sec_level = SMP_SEC_NONE, cur_sec_level = SMP_SEC_NONE;

  BTM_TRACE_DEBUG("btm_ble_link_sec_check auth_req =0x%x", auth_req);

@@ -1289,9 +1290,9 @@ void btm_ble_link_sec_check(const RawAddress& bd_addr,
     * the link */
    *p_sec_req_act = BTM_BLE_SEC_REQ_ACT_DISCARD;
  } else {
    req_sec_level = BTM_LE_SEC_UNAUTHENTICATE;
    req_sec_level = SMP_SEC_UNAUTHENTICATE;
    if (auth_req & BTM_LE_AUTH_REQ_MITM) {
      req_sec_level = BTM_LE_SEC_AUTHENTICATED;
      req_sec_level = SMP_SEC_AUTHENTICATED;
    }

    BTM_TRACE_DEBUG("dev_rec sec_flags=0x%x", p_dev_rec->sec_flags);
@@ -1299,16 +1300,16 @@ void btm_ble_link_sec_check(const RawAddress& bd_addr,
    /* currently encrpted  */
    if (p_dev_rec->sec_flags & BTM_SEC_LE_ENCRYPTED) {
      if (p_dev_rec->sec_flags & BTM_SEC_LE_AUTHENTICATED)
        cur_sec_level = BTM_LE_SEC_AUTHENTICATED;
        cur_sec_level = SMP_SEC_AUTHENTICATED;
      else
        cur_sec_level = BTM_LE_SEC_UNAUTHENTICATE;
        cur_sec_level = SMP_SEC_UNAUTHENTICATE;
    } else /* unencrypted link */
    {
      /* if bonded, get the key security level */
      if (p_dev_rec->ble.key_type & BTM_LE_KEY_PENC)
        cur_sec_level = p_dev_rec->ble.keys.sec_level;
      else
        cur_sec_level = BTM_LE_SEC_NONE;
        cur_sec_level = SMP_SEC_NONE;
    }

    if (cur_sec_level >= req_sec_level) {
+0 −6
Original line number Diff line number Diff line
@@ -639,12 +639,6 @@ typedef uint8_t tBTM_LE_AUTH_REQ;
#define BTM_LE_AUTH_REQ_SC_MITM_BOND SMP_AUTH_SC_MITM_GB /* 00101101 */
#define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK               /* 0x3D */

/* LE security level */
#define BTM_LE_SEC_NONE SMP_SEC_NONE
#define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE /* 1 */
#define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED   /* 4 */
typedef uint8_t tBTM_LE_SEC;

typedef struct {
  /* local IO capabilities */
  tBTM_IO_CAP io_cap;