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

Commit 8ee921fb authored by johnshamoon's avatar johnshamoon Committed by John Shamoon
Browse files

smp: Fix long SMP_Trace_* log messages

Test: Manually pair two devices
Change-Id: Iebf43688220922563c0e1028d9e75a4cae2fc1bd
parent 8766c00c
Loading
Loading
Loading
Loading
+38 −42
Original line number Diff line number Diff line
@@ -154,8 +154,8 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
          }

          SMP_TRACE_WARNING(
              "rcvd auth_req: 0x%02x, io_cap: %d \
                        loc_oob_flag: %d loc_enc_size: %d,"
              "rcvd auth_req: 0x%02x, io_cap: %d "
              "loc_oob_flag: %d loc_enc_size: %d, "
              "local_i_key: 0x%02x, local_r_key: 0x%02x",
              p_cb->loc_auth_req, p_cb->local_io_capability, p_cb->loc_oob_flag,
              p_cb->loc_enc_size, p_cb->local_i_key, p_cb->local_r_key);
@@ -193,8 +193,8 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
          p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK;

          SMP_TRACE_WARNING(
              "for SMP over BR max_key_size: 0x%02x,\
                        local_i_key: 0x%02x, local_r_key: 0x%02x, p_cb->loc_auth_req: 0x%02x",
              "for SMP over BR max_key_size: 0x%02x, local_i_key: 0x%02x, "
              "local_r_key: 0x%02x, p_cb->loc_auth_req: 0x%02x",
              p_cb->loc_enc_size, p_cb->local_i_key, p_cb->local_r_key,
              p_cb->loc_auth_req);

@@ -209,7 +209,7 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
    smp_sm_event(p_cb, SMP_DISCARD_SEC_REQ_EVT, NULL);
  }

  SMP_TRACE_DEBUG("%s return", __func__);
  SMP_TRACE_DEBUG("%s: return", __func__);
}

/*******************************************************************************
@@ -220,7 +220,7 @@ void smp_send_pair_fail(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  p_cb->status = *(uint8_t*)p_data;
  p_cb->failure = *(uint8_t*)p_data;

  SMP_TRACE_DEBUG("%s status=%d failure=%d ", __func__, p_cb->status,
  SMP_TRACE_DEBUG("%s: status=%d failure=%d ", __func__, p_cb->status,
                  p_cb->failure);

  if (p_cb->status <= SMP_MAX_FAIL_RSN_PER_SPEC &&
@@ -333,7 +333,7 @@ void smp_send_keypress_notification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
void smp_send_enc_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  tBTM_LE_LENC_KEYS le_key;

  SMP_TRACE_DEBUG("%s p_cb->loc_enc_size = %d", __func__, p_cb->loc_enc_size);
  SMP_TRACE_DEBUG("%s: p_cb->loc_enc_size = %d", __func__, p_cb->loc_enc_size);
  smp_update_key_mask(p_cb, SMP_SEC_KEY_TYPE_ENC, false);

  smp_send_cmd(SMP_OPCODE_ENCRYPT_INFO, p_cb);
@@ -415,17 +415,17 @@ void smp_proc_sec_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  tBTM_BLE_SEC_REQ_ACT sec_req_act;
  uint8_t reason;

  SMP_TRACE_DEBUG("%s auth_req=0x%x", __func__, auth_req);
  SMP_TRACE_DEBUG("%s: auth_req=0x%x", __func__, auth_req);

  p_cb->cb_evt = 0;

  btm_ble_link_sec_check(p_cb->pairing_bda, auth_req, &sec_req_act);

  SMP_TRACE_DEBUG("%s sec_req_act=0x%x", __func__, sec_req_act);
  SMP_TRACE_DEBUG("%s: sec_req_act=0x%x", __func__, sec_req_act);

  switch (sec_req_act) {
    case BTM_BLE_SEC_REQ_ACT_ENCRYPT:
      SMP_TRACE_DEBUG("%s BTM_BLE_SEC_REQ_ACT_ENCRYPT", __func__);
      SMP_TRACE_DEBUG("%s: BTM_BLE_SEC_REQ_ACT_ENCRYPT", __func__);
      smp_sm_event(p_cb, SMP_ENC_REQ_EVT, NULL);
      break;

@@ -535,7 +535,7 @@ void smp_proc_pair_cmd(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
           (p_cb->selected_association_model ==
            SMP_MODEL_SEC_CONN_JUSTWORKS))) {
        SMP_TRACE_ERROR(
            "%s pairing failed - slave requires secure connection only mode",
            "%s: pairing failed - slave requires secure connection only mode",
            __func__);
        reason = SMP_PAIR_AUTH_FAIL;
        smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
@@ -556,8 +556,8 @@ void smp_proc_pair_cmd(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
        (!(p_cb->le_secure_connections_mode_is_used) ||
         (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS))) {
      SMP_TRACE_ERROR(
          "Master requires secure connection only mode \
                but it can't be provided -> Master fails pairing");
          "Master requires secure connection only mode "
          "but it can't be provided -> Master fails pairing");
      reason = SMP_PAIR_AUTH_FAIL;
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      return;
@@ -772,8 +772,8 @@ void smp_br_process_pairing_command(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
    p_dev_rec->new_encryption_key_is_p256 = false;
    /* shortcut to skip Security Grant step */
    p_cb->cb_evt = SMP_BR_KEYS_REQ_EVT;
  } else /* Master receives pairing response */
  {
  } else {
    /* Master receives pairing response */
    SMP_TRACE_DEBUG(
        "%s master rcvs valid PAIRING RESPONSE."
        " Supposed to move to key distribution phase. ",
@@ -795,9 +795,8 @@ void smp_br_process_security_grant(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  SMP_TRACE_DEBUG("%s", __func__);
  if (res != SMP_SUCCESS) {
    smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, p_data);
  } else /*otherwise, start pairing */
  {
    /* send IO request callback */
  } else {
    /* otherwise, start pairing; send IO request callback */
    p_cb->cb_evt = SMP_BR_KEYS_REQ_EVT;
  }
}
@@ -810,9 +809,7 @@ void smp_br_process_security_grant(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
void smp_br_check_authorization_request(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  uint8_t reason = SMP_SUCCESS;

  SMP_TRACE_DEBUG(
      "%s rcvs i_keys=0x%x r_keys=0x%x "
      "(i-initiator r-responder)",
  SMP_TRACE_DEBUG("%s rcvs i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
                  __func__, p_cb->local_i_key, p_cb->local_r_key);

  /* In LE SC mode LK field is ignored when BR/EDR transport is used */
@@ -833,8 +830,7 @@ void smp_br_check_authorization_request(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  SMP_TRACE_DEBUG("%s: use h7 = %d", __func__, p_cb->key_derivation_h7_used);

  SMP_TRACE_DEBUG(
      "%s rcvs upgrades: i_keys=0x%x r_keys=0x%x "
      "(i-initiator r-responder)",
      "%s rcvs upgrades: i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
      __func__, p_cb->local_i_key, p_cb->local_r_key);

  if (/*((p_cb->peer_auth_req & SMP_AUTH_BOND) ||
@@ -967,9 +963,12 @@ void smp_proc_srk_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {

  /* save CSRK to security record */
  le_key.sec_level = p_cb->sec_level;
  maybe_non_aligned_memcpy(le_key.csrk, p_data,
                           BT_OCTET16_LEN);    /* get peer CSRK */
  le_key.counter = 0;                          /* initialize the peer counter */

  /* get peer CSRK */
  maybe_non_aligned_memcpy(le_key.csrk, p_data, BT_OCTET16_LEN);

  /* initialize the peer counter */
  le_key.counter = 0;

  if ((p_cb->peer_auth_req & SMP_AUTH_BOND) &&
      (p_cb->loc_auth_req & SMP_AUTH_BOND))
@@ -1075,8 +1074,7 @@ void smp_check_auth_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  uint8_t reason = enc_enable ? SMP_SUCCESS : SMP_ENC_FAIL;

  SMP_TRACE_DEBUG(
      "%s rcvs enc_enable=%d i_keys=0x%x r_keys=0x%x "
      "(i-initiator r-responder)",
      "%s rcvs enc_enable=%d i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
      __func__, enc_enable, p_cb->local_i_key, p_cb->local_r_key);
  if (enc_enable == 1) {
    if (p_cb->le_secure_connections_mode_is_used) {
@@ -1103,8 +1101,7 @@ void smp_check_auth_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
      p_cb->local_r_key &= ~SMP_SEC_KEY_TYPE_LK;
    }
    SMP_TRACE_DEBUG(
        "%s rcvs upgrades: i_keys=0x%x r_keys=0x%x "
        "(i-initiator r-responder)",
        "%s rcvs upgrades: i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
        __func__, p_cb->local_i_key, p_cb->local_r_key);

    if (/*((p_cb->peer_auth_req & SMP_AUTH_BOND) ||
@@ -1302,8 +1299,8 @@ void smp_process_io_response(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
        (!(p_cb->le_secure_connections_mode_is_used) ||
         (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS))) {
      SMP_TRACE_ERROR(
          "Slave requires secure connection only mode \
                              but it can't be provided -> Slave fails pairing");
          "Slave requires secure connection only mode "
          "but it can't be provided -> Slave fails pairing");
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      return;
    }
@@ -1482,8 +1479,8 @@ void smp_process_local_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
          /* slave commitment is already received, send local nonce, wait for
           * remote nonce*/
          SMP_TRACE_DEBUG(
              "master in assoc mode = %d \
                    already rcvd slave commitment - race condition",
              "master in assoc mode = %d "
              "already rcvd slave commitment - race condition",
              p_cb->selected_association_model);
          p_cb->flags &= ~SMP_PAIR_FLAG_HAVE_PEER_COMM;
          smp_send_rand(p_cb, NULL);
@@ -1838,12 +1835,11 @@ void smp_set_local_oob_random_commitment(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
void smp_link_encrypted(BD_ADDR bda, uint8_t encr_enable) {
  tSMP_CB* p_cb = &smp_cb;

  SMP_TRACE_DEBUG("%s encr_enable=%d", __func__, encr_enable);
  SMP_TRACE_DEBUG("%s: encr_enable=%d", __func__, encr_enable);

  if (memcmp(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN) == 0) {
    /* encryption completed with STK, remmeber the key size now, could be
    * overwite
    *  when key exchange happens                                        */
    /* encryption completed with STK, remember the key size now, could be
     * overwritten when key exchange happens                                 */
    if (p_cb->loc_enc_size != 0 && encr_enable) {
      /* update the link encryption key size if a SMP pairing just performed */
      btm_ble_update_sec_key_size(bda, p_cb->loc_enc_size);
@@ -1954,7 +1950,7 @@ void smp_derive_link_key_from_long_term_key(tSMP_CB* p_cb,
 *
 * Description      This function is called to process BR/EDR LK:
 *                  - to derive SMP LTK from BR/EDR LK;
*8                  - to save SMP LTK.
 *                  - to save SMP LTK.
 *
 * Returns          void
 *
@@ -1964,7 +1960,7 @@ void smp_br_process_link_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {

  SMP_TRACE_DEBUG("%s", __func__);
  if (!smp_calculate_long_term_key_from_link_key(p_cb)) {
    SMP_TRACE_ERROR("%s failed", __func__);
    SMP_TRACE_ERROR("%s: failed", __func__);
    smp_sm_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status);
    return;
  }
+4 −4
Original line number Diff line number Diff line
@@ -886,8 +886,8 @@ void smp_calculate_local_commitment(tSMP_CB* p_cb) {
    case SMP_MODEL_SEC_CONN_NUM_COMP:
      if (p_cb->role == HCI_ROLE_MASTER)
        SMP_TRACE_WARNING(
            "local commitment calc on master is not expected \
                                    for Just Works/Numeric Comparison models");
            "local commitment calc on master is not expected "
            "for Just Works/Numeric Comparison models");
      smp_calculate_f4(p_cb->loc_publ_key.x, p_cb->peer_publ_key.x, p_cb->rand,
                       0, p_cb->commitment);
      break;
@@ -933,8 +933,8 @@ void smp_calculate_peer_commitment(tSMP_CB* p_cb, BT_OCTET16 output_buf) {
    case SMP_MODEL_SEC_CONN_NUM_COMP:
      if (p_cb->role == HCI_ROLE_SLAVE)
        SMP_TRACE_WARNING(
            "peer commitment calc on slave is not expected \
                for Just Works/Numeric Comparison models");
            "peer commitment calc on slave is not expected "
            "for Just Works/Numeric Comparison models");
      smp_calculate_f4(p_cb->peer_publ_key.x, p_cb->loc_publ_key.x, p_cb->rrand,
                       0, output_buf);
      break;
+12 −12
Original line number Diff line number Diff line
@@ -995,8 +995,8 @@ bool smp_command_has_valid_fixed_length(tSMP_CB* p_cb) {

  if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code]) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with invalid length\
            0x%02x (per spec the length is 0x%02x).",
        "Rcvd from the peer cmd 0x%02x with invalid length "
        "0x%02x (per spec the length is 0x%02x).",
        cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]);
    return false;
  }
@@ -1030,24 +1030,24 @@ bool smp_pairing_request_response_parameters_are_valid(tSMP_CB* p_cb) {

  if (io_caps >= BTM_IO_CAP_MAX) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with IO Capabilty \
            value (0x%02x) out of range).",
        "Rcvd from the peer cmd 0x%02x with IO Capability "
        "value (0x%02x) out of range).",
        p_cb->rcvd_cmd_code, io_caps);
    return false;
  }

  if (!((oob_flag == SMP_OOB_NONE) || (oob_flag == SMP_OOB_PRESENT))) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with OOB data flag value \
            (0x%02x) out of range).",
        "Rcvd from the peer cmd 0x%02x with OOB data flag value "
        "(0x%02x) out of range).",
        p_cb->rcvd_cmd_code, oob_flag);
    return false;
  }

  if (!((bond_flag == SMP_AUTH_NO_BOND) || (bond_flag == SMP_AUTH_BOND))) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with Bonding_Flags value (0x%02x)\
                           out of range).",
        "Rcvd from the peer cmd 0x%02x with Bonding_Flags value (0x%02x) "
        "out of range).",
        p_cb->rcvd_cmd_code, bond_flag);
    return false;
  }
@@ -1055,8 +1055,8 @@ bool smp_pairing_request_response_parameters_are_valid(tSMP_CB* p_cb) {
  if ((enc_size < SMP_ENCR_KEY_SIZE_MIN) ||
      (enc_size > SMP_ENCR_KEY_SIZE_MAX)) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with Maximum Encryption \
            Key value (0x%02x) out of range).",
        "Rcvd from the peer cmd 0x%02x with Maximum Encryption "
        "Key value (0x%02x) out of range).",
        p_cb->rcvd_cmd_code, enc_size);
    return false;
  }
@@ -1080,8 +1080,8 @@ bool smp_pairing_keypress_notification_is_valid(tSMP_CB* p_cb) {

  if (keypress_notification >= BTM_SP_KEY_OUT_OF_RANGE) {
    SMP_TRACE_WARNING(
        "Rcvd from the peer cmd 0x%02x with Pairing Keypress \
            Notification value (0x%02x) out of range).",
        "Rcvd from the peer cmd 0x%02x with Pairing Keypress "
        "Notification value (0x%02x) out of range).",
        p_cb->rcvd_cmd_code, keypress_notification);
    return false;
  }