Lines Matching refs:smp
48 #define SMP_ALLOW_CMD(smp, code) set_bit(code, &smp->allow_cmd) argument
494 struct smp_dev *smp; in smp_irk_matches() local
501 smp = chan->data; in smp_irk_matches()
505 err = smp_ah(smp->tfm_aes, irk, &bdaddr->b[3], hash); in smp_irk_matches()
515 struct smp_dev *smp; in smp_generate_rpa() local
521 smp = chan->data; in smp_generate_rpa()
528 err = smp_ah(smp->tfm_aes, irk, &rpa->b[3], rpa->b); in smp_generate_rpa()
540 struct smp_dev *smp; in smp_generate_oob() local
546 smp = chan->data; in smp_generate_oob()
550 memcpy(smp->local_pk, debug_pk, 64); in smp_generate_oob()
551 memcpy(smp->local_sk, debug_sk, 32); in smp_generate_oob()
552 smp->debug_key = true; in smp_generate_oob()
556 if (!ecc_make_key(smp->local_pk, smp->local_sk)) in smp_generate_oob()
562 if (memcmp(smp->local_sk, debug_sk, 32)) in smp_generate_oob()
565 smp->debug_key = false; in smp_generate_oob()
568 SMP_DBG("OOB Public Key X: %32phN", smp->local_pk); in smp_generate_oob()
569 SMP_DBG("OOB Public Key Y: %32phN", smp->local_pk + 32); in smp_generate_oob()
570 SMP_DBG("OOB Private Key: %32phN", smp->local_sk); in smp_generate_oob()
572 get_random_bytes(smp->local_rand, 16); in smp_generate_oob()
574 err = smp_f4(smp->tfm_cmac, smp->local_pk, smp->local_pk, in smp_generate_oob()
575 smp->local_rand, 0, hash); in smp_generate_oob()
579 memcpy(rand, smp->local_rand, 16); in smp_generate_oob()
586 struct l2cap_chan *chan = conn->smp; in smp_send_cmd()
587 struct smp_chan *smp; in smp_send_cmd() local
611 smp = chan->data; in smp_send_cmd()
613 cancel_delayed_work_sync(&smp->security_timer); in smp_send_cmd()
614 schedule_delayed_work(&smp->security_timer, SMP_TIMEOUT); in smp_send_cmd()
646 struct l2cap_chan *chan = conn->smp; in build_pairing_cmd()
647 struct smp_chan *smp = chan->data; in build_pairing_cmd() local
684 set_bit(SMP_FLAG_REMOTE_OOB, &smp->flags); in build_pairing_cmd()
686 memcpy(smp->rr, oob_data->rand256, 16); in build_pairing_cmd()
687 memcpy(smp->pcnf, oob_data->hash256, 16); in build_pairing_cmd()
688 SMP_DBG("OOB Remote Confirmation: %16phN", smp->pcnf); in build_pairing_cmd()
689 SMP_DBG("OOB Remote Random: %16phN", smp->rr); in build_pairing_cmd()
704 smp->remote_key_dist = remote_dist; in build_pairing_cmd()
715 smp->remote_key_dist = rsp->init_key_dist; in build_pairing_cmd()
720 struct l2cap_chan *chan = conn->smp; in check_enc_key_size()
721 struct smp_chan *smp = chan->data; in check_enc_key_size() local
727 smp->enc_key_size = max_key_size; in check_enc_key_size()
734 struct l2cap_chan *chan = conn->smp; in smp_chan_destroy()
735 struct smp_chan *smp = chan->data; in smp_chan_destroy() local
739 BUG_ON(!smp); in smp_chan_destroy()
741 cancel_delayed_work_sync(&smp->security_timer); in smp_chan_destroy()
743 complete = test_bit(SMP_FLAG_COMPLETE, &smp->flags); in smp_chan_destroy()
746 kzfree(smp->csrk); in smp_chan_destroy()
747 kzfree(smp->slave_csrk); in smp_chan_destroy()
748 kzfree(smp->link_key); in smp_chan_destroy()
750 crypto_free_blkcipher(smp->tfm_aes); in smp_chan_destroy()
751 crypto_free_hash(smp->tfm_cmac); in smp_chan_destroy()
756 if (smp->ltk && smp->ltk->type == SMP_LTK_P256_DEBUG && in smp_chan_destroy()
758 list_del_rcu(&smp->ltk->list); in smp_chan_destroy()
759 kfree_rcu(smp->ltk, rcu); in smp_chan_destroy()
760 smp->ltk = NULL; in smp_chan_destroy()
765 if (smp->ltk) { in smp_chan_destroy()
766 list_del_rcu(&smp->ltk->list); in smp_chan_destroy()
767 kfree_rcu(smp->ltk, rcu); in smp_chan_destroy()
770 if (smp->slave_ltk) { in smp_chan_destroy()
771 list_del_rcu(&smp->slave_ltk->list); in smp_chan_destroy()
772 kfree_rcu(smp->slave_ltk, rcu); in smp_chan_destroy()
775 if (smp->remote_irk) { in smp_chan_destroy()
776 list_del_rcu(&smp->remote_irk->list); in smp_chan_destroy()
777 kfree_rcu(smp->remote_irk, rcu); in smp_chan_destroy()
782 kzfree(smp); in smp_chan_destroy()
789 struct l2cap_chan *chan = conn->smp; in smp_failure()
826 static u8 get_auth_method(struct smp_chan *smp, u8 local_io, u8 remote_io) in get_auth_method() argument
835 if (test_bit(SMP_FLAG_SC, &smp->flags)) in get_auth_method()
845 struct l2cap_chan *chan = conn->smp; in tk_request()
846 struct smp_chan *smp = chan->data; in tk_request() local
851 memset(smp->tk, 0, sizeof(smp->tk)); in tk_request()
852 clear_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
863 smp->method = JUST_CFM; in tk_request()
865 smp->method = get_auth_method(smp, local_io, remote_io); in tk_request()
868 if (smp->method == JUST_CFM && test_bit(SMP_FLAG_INITIATOR, in tk_request()
869 &smp->flags)) in tk_request()
870 smp->method = JUST_WORKS; in tk_request()
873 if (smp->method == JUST_CFM && in tk_request()
875 smp->method = JUST_WORKS; in tk_request()
878 if (smp->method == JUST_WORKS) { in tk_request()
879 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
886 if (test_bit(SMP_FLAG_SC, &smp->flags)) in tk_request()
890 if (smp->method != JUST_CFM) { in tk_request()
891 set_bit(SMP_FLAG_MITM_AUTH, &smp->flags); in tk_request()
899 if (smp->method == OVERLAP) { in tk_request()
901 smp->method = CFM_PASSKEY; in tk_request()
903 smp->method = REQ_PASSKEY; in tk_request()
907 if (smp->method == CFM_PASSKEY) { in tk_request()
908 memset(smp->tk, 0, sizeof(smp->tk)); in tk_request()
911 put_unaligned_le32(passkey, smp->tk); in tk_request()
913 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
916 if (smp->method == REQ_PASSKEY) in tk_request()
919 else if (smp->method == JUST_CFM) in tk_request()
931 static u8 smp_confirm(struct smp_chan *smp) in smp_confirm() argument
933 struct l2cap_conn *conn = smp->conn; in smp_confirm()
939 ret = smp_c1(smp->tfm_aes, smp->tk, smp->prnd, smp->preq, smp->prsp, in smp_confirm()
946 clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_confirm()
948 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); in smp_confirm()
951 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_confirm()
953 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_confirm()
958 static u8 smp_random(struct smp_chan *smp) in smp_random() argument
960 struct l2cap_conn *conn = smp->conn; in smp_random()
965 if (IS_ERR_OR_NULL(smp->tfm_aes)) in smp_random()
970 ret = smp_c1(smp->tfm_aes, smp->tk, smp->rrnd, smp->preq, smp->prsp, in smp_random()
976 if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { in smp_random()
986 smp_s1(smp->tfm_aes, smp->tk, smp->rrnd, smp->prnd, stk); in smp_random()
988 memset(stk + smp->enc_key_size, 0, in smp_random()
989 SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); in smp_random()
995 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1002 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_random()
1003 smp->prnd); in smp_random()
1005 smp_s1(smp->tfm_aes, smp->tk, smp->prnd, smp->rrnd, stk); in smp_random()
1007 memset(stk + smp->enc_key_size, 0, in smp_random()
1008 SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); in smp_random()
1020 SMP_STK, auth, stk, smp->enc_key_size, ediv, rand); in smp_random()
1028 struct l2cap_chan *chan = conn->smp; in smp_notify_keys()
1029 struct smp_chan *smp = chan->data; in smp_notify_keys() local
1032 struct smp_cmd_pairing *req = (void *) &smp->preq[1]; in smp_notify_keys()
1033 struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; in smp_notify_keys()
1036 if (smp->remote_irk) { in smp_notify_keys()
1037 mgmt_new_irk(hdev, smp->remote_irk); in smp_notify_keys()
1043 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1044 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1058 if (!bacmp(&smp->remote_irk->rpa, BDADDR_ANY)) { in smp_notify_keys()
1059 list_del_rcu(&smp->remote_irk->list); in smp_notify_keys()
1060 kfree_rcu(smp->remote_irk, rcu); in smp_notify_keys()
1061 smp->remote_irk = NULL; in smp_notify_keys()
1080 if (smp->csrk) { in smp_notify_keys()
1081 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1082 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1083 mgmt_new_csrk(hdev, smp->csrk, persistent); in smp_notify_keys()
1086 if (smp->slave_csrk) { in smp_notify_keys()
1087 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1088 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1089 mgmt_new_csrk(hdev, smp->slave_csrk, persistent); in smp_notify_keys()
1092 if (smp->ltk) { in smp_notify_keys()
1093 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1094 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1095 mgmt_new_ltk(hdev, smp->ltk, persistent); in smp_notify_keys()
1098 if (smp->slave_ltk) { in smp_notify_keys()
1099 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1100 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1101 mgmt_new_ltk(hdev, smp->slave_ltk, persistent); in smp_notify_keys()
1104 if (smp->link_key) { in smp_notify_keys()
1108 if (test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags)) in smp_notify_keys()
1115 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1116 smp->link_key, type, 0, &persistent); in smp_notify_keys()
1132 static void sc_add_ltk(struct smp_chan *smp) in sc_add_ltk() argument
1134 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk()
1137 if (test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags)) in sc_add_ltk()
1147 memset(smp->tk + smp->enc_key_size, 0, in sc_add_ltk()
1148 SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); in sc_add_ltk()
1150 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1151 key_type, auth, smp->tk, smp->enc_key_size, in sc_add_ltk()
1155 static void sc_generate_link_key(struct smp_chan *smp) in sc_generate_link_key() argument
1163 smp->link_key = kzalloc(16, GFP_KERNEL); in sc_generate_link_key()
1164 if (!smp->link_key) in sc_generate_link_key()
1167 if (smp_h6(smp->tfm_cmac, smp->tk, tmp1, smp->link_key)) { in sc_generate_link_key()
1168 kzfree(smp->link_key); in sc_generate_link_key()
1169 smp->link_key = NULL; in sc_generate_link_key()
1173 if (smp_h6(smp->tfm_cmac, smp->link_key, lebr, smp->link_key)) { in sc_generate_link_key()
1174 kzfree(smp->link_key); in sc_generate_link_key()
1175 smp->link_key = NULL; in sc_generate_link_key()
1180 static void smp_allow_key_dist(struct smp_chan *smp) in smp_allow_key_dist() argument
1186 if (smp->remote_key_dist & SMP_DIST_ENC_KEY) in smp_allow_key_dist()
1187 SMP_ALLOW_CMD(smp, SMP_CMD_ENCRYPT_INFO); in smp_allow_key_dist()
1188 else if (smp->remote_key_dist & SMP_DIST_ID_KEY) in smp_allow_key_dist()
1189 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_INFO); in smp_allow_key_dist()
1190 else if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_allow_key_dist()
1191 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_allow_key_dist()
1194 static void sc_generate_ltk(struct smp_chan *smp) in sc_generate_ltk() argument
1201 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk()
1212 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_generate_ltk()
1214 if (smp_h6(smp->tfm_cmac, key->val, tmp2, smp->tk)) in sc_generate_ltk()
1217 if (smp_h6(smp->tfm_cmac, smp->tk, brle, smp->tk)) in sc_generate_ltk()
1220 sc_add_ltk(smp); in sc_generate_ltk()
1223 static void smp_distribute_keys(struct smp_chan *smp) in smp_distribute_keys() argument
1226 struct l2cap_conn *conn = smp->conn; in smp_distribute_keys()
1233 rsp = (void *) &smp->prsp[1]; in smp_distribute_keys()
1236 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1237 smp_allow_key_dist(smp); in smp_distribute_keys()
1241 req = (void *) &smp->preq[1]; in smp_distribute_keys()
1251 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_distribute_keys()
1253 sc_generate_link_key(smp); in smp_distribute_keys()
1255 sc_generate_ltk(smp); in smp_distribute_keys()
1280 smp->enc_key_size, ediv, rand); in smp_distribute_keys()
1281 smp->slave_ltk = ltk; in smp_distribute_keys()
1329 smp->slave_csrk = csrk; in smp_distribute_keys()
1337 if (smp->remote_key_dist & KEY_DIST_MASK) { in smp_distribute_keys()
1338 smp_allow_key_dist(smp); in smp_distribute_keys()
1342 set_bit(SMP_FLAG_COMPLETE, &smp->flags); in smp_distribute_keys()
1350 struct smp_chan *smp = container_of(work, struct smp_chan, in smp_timeout() local
1352 struct l2cap_conn *conn = smp->conn; in smp_timeout()
1361 struct l2cap_chan *chan = conn->smp; in smp_chan_create()
1362 struct smp_chan *smp; in smp_chan_create() local
1364 smp = kzalloc(sizeof(*smp), GFP_ATOMIC); in smp_chan_create()
1365 if (!smp) in smp_chan_create()
1368 smp->tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC); in smp_chan_create()
1369 if (IS_ERR(smp->tfm_aes)) { in smp_chan_create()
1371 kzfree(smp); in smp_chan_create()
1375 smp->tfm_cmac = crypto_alloc_hash("cmac(aes)", 0, CRYPTO_ALG_ASYNC); in smp_chan_create()
1376 if (IS_ERR(smp->tfm_cmac)) { in smp_chan_create()
1378 crypto_free_blkcipher(smp->tfm_aes); in smp_chan_create()
1379 kzfree(smp); in smp_chan_create()
1383 smp->conn = conn; in smp_chan_create()
1384 chan->data = smp; in smp_chan_create()
1386 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_FAIL); in smp_chan_create()
1388 INIT_DELAYED_WORK(&smp->security_timer, smp_timeout); in smp_chan_create()
1392 return smp; in smp_chan_create()
1395 static int sc_mackey_and_ltk(struct smp_chan *smp, u8 mackey[16], u8 ltk[16]) in sc_mackey_and_ltk() argument
1397 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk()
1401 na = smp->prnd; in sc_mackey_and_ltk()
1402 nb = smp->rrnd; in sc_mackey_and_ltk()
1404 na = smp->rrnd; in sc_mackey_and_ltk()
1405 nb = smp->prnd; in sc_mackey_and_ltk()
1413 return smp_f5(smp->tfm_cmac, smp->dhkey, na, nb, a, b, mackey, ltk); in sc_mackey_and_ltk()
1416 static void sc_dhkey_check(struct smp_chan *smp) in sc_dhkey_check() argument
1418 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check()
1431 memcpy(io_cap, &smp->preq[1], 3); in sc_dhkey_check()
1435 memcpy(io_cap, &smp->prsp[1], 3); in sc_dhkey_check()
1440 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in sc_dhkey_check()
1443 if (smp->method == REQ_OOB) in sc_dhkey_check()
1444 memcpy(r, smp->rr, 16); in sc_dhkey_check()
1446 smp_f6(smp->tfm_cmac, smp->mackey, smp->prnd, smp->rrnd, r, io_cap, in sc_dhkey_check()
1449 smp_send_cmd(smp->conn, SMP_CMD_DHKEY_CHECK, sizeof(check), &check); in sc_dhkey_check()
1452 static u8 sc_passkey_send_confirm(struct smp_chan *smp) in sc_passkey_send_confirm() argument
1454 struct l2cap_conn *conn = smp->conn; in sc_passkey_send_confirm()
1459 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1462 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in sc_passkey_send_confirm()
1464 if (smp_f4(smp->tfm_cmac, smp->local_pk, smp->remote_pk, smp->prnd, r, in sc_passkey_send_confirm()
1473 static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op) in sc_passkey_round() argument
1475 struct l2cap_conn *conn = smp->conn; in sc_passkey_round()
1481 if (smp->passkey_round >= 20) in sc_passkey_round()
1486 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1489 if (smp_f4(smp->tfm_cmac, smp->remote_pk, smp->local_pk, in sc_passkey_round()
1490 smp->rrnd, r, cfm)) in sc_passkey_round()
1493 if (memcmp(smp->pcnf, cfm, 16)) in sc_passkey_round()
1496 smp->passkey_round++; in sc_passkey_round()
1498 if (smp->passkey_round == 20) { in sc_passkey_round()
1500 if (sc_mackey_and_ltk(smp, smp->mackey, smp->tk)) in sc_passkey_round()
1509 sizeof(smp->prnd), smp->prnd); in sc_passkey_round()
1510 if (smp->passkey_round == 20) in sc_passkey_round()
1511 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_passkey_round()
1513 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in sc_passkey_round()
1518 if (smp->passkey_round != 20) in sc_passkey_round()
1519 return sc_passkey_round(smp, 0); in sc_passkey_round()
1522 sc_dhkey_check(smp); in sc_passkey_round()
1523 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_passkey_round()
1528 if (test_bit(SMP_FLAG_WAIT_USER, &smp->flags)) { in sc_passkey_round()
1529 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in sc_passkey_round()
1533 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in sc_passkey_round()
1537 sizeof(smp->prnd), smp->prnd); in sc_passkey_round()
1541 return sc_passkey_send_confirm(smp); in sc_passkey_round()
1550 smp->passkey_round + 1); in sc_passkey_round()
1552 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in sc_passkey_round()
1554 return sc_passkey_send_confirm(smp); in sc_passkey_round()
1560 static int sc_user_reply(struct smp_chan *smp, u16 mgmt_op, __le32 passkey) in sc_user_reply() argument
1562 struct l2cap_conn *conn = smp->conn; in sc_user_reply()
1566 clear_bit(SMP_FLAG_WAIT_USER, &smp->flags); in sc_user_reply()
1570 smp_failure(smp->conn, SMP_PASSKEY_ENTRY_FAILED); in sc_user_reply()
1573 smp_failure(smp->conn, SMP_NUMERIC_COMP_FAILED); in sc_user_reply()
1577 smp->passkey_round = 0; in sc_user_reply()
1579 if (test_and_clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) in sc_user_reply()
1584 if (sc_passkey_round(smp, smp_op)) in sc_user_reply()
1592 sc_dhkey_check(smp); in sc_user_reply()
1593 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_user_reply()
1594 } else if (test_and_clear_bit(SMP_FLAG_DHKEY_PENDING, &smp->flags)) { in sc_user_reply()
1595 sc_dhkey_check(smp); in sc_user_reply()
1596 sc_add_ltk(smp); in sc_user_reply()
1606 struct smp_chan *smp; in smp_user_confirm_reply() local
1615 chan = conn->smp; in smp_user_confirm_reply()
1625 smp = chan->data; in smp_user_confirm_reply()
1627 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_user_confirm_reply()
1628 err = sc_user_reply(smp, mgmt_op, passkey); in smp_user_confirm_reply()
1635 memset(smp->tk, 0, sizeof(smp->tk)); in smp_user_confirm_reply()
1637 put_unaligned_le32(value, smp->tk); in smp_user_confirm_reply()
1640 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in smp_user_confirm_reply()
1656 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) { in smp_user_confirm_reply()
1657 u8 rsp = smp_confirm(smp); in smp_user_confirm_reply()
1667 static void build_bredr_pairing_cmd(struct smp_chan *smp, in build_bredr_pairing_cmd() argument
1671 struct l2cap_conn *conn = smp->conn; in build_bredr_pairing_cmd()
1693 smp->remote_key_dist = remote_dist; in build_bredr_pairing_cmd()
1704 smp->remote_key_dist = rsp->init_key_dist; in build_bredr_pairing_cmd()
1710 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_req()
1712 struct smp_chan *smp; in smp_cmd_pairing_req() local
1725 smp = smp_chan_create(conn); in smp_cmd_pairing_req()
1727 smp = chan->data; in smp_cmd_pairing_req()
1729 if (!smp) in smp_cmd_pairing_req()
1742 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_cmd_pairing_req()
1743 memcpy(&smp->preq[1], req, sizeof(*req)); in smp_cmd_pairing_req()
1751 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); in smp_cmd_pairing_req()
1760 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_req()
1762 build_bredr_pairing_cmd(smp, req, &rsp); in smp_cmd_pairing_req()
1769 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_req()
1771 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_req()
1772 memcpy(&smp->prsp[1], &rsp, sizeof(rsp)); in smp_cmd_pairing_req()
1775 smp_distribute_keys(smp); in smp_cmd_pairing_req()
1782 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_req()
1796 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1806 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in smp_cmd_pairing_req()
1808 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_req()
1809 memcpy(&smp->prsp[1], &rsp, sizeof(rsp)); in smp_cmd_pairing_req()
1813 clear_bit(SMP_FLAG_INITIATOR, &smp->flags); in smp_cmd_pairing_req()
1820 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_pairing_req()
1822 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_req()
1823 SMP_ALLOW_CMD(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_pairing_req()
1825 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_req()
1838 static u8 sc_send_public_key(struct smp_chan *smp) in sc_send_public_key() argument
1840 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1844 if (test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) { in sc_send_public_key()
1853 memcpy(smp->local_pk, smp_dev->local_pk, 64); in sc_send_public_key()
1854 memcpy(smp->local_sk, smp_dev->local_sk, 32); in sc_send_public_key()
1855 memcpy(smp->lr, smp_dev->local_rand, 16); in sc_send_public_key()
1858 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_send_public_key()
1865 memcpy(smp->local_pk, debug_pk, 64); in sc_send_public_key()
1866 memcpy(smp->local_sk, debug_sk, 32); in sc_send_public_key()
1867 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_send_public_key()
1871 if (!ecc_make_key(smp->local_pk, smp->local_sk)) in sc_send_public_key()
1877 if (memcmp(smp->local_sk, debug_sk, 32)) in sc_send_public_key()
1883 SMP_DBG("Local Public Key X: %32phN", smp->local_pk); in sc_send_public_key()
1884 SMP_DBG("Local Public Key Y: %32phN", smp->local_pk + 32); in sc_send_public_key()
1885 SMP_DBG("Local Private Key: %32phN", smp->local_sk); in sc_send_public_key()
1887 smp_send_cmd(smp->conn, SMP_CMD_PUBLIC_KEY, 64, smp->local_pk); in sc_send_public_key()
1895 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_rsp()
1896 struct smp_chan *smp = chan->data; in smp_cmd_pairing_rsp() local
1911 req = (void *) &smp->preq[1]; in smp_cmd_pairing_rsp()
1927 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); in smp_cmd_pairing_rsp()
1929 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_rsp()
1930 memcpy(&smp->prsp[1], rsp, sizeof(*rsp)); in smp_cmd_pairing_rsp()
1935 smp->remote_key_dist &= rsp->resp_key_dist; in smp_cmd_pairing_rsp()
1940 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_rsp()
1941 smp_distribute_keys(smp); in smp_cmd_pairing_rsp()
1946 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_rsp()
1954 method = get_auth_method(smp, req->io_capability, in smp_cmd_pairing_rsp()
1960 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in smp_cmd_pairing_rsp()
1965 smp->remote_key_dist &= rsp->resp_key_dist; in smp_cmd_pairing_rsp()
1967 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_rsp()
1969 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_rsp()
1970 SMP_ALLOW_CMD(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_pairing_rsp()
1971 return sc_send_public_key(smp); in smp_cmd_pairing_rsp()
1980 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_cmd_pairing_rsp()
1983 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) in smp_cmd_pairing_rsp()
1984 return smp_confirm(smp); in smp_cmd_pairing_rsp()
1989 static u8 sc_check_confirm(struct smp_chan *smp) in sc_check_confirm() argument
1991 struct l2cap_conn *conn = smp->conn; in sc_check_confirm()
1995 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in sc_check_confirm()
1996 return sc_passkey_round(smp, SMP_CMD_PAIRING_CONFIRM); in sc_check_confirm()
1999 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in sc_check_confirm()
2000 smp->prnd); in sc_check_confirm()
2001 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in sc_check_confirm()
2011 static int fixup_sc_false_positive(struct smp_chan *smp) in fixup_sc_false_positive() argument
2013 struct l2cap_conn *conn = smp->conn; in fixup_sc_false_positive()
2030 req = (void *) &smp->preq[1]; in fixup_sc_false_positive()
2031 rsp = (void *) &smp->prsp[1]; in fixup_sc_false_positive()
2034 smp->remote_key_dist = (req->init_key_dist & rsp->resp_key_dist); in fixup_sc_false_positive()
2043 clear_bit(SMP_FLAG_SC, &smp->flags); in fixup_sc_false_positive()
2050 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_confirm()
2051 struct smp_chan *smp = chan->data; in smp_cmd_pairing_confirm() local
2055 if (skb->len < sizeof(smp->pcnf)) in smp_cmd_pairing_confirm()
2058 memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf)); in smp_cmd_pairing_confirm()
2059 skb_pull(skb, sizeof(smp->pcnf)); in smp_cmd_pairing_confirm()
2061 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_confirm()
2065 if (test_bit(SMP_FLAG_REMOTE_PK, &smp->flags)) in smp_cmd_pairing_confirm()
2066 return sc_check_confirm(smp); in smp_cmd_pairing_confirm()
2070 ret = fixup_sc_false_positive(smp); in smp_cmd_pairing_confirm()
2076 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_confirm()
2077 smp->prnd); in smp_cmd_pairing_confirm()
2078 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_pairing_confirm()
2082 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) in smp_cmd_pairing_confirm()
2083 return smp_confirm(smp); in smp_cmd_pairing_confirm()
2085 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_cmd_pairing_confirm()
2092 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_random()
2093 struct smp_chan *smp = chan->data; in smp_cmd_pairing_random() local
2101 if (skb->len < sizeof(smp->rrnd)) in smp_cmd_pairing_random()
2104 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); in smp_cmd_pairing_random()
2105 skb_pull(skb, sizeof(smp->rrnd)); in smp_cmd_pairing_random()
2107 if (!test_bit(SMP_FLAG_SC, &smp->flags)) in smp_cmd_pairing_random()
2108 return smp_random(smp); in smp_cmd_pairing_random()
2111 pkax = smp->local_pk; in smp_cmd_pairing_random()
2112 pkbx = smp->remote_pk; in smp_cmd_pairing_random()
2113 na = smp->prnd; in smp_cmd_pairing_random()
2114 nb = smp->rrnd; in smp_cmd_pairing_random()
2116 pkax = smp->remote_pk; in smp_cmd_pairing_random()
2117 pkbx = smp->local_pk; in smp_cmd_pairing_random()
2118 na = smp->rrnd; in smp_cmd_pairing_random()
2119 nb = smp->prnd; in smp_cmd_pairing_random()
2122 if (smp->method == REQ_OOB) { in smp_cmd_pairing_random()
2125 sizeof(smp->prnd), smp->prnd); in smp_cmd_pairing_random()
2126 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2131 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in smp_cmd_pairing_random()
2132 return sc_passkey_round(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_pairing_random()
2137 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->local_pk, in smp_cmd_pairing_random()
2138 smp->rrnd, 0, cfm); in smp_cmd_pairing_random()
2142 if (memcmp(smp->pcnf, cfm, 16)) in smp_cmd_pairing_random()
2145 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_random()
2146 smp->prnd); in smp_cmd_pairing_random()
2147 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2152 err = sc_mackey_and_ltk(smp, smp->mackey, smp->tk); in smp_cmd_pairing_random()
2156 if (smp->method == JUST_WORKS || smp->method == REQ_OOB) { in smp_cmd_pairing_random()
2158 sc_dhkey_check(smp); in smp_cmd_pairing_random()
2159 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2164 err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); in smp_cmd_pairing_random()
2173 set_bit(SMP_FLAG_WAIT_USER, &smp->flags); in smp_cmd_pairing_random()
2231 struct smp_chan *smp; in smp_cmd_security_req() local
2261 smp = smp_chan_create(conn); in smp_cmd_security_req()
2262 if (!smp) in smp_cmd_security_req()
2274 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_cmd_security_req()
2275 memcpy(&smp->preq[1], &cp, sizeof(cp)); in smp_cmd_security_req()
2278 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in smp_cmd_security_req()
2287 struct smp_chan *smp; in smp_conn_security() local
2310 chan = conn->smp; in smp_conn_security()
2324 smp = smp_chan_create(conn); in smp_conn_security()
2325 if (!smp) { in smp_conn_security()
2346 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_conn_security()
2347 memcpy(&smp->preq[1], &cp, sizeof(cp)); in smp_conn_security()
2350 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in smp_conn_security()
2355 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_REQ); in smp_conn_security()
2358 set_bit(SMP_FLAG_INITIATOR, &smp->flags); in smp_conn_security()
2369 struct l2cap_chan *chan = conn->smp; in smp_cmd_encrypt_info()
2370 struct smp_chan *smp = chan->data; in smp_cmd_encrypt_info() local
2377 SMP_ALLOW_CMD(smp, SMP_CMD_MASTER_IDENT); in smp_cmd_encrypt_info()
2381 memcpy(smp->tk, rp->ltk, sizeof(smp->tk)); in smp_cmd_encrypt_info()
2389 struct l2cap_chan *chan = conn->smp; in smp_cmd_master_ident()
2390 struct smp_chan *smp = chan->data; in smp_cmd_master_ident() local
2402 smp->remote_key_dist &= ~SMP_DIST_ENC_KEY; in smp_cmd_master_ident()
2404 if (smp->remote_key_dist & SMP_DIST_ID_KEY) in smp_cmd_master_ident()
2405 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_INFO); in smp_cmd_master_ident()
2406 else if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_cmd_master_ident()
2407 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_cmd_master_ident()
2413 authenticated, smp->tk, smp->enc_key_size, in smp_cmd_master_ident()
2415 smp->ltk = ltk; in smp_cmd_master_ident()
2416 if (!(smp->remote_key_dist & KEY_DIST_MASK)) in smp_cmd_master_ident()
2417 smp_distribute_keys(smp); in smp_cmd_master_ident()
2425 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_info()
2426 struct smp_chan *smp = chan->data; in smp_cmd_ident_info() local
2433 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_ADDR_INFO); in smp_cmd_ident_info()
2437 memcpy(smp->irk, info->irk, 16); in smp_cmd_ident_info()
2446 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_addr_info()
2447 struct smp_chan *smp = chan->data; in smp_cmd_ident_addr_info() local
2457 smp->remote_key_dist &= ~SMP_DIST_ID_KEY; in smp_cmd_ident_addr_info()
2459 if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_cmd_ident_addr_info()
2460 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_cmd_ident_addr_info()
2480 bacpy(&smp->id_addr, &info->bdaddr); in smp_cmd_ident_addr_info()
2481 smp->id_addr_type = info->addr_type; in smp_cmd_ident_addr_info()
2488 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2489 smp->id_addr_type, smp->irk, &rpa); in smp_cmd_ident_addr_info()
2492 if (!(smp->remote_key_dist & KEY_DIST_MASK)) in smp_cmd_ident_addr_info()
2493 smp_distribute_keys(smp); in smp_cmd_ident_addr_info()
2501 struct l2cap_chan *chan = conn->smp; in smp_cmd_sign_info()
2502 struct smp_chan *smp = chan->data; in smp_cmd_sign_info() local
2511 smp->remote_key_dist &= ~SMP_DIST_SIGN; in smp_cmd_sign_info()
2523 smp->csrk = csrk; in smp_cmd_sign_info()
2524 smp_distribute_keys(smp); in smp_cmd_sign_info()
2529 static u8 sc_select_method(struct smp_chan *smp) in sc_select_method() argument
2531 struct l2cap_conn *conn = smp->conn; in sc_select_method()
2536 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags) || in sc_select_method()
2537 test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) in sc_select_method()
2546 local = (void *) &smp->preq[1]; in sc_select_method()
2547 remote = (void *) &smp->prsp[1]; in sc_select_method()
2549 local = (void *) &smp->prsp[1]; in sc_select_method()
2550 remote = (void *) &smp->preq[1]; in sc_select_method()
2563 method = get_auth_method(smp, local_io, remote_io); in sc_select_method()
2568 if (method == JUST_CFM && test_bit(SMP_FLAG_INITIATOR, &smp->flags)) in sc_select_method()
2578 struct l2cap_chan *chan = conn->smp; in smp_cmd_public_key()
2579 struct smp_chan *smp = chan->data; in smp_cmd_public_key() local
2589 memcpy(smp->remote_pk, key, 64); in smp_cmd_public_key()
2591 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) { in smp_cmd_public_key()
2592 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->remote_pk, in smp_cmd_public_key()
2593 smp->rr, 0, cfm.confirm_val); in smp_cmd_public_key()
2597 if (memcmp(cfm.confirm_val, smp->pcnf, 16)) in smp_cmd_public_key()
2605 err = sc_send_public_key(smp); in smp_cmd_public_key()
2610 SMP_DBG("Remote Public Key X: %32phN", smp->remote_pk); in smp_cmd_public_key()
2611 SMP_DBG("Remote Public Key Y: %32phN", smp->remote_pk + 32); in smp_cmd_public_key()
2613 if (!ecdh_shared_secret(smp->remote_pk, smp->local_sk, smp->dhkey)) in smp_cmd_public_key()
2616 SMP_DBG("DHKey %32phN", smp->dhkey); in smp_cmd_public_key()
2618 set_bit(SMP_FLAG_REMOTE_PK, &smp->flags); in smp_cmd_public_key()
2620 smp->method = sc_select_method(smp); in smp_cmd_public_key()
2622 BT_DBG("%s selected method 0x%02x", hdev->name, smp->method); in smp_cmd_public_key()
2625 if (smp->method == JUST_WORKS || smp->method == JUST_CFM) in smp_cmd_public_key()
2630 if (!memcmp(debug_pk, smp->remote_pk, 64)) in smp_cmd_public_key()
2631 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in smp_cmd_public_key()
2633 if (smp->method == DSP_PASSKEY) { in smp_cmd_public_key()
2638 smp->passkey_round = 0; in smp_cmd_public_key()
2644 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2645 return sc_passkey_round(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_public_key()
2648 if (smp->method == REQ_OOB) { in smp_cmd_public_key()
2651 sizeof(smp->prnd), smp->prnd); in smp_cmd_public_key()
2653 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_public_key()
2659 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2661 if (smp->method == REQ_PASSKEY) { in smp_cmd_public_key()
2665 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2666 set_bit(SMP_FLAG_WAIT_USER, &smp->flags); in smp_cmd_public_key()
2676 err = smp_f4(smp->tfm_cmac, smp->local_pk, smp->remote_pk, smp->prnd, in smp_cmd_public_key()
2682 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_public_key()
2690 struct l2cap_chan *chan = conn->smp; in smp_cmd_dhkey_check()
2692 struct smp_chan *smp = chan->data; in smp_cmd_dhkey_check() local
2710 memcpy(io_cap, &smp->prsp[1], 3); in smp_cmd_dhkey_check()
2714 memcpy(io_cap, &smp->preq[1], 3); in smp_cmd_dhkey_check()
2719 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in smp_cmd_dhkey_check()
2721 else if (smp->method == REQ_OOB) in smp_cmd_dhkey_check()
2722 memcpy(r, smp->lr, 16); in smp_cmd_dhkey_check()
2724 err = smp_f6(smp->tfm_cmac, smp->mackey, smp->rrnd, smp->prnd, r, in smp_cmd_dhkey_check()
2733 if (test_bit(SMP_FLAG_WAIT_USER, &smp->flags)) { in smp_cmd_dhkey_check()
2734 set_bit(SMP_FLAG_DHKEY_PENDING, &smp->flags); in smp_cmd_dhkey_check()
2739 sc_dhkey_check(smp); in smp_cmd_dhkey_check()
2742 sc_add_ltk(smp); in smp_cmd_dhkey_check()
2745 hci_le_start_enc(hcon, 0, 0, smp->tk); in smp_cmd_dhkey_check()
2746 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2766 struct smp_chan *smp; in smp_sig_channel() local
2781 smp = chan->data; in smp_sig_channel()
2786 if (smp && !test_and_clear_bit(code, &smp->allow_cmd)) in smp_sig_channel()
2792 if (!smp && code != SMP_CMD_PAIRING_REQ && code != SMP_CMD_SECURITY_REQ) in smp_sig_channel()
2884 conn->smp = NULL; in smp_teardown_cb()
2894 struct smp_chan *smp; in bredr_pairing() local
2935 smp = smp_chan_create(conn); in bredr_pairing()
2936 if (!smp) { in bredr_pairing()
2942 set_bit(SMP_FLAG_SC, &smp->flags); in bredr_pairing()
2947 build_bredr_pairing_cmd(smp, &req, NULL); in bredr_pairing()
2949 smp->preq[0] = SMP_CMD_PAIRING_REQ; in bredr_pairing()
2950 memcpy(&smp->preq[1], &req, sizeof(req)); in bredr_pairing()
2953 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in bredr_pairing()
2958 struct smp_chan *smp = chan->data; in smp_resume_cb() local
2969 if (!smp) in smp_resume_cb()
2975 cancel_delayed_work(&smp->security_timer); in smp_resume_cb()
2977 smp_distribute_keys(smp); in smp_resume_cb()
2987 conn->smp = chan; in smp_ready_cb()
3002 struct smp_chan *smp = chan->data; in smp_recv_cb() local
3004 if (smp) in smp_recv_cb()
3005 cancel_delayed_work_sync(&smp->security_timer); in smp_recv_cb()
3097 struct smp_dev *smp; in smp_add_cid() local
3102 smp = NULL; in smp_add_cid()
3106 smp = kzalloc(sizeof(*smp), GFP_KERNEL); in smp_add_cid()
3107 if (!smp) in smp_add_cid()
3113 kzfree(smp); in smp_add_cid()
3121 kzfree(smp); in smp_add_cid()
3125 smp->tfm_aes = tfm_aes; in smp_add_cid()
3126 smp->tfm_cmac = tfm_cmac; in smp_add_cid()
3131 if (smp) { in smp_add_cid()
3132 crypto_free_blkcipher(smp->tfm_aes); in smp_add_cid()
3133 crypto_free_hash(smp->tfm_cmac); in smp_add_cid()
3134 kzfree(smp); in smp_add_cid()
3139 chan->data = smp; in smp_add_cid()
3172 struct smp_dev *smp; in smp_del_chan() local
3176 smp = chan->data; in smp_del_chan()
3177 if (smp) { in smp_del_chan()
3179 if (smp->tfm_aes) in smp_del_chan()
3180 crypto_free_blkcipher(smp->tfm_aes); in smp_del_chan()
3181 if (smp->tfm_cmac) in smp_del_chan()
3182 crypto_free_hash(smp->tfm_cmac); in smp_del_chan()
3183 kzfree(smp); in smp_del_chan()