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

Commit fa2780db authored by ravishankar srivatsa's avatar ravishankar srivatsa Committed by Andre Eisenbach
Browse files

Add additional failure modes for SMP PTS test cases



SM/MAS/SCJW/BI-01-C [Just Works, IUT Initiator, Secure Connections -Pairing Failed
For Lower tester to handle step 15.
Lower Tester responds with a Pairing Failed command in phase 2 with reason code
0x0C (Numeric Comparison Failed).

Bug: 37707831
Change-Id: Ia7103330d1d1ecb06e39502c2a0976585b203ba5
Signed-off-by: default avatarRavishankar Srivatsa <Ravishankar.Srivatsa@intel.com>
Test: manual
parent 697db845
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -53,17 +53,17 @@ TRC_HID_DEV=2
#PTS_SmpOptions=0xD,0x4,0xf,0xf,0x10

# SMP Certification Failure Cases
# Fail case number range from 1 to 9 will set up remote device for test
# case execution. Setting PTS_SmpFailureCase to 0 means normal operation.
# Set any of the following SMP error values (from smp_api_types.h)
# to induce pairing failues for various PTS SMP test cases.
# Setting PTS_SmpFailureCase to 0 means normal operation.
# Failure modes:
#  1 = SMP_CONFIRM_VALUE_ERR
#  2 = SMP_PAIR_AUTH_FAIL
#  3 = SMP_PAIR_FAIL_UNKNOWN
#  4 = SMP_PAIR_NOT_SUPPORT
#  5 = SMP_PASSKEY_ENTRY_FAIL
#  6 = SMP_REPEATED_ATTEMPTS
#  7 = PIN generation failure?
#  8 = SMP_PASSKEY_ENTRY_FAIL
#  9 = SMP_NUMERIC_COMPAR_FAIL;
#
#  SMP_PASSKEY_ENTRY_FAIL = 1
#  SMP_PAIR_AUTH_FAIL = 3
#  SMP_CONFIRM_VALUE_ERR = 4
#  SMP_PAIR_NOT_SUPPORT = 5
#  SMP_PAIR_FAIL_UNKNOWN = 8
#  SMP_REPEATED_ATTEMPTS = 9
#  SMP_NUMERIC_COMPAR_FAIL = 12
#PTS_SmpFailureCase=0
+20 −32
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
extern fixed_queue_t* btu_general_alarm_queue;

#define SMP_KEY_DIST_TYPE_MAX 4

const tSMP_ACT smp_distribute_act[] = {smp_generate_ltk, smp_send_id_info,
                                       smp_generate_csrk,
                                       smp_set_derive_link_key};
@@ -44,37 +45,14 @@ static bool lmp_version_below(BD_ADDR bda, uint8_t version) {
}

static bool pts_test_send_authentication_complete_failure(tSMP_CB* p_cb) {
  uint8_t reason = 0;

  if (p_cb->cert_failure < 2 || p_cb->cert_failure > 6) return false;

  SMP_TRACE_ERROR("%s failure case = %d", __func__, p_cb->cert_failure);

  switch (p_cb->cert_failure) {
    case 2:
      reason = SMP_PAIR_AUTH_FAIL;
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      break;
    case 3:
      reason = SMP_PAIR_FAIL_UNKNOWN;
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      break;
    case 4:
      reason = SMP_PAIR_NOT_SUPPORT;
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      break;
    case 5:
      reason = SMP_PASSKEY_ENTRY_FAIL;
  uint8_t reason = p_cb->cert_failure;
  if (reason == SMP_PAIR_AUTH_FAIL || reason == SMP_PAIR_FAIL_UNKNOWN ||
      reason == SMP_PAIR_NOT_SUPPORT || reason == SMP_PASSKEY_ENTRY_FAIL ||
      reason == SMP_REPEATED_ATTEMPTS) {
    smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      break;
    case 6:
      reason = SMP_REPEATED_ATTEMPTS;
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
      break;
  }

    return true;
  ;
  }
  return false;
}

/*******************************************************************************
@@ -1556,12 +1534,21 @@ void smp_process_peer_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  SMP_TRACE_DEBUG("%s start ", __func__);

  // PTS Testing failure modes
  if (p_cb->cert_failure == 1) {
  if (p_cb->cert_failure == SMP_CONFIRM_VALUE_ERR) {
    SMP_TRACE_ERROR("%s failure case = %d", __func__, p_cb->cert_failure);
    reason = p_cb->failure = SMP_CONFIRM_VALUE_ERR;
    smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
    return;
  }
  // PTS Testing failure modes (for LT)
  if ((p_cb->cert_failure == SMP_NUMERIC_COMPAR_FAIL) &&
      (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) &&
      (p_cb->role == HCI_ROLE_SLAVE)) {
    SMP_TRACE_ERROR("%s failure case = %d", __func__, p_cb->cert_failure);
    reason = p_cb->failure = SMP_NUMERIC_COMPAR_FAIL;
    smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
    return;
  }

  switch (p_cb->selected_association_model) {
    case SMP_MODEL_SEC_CONN_JUSTWORKS:
@@ -1589,7 +1576,8 @@ void smp_process_peer_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
      break;
    case SMP_MODEL_SEC_CONN_PASSKEY_ENT:
    case SMP_MODEL_SEC_CONN_PASSKEY_DISP:
      if (!smp_check_commitment(p_cb) && p_cb->cert_failure != 9) {
      if (!smp_check_commitment(p_cb) &&
          p_cb->cert_failure != SMP_NUMERIC_COMPAR_FAIL) {
        reason = p_cb->failure = SMP_CONFIRM_VALUE_ERR;
        smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
        break;
+3 −4
Original line number Diff line number Diff line
@@ -212,10 +212,9 @@ bool SMP_PairCancel(BD_ADDR bd_addr) {
  bool status = false;

  // PTS SMP failure test cases
  if (p_cb->cert_failure == 7)
    err_code = SMP_PASSKEY_ENTRY_FAIL;
  else if (p_cb->cert_failure == 8)
    err_code = SMP_NUMERIC_COMPAR_FAIL;
  if (p_cb->cert_failure == SMP_PASSKEY_ENTRY_FAIL ||
      p_cb->cert_failure == SMP_NUMERIC_COMPAR_FAIL)
    err_code = p_cb->cert_failure;

  BTM_TRACE_EVENT("SMP_CancelPair state=%d flag=0x%x ", p_cb->state,
                  p_cb->flags);