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

Commit af12e2d0 authored by Myles Watson's avatar Myles Watson Committed by android-build-team Robot
Browse files

smp: Reject pairing if the public keys match

Bug: 174886838
Test: pair an LE device
Tag: #security
Change-Id: I0902fdf6bb5c1c7d443fc73fc480d51226fb836b
Merged-In: I0902fdf6bb5c1c7d443fc73fc480d51226fb836b
(cherry picked from commit bb38f5c7)
parent 3dedaf9b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -689,6 +689,16 @@ void smp_process_pairing_public_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  memcpy(pt.x, p_cb->peer_publ_key.x, BT_OCTET32_LEN);
  memcpy(pt.y, p_cb->peer_publ_key.y, BT_OCTET32_LEN);

  if (!memcmp(p_cb->peer_publ_key.x, p_cb->loc_publ_key.x, BT_OCTET32_LEN) &&
      !memcmp(p_cb->peer_publ_key.y, p_cb->loc_publ_key.y, BT_OCTET32_LEN)) {
    android_errorWriteLog(0x534e4554, "174886838");
    LOG_WARN("Remote and local public keys can't match");
    tSMP_INT_DATA smp;
    smp.status = SMP_PAIR_AUTH_FAIL;
    smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp);
    return;
  }

  if (!ECC_ValidatePoint(pt)) {
    android_errorWriteLog(0x534e4554, "72377774");
    tSMP_INT_DATA smp;