Lines Matching refs:smp

51 #define SMP_ALLOW_CMD(smp, code)	set_bit(code, &smp->allow_cmd)  argument
512 struct smp_dev *smp; in smp_irk_matches() local
519 smp = chan->data; in smp_irk_matches()
523 err = smp_ah(smp->tfm_aes, irk, &bdaddr->b[3], hash); in smp_irk_matches()
533 struct smp_dev *smp; in smp_generate_rpa() local
539 smp = chan->data; in smp_generate_rpa()
546 err = smp_ah(smp->tfm_aes, irk, &rpa->b[3], rpa->b); in smp_generate_rpa()
558 struct smp_dev *smp; in smp_generate_oob() local
564 smp = chan->data; in smp_generate_oob()
568 memcpy(smp->local_pk, debug_pk, 64); in smp_generate_oob()
569 memcpy(smp->local_sk, debug_sk, 32); in smp_generate_oob()
570 smp->debug_key = true; in smp_generate_oob()
574 if (!ecc_make_key(smp->local_pk, smp->local_sk)) in smp_generate_oob()
580 if (memcmp(smp->local_sk, debug_sk, 32)) in smp_generate_oob()
583 smp->debug_key = false; in smp_generate_oob()
586 SMP_DBG("OOB Public Key X: %32phN", smp->local_pk); in smp_generate_oob()
587 SMP_DBG("OOB Public Key Y: %32phN", smp->local_pk + 32); in smp_generate_oob()
588 SMP_DBG("OOB Private Key: %32phN", smp->local_sk); in smp_generate_oob()
590 get_random_bytes(smp->local_rand, 16); in smp_generate_oob()
592 err = smp_f4(smp->tfm_cmac, smp->local_pk, smp->local_pk, in smp_generate_oob()
593 smp->local_rand, 0, hash); in smp_generate_oob()
597 memcpy(rand, smp->local_rand, 16); in smp_generate_oob()
604 struct l2cap_chan *chan = conn->smp; in smp_send_cmd()
605 struct smp_chan *smp; in smp_send_cmd() local
629 smp = chan->data; in smp_send_cmd()
631 cancel_delayed_work_sync(&smp->security_timer); in smp_send_cmd()
632 schedule_delayed_work(&smp->security_timer, SMP_TIMEOUT); in smp_send_cmd()
664 struct l2cap_chan *chan = conn->smp; in build_pairing_cmd()
665 struct smp_chan *smp = chan->data; in build_pairing_cmd() local
702 set_bit(SMP_FLAG_REMOTE_OOB, &smp->flags); in build_pairing_cmd()
704 memcpy(smp->rr, oob_data->rand256, 16); in build_pairing_cmd()
705 memcpy(smp->pcnf, oob_data->hash256, 16); in build_pairing_cmd()
706 SMP_DBG("OOB Remote Confirmation: %16phN", smp->pcnf); in build_pairing_cmd()
707 SMP_DBG("OOB Remote Random: %16phN", smp->rr); in build_pairing_cmd()
722 smp->remote_key_dist = remote_dist; in build_pairing_cmd()
733 smp->remote_key_dist = rsp->init_key_dist; in build_pairing_cmd()
738 struct l2cap_chan *chan = conn->smp; in check_enc_key_size()
740 struct smp_chan *smp = chan->data; in check_enc_key_size() local
746 smp->enc_key_size = max_key_size; in check_enc_key_size()
753 struct l2cap_chan *chan = conn->smp; in smp_chan_destroy()
754 struct smp_chan *smp = chan->data; in smp_chan_destroy() local
758 BUG_ON(!smp); in smp_chan_destroy()
760 cancel_delayed_work_sync(&smp->security_timer); in smp_chan_destroy()
762 complete = test_bit(SMP_FLAG_COMPLETE, &smp->flags); in smp_chan_destroy()
765 kzfree(smp->csrk); in smp_chan_destroy()
766 kzfree(smp->slave_csrk); in smp_chan_destroy()
767 kzfree(smp->link_key); in smp_chan_destroy()
769 crypto_free_blkcipher(smp->tfm_aes); in smp_chan_destroy()
770 crypto_free_hash(smp->tfm_cmac); in smp_chan_destroy()
775 if (smp->ltk && smp->ltk->type == SMP_LTK_P256_DEBUG && in smp_chan_destroy()
777 list_del_rcu(&smp->ltk->list); in smp_chan_destroy()
778 kfree_rcu(smp->ltk, rcu); in smp_chan_destroy()
779 smp->ltk = NULL; in smp_chan_destroy()
784 if (smp->ltk) { in smp_chan_destroy()
785 list_del_rcu(&smp->ltk->list); in smp_chan_destroy()
786 kfree_rcu(smp->ltk, rcu); in smp_chan_destroy()
789 if (smp->slave_ltk) { in smp_chan_destroy()
790 list_del_rcu(&smp->slave_ltk->list); in smp_chan_destroy()
791 kfree_rcu(smp->slave_ltk, rcu); in smp_chan_destroy()
794 if (smp->remote_irk) { in smp_chan_destroy()
795 list_del_rcu(&smp->remote_irk->list); in smp_chan_destroy()
796 kfree_rcu(smp->remote_irk, rcu); in smp_chan_destroy()
801 kzfree(smp); in smp_chan_destroy()
808 struct l2cap_chan *chan = conn->smp; in smp_failure()
844 static u8 get_auth_method(struct smp_chan *smp, u8 local_io, u8 remote_io) in get_auth_method() argument
853 if (test_bit(SMP_FLAG_SC, &smp->flags)) in get_auth_method()
863 struct l2cap_chan *chan = conn->smp; in tk_request()
864 struct smp_chan *smp = chan->data; in tk_request() local
869 memset(smp->tk, 0, sizeof(smp->tk)); in tk_request()
870 clear_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
881 smp->method = JUST_CFM; in tk_request()
883 smp->method = get_auth_method(smp, local_io, remote_io); in tk_request()
886 if (smp->method == JUST_CFM && test_bit(SMP_FLAG_INITIATOR, in tk_request()
887 &smp->flags)) in tk_request()
888 smp->method = JUST_WORKS; in tk_request()
891 if (smp->method == JUST_CFM && in tk_request()
893 smp->method = JUST_WORKS; in tk_request()
896 if (smp->method == JUST_WORKS) { in tk_request()
897 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
904 if (test_bit(SMP_FLAG_SC, &smp->flags)) in tk_request()
908 if (smp->method != JUST_CFM) { in tk_request()
909 set_bit(SMP_FLAG_MITM_AUTH, &smp->flags); in tk_request()
917 if (smp->method == OVERLAP) { in tk_request()
919 smp->method = CFM_PASSKEY; in tk_request()
921 smp->method = REQ_PASSKEY; in tk_request()
925 if (smp->method == CFM_PASSKEY) { in tk_request()
926 memset(smp->tk, 0, sizeof(smp->tk)); in tk_request()
929 put_unaligned_le32(passkey, smp->tk); in tk_request()
931 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in tk_request()
934 if (smp->method == REQ_PASSKEY) in tk_request()
937 else if (smp->method == JUST_CFM) in tk_request()
949 static u8 smp_confirm(struct smp_chan *smp) in smp_confirm() argument
951 struct l2cap_conn *conn = smp->conn; in smp_confirm()
957 ret = smp_c1(smp->tfm_aes, smp->tk, smp->prnd, smp->preq, smp->prsp, in smp_confirm()
964 clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_confirm()
966 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); in smp_confirm()
969 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_confirm()
971 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_confirm()
976 static u8 smp_random(struct smp_chan *smp) in smp_random() argument
978 struct l2cap_conn *conn = smp->conn; in smp_random()
983 if (IS_ERR_OR_NULL(smp->tfm_aes)) in smp_random()
988 ret = smp_c1(smp->tfm_aes, smp->tk, smp->rrnd, smp->preq, smp->prsp, in smp_random()
994 if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { in smp_random()
1004 smp_s1(smp->tfm_aes, smp->tk, smp->rrnd, smp->prnd, stk); in smp_random()
1009 hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size); in smp_random()
1010 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1017 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_random()
1018 smp->prnd); in smp_random()
1020 smp_s1(smp->tfm_aes, smp->tk, smp->prnd, smp->rrnd, stk); in smp_random()
1032 SMP_STK, auth, stk, smp->enc_key_size, ediv, rand); in smp_random()
1040 struct l2cap_chan *chan = conn->smp; in smp_notify_keys()
1041 struct smp_chan *smp = chan->data; in smp_notify_keys() local
1044 struct smp_cmd_pairing *req = (void *) &smp->preq[1]; in smp_notify_keys()
1045 struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; in smp_notify_keys()
1063 if (smp->remote_irk) { in smp_notify_keys()
1064 mgmt_new_irk(hdev, smp->remote_irk, persistent); in smp_notify_keys()
1071 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1072 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1077 if (smp->csrk) { in smp_notify_keys()
1078 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1079 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1080 mgmt_new_csrk(hdev, smp->csrk, persistent); in smp_notify_keys()
1083 if (smp->slave_csrk) { in smp_notify_keys()
1084 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1085 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1086 mgmt_new_csrk(hdev, smp->slave_csrk, persistent); in smp_notify_keys()
1089 if (smp->ltk) { in smp_notify_keys()
1090 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1091 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1092 mgmt_new_ltk(hdev, smp->ltk, persistent); in smp_notify_keys()
1095 if (smp->slave_ltk) { in smp_notify_keys()
1096 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1097 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1098 mgmt_new_ltk(hdev, smp->slave_ltk, persistent); in smp_notify_keys()
1101 if (smp->link_key) { in smp_notify_keys()
1105 if (test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags)) in smp_notify_keys()
1112 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1113 smp->link_key, type, 0, &persistent); in smp_notify_keys()
1129 static void sc_add_ltk(struct smp_chan *smp) in sc_add_ltk() argument
1131 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk()
1134 if (test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags)) in sc_add_ltk()
1144 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1145 key_type, auth, smp->tk, smp->enc_key_size, in sc_add_ltk()
1149 static void sc_generate_link_key(struct smp_chan *smp) in sc_generate_link_key() argument
1157 smp->link_key = kzalloc(16, GFP_KERNEL); in sc_generate_link_key()
1158 if (!smp->link_key) in sc_generate_link_key()
1161 if (smp_h6(smp->tfm_cmac, smp->tk, tmp1, smp->link_key)) { in sc_generate_link_key()
1162 kzfree(smp->link_key); in sc_generate_link_key()
1163 smp->link_key = NULL; in sc_generate_link_key()
1167 if (smp_h6(smp->tfm_cmac, smp->link_key, lebr, 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()
1174 static void smp_allow_key_dist(struct smp_chan *smp) in smp_allow_key_dist() argument
1180 if (smp->remote_key_dist & SMP_DIST_ENC_KEY) in smp_allow_key_dist()
1181 SMP_ALLOW_CMD(smp, SMP_CMD_ENCRYPT_INFO); in smp_allow_key_dist()
1182 else if (smp->remote_key_dist & SMP_DIST_ID_KEY) in smp_allow_key_dist()
1183 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_INFO); in smp_allow_key_dist()
1184 else if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_allow_key_dist()
1185 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_allow_key_dist()
1188 static void sc_generate_ltk(struct smp_chan *smp) in sc_generate_ltk() argument
1195 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk()
1206 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_generate_ltk()
1208 if (smp_h6(smp->tfm_cmac, key->val, tmp2, smp->tk)) in sc_generate_ltk()
1211 if (smp_h6(smp->tfm_cmac, smp->tk, brle, smp->tk)) in sc_generate_ltk()
1214 sc_add_ltk(smp); in sc_generate_ltk()
1217 static void smp_distribute_keys(struct smp_chan *smp) in smp_distribute_keys() argument
1220 struct l2cap_conn *conn = smp->conn; in smp_distribute_keys()
1227 rsp = (void *) &smp->prsp[1]; in smp_distribute_keys()
1230 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1231 smp_allow_key_dist(smp); in smp_distribute_keys()
1235 req = (void *) &smp->preq[1]; in smp_distribute_keys()
1245 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_distribute_keys()
1247 sc_generate_link_key(smp); in smp_distribute_keys()
1249 sc_generate_ltk(smp); in smp_distribute_keys()
1269 get_random_bytes(enc.ltk, smp->enc_key_size); in smp_distribute_keys()
1270 memset(enc.ltk + smp->enc_key_size, 0, in smp_distribute_keys()
1271 sizeof(enc.ltk) - smp->enc_key_size); in smp_distribute_keys()
1281 smp->enc_key_size, ediv, rand); in smp_distribute_keys()
1282 smp->slave_ltk = ltk; in smp_distribute_keys()
1330 smp->slave_csrk = csrk; in smp_distribute_keys()
1338 if (smp->remote_key_dist & KEY_DIST_MASK) { in smp_distribute_keys()
1339 smp_allow_key_dist(smp); in smp_distribute_keys()
1343 set_bit(SMP_FLAG_COMPLETE, &smp->flags); in smp_distribute_keys()
1351 struct smp_chan *smp = container_of(work, struct smp_chan, in smp_timeout() local
1353 struct l2cap_conn *conn = smp->conn; in smp_timeout()
1362 struct l2cap_chan *chan = conn->smp; in smp_chan_create()
1363 struct smp_chan *smp; in smp_chan_create() local
1365 smp = kzalloc(sizeof(*smp), GFP_ATOMIC); in smp_chan_create()
1366 if (!smp) in smp_chan_create()
1369 smp->tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC); in smp_chan_create()
1370 if (IS_ERR(smp->tfm_aes)) { in smp_chan_create()
1372 kzfree(smp); in smp_chan_create()
1376 smp->tfm_cmac = crypto_alloc_hash("cmac(aes)", 0, CRYPTO_ALG_ASYNC); in smp_chan_create()
1377 if (IS_ERR(smp->tfm_cmac)) { in smp_chan_create()
1379 crypto_free_blkcipher(smp->tfm_aes); in smp_chan_create()
1380 kzfree(smp); in smp_chan_create()
1384 smp->conn = conn; in smp_chan_create()
1385 chan->data = smp; in smp_chan_create()
1387 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_FAIL); in smp_chan_create()
1389 INIT_DELAYED_WORK(&smp->security_timer, smp_timeout); in smp_chan_create()
1393 return smp; in smp_chan_create()
1396 static int sc_mackey_and_ltk(struct smp_chan *smp, u8 mackey[16], u8 ltk[16]) in sc_mackey_and_ltk() argument
1398 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk()
1402 na = smp->prnd; in sc_mackey_and_ltk()
1403 nb = smp->rrnd; in sc_mackey_and_ltk()
1405 na = smp->rrnd; in sc_mackey_and_ltk()
1406 nb = smp->prnd; in sc_mackey_and_ltk()
1414 return smp_f5(smp->tfm_cmac, smp->dhkey, na, nb, a, b, mackey, ltk); in sc_mackey_and_ltk()
1417 static void sc_dhkey_check(struct smp_chan *smp) in sc_dhkey_check() argument
1419 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check()
1432 memcpy(io_cap, &smp->preq[1], 3); in sc_dhkey_check()
1436 memcpy(io_cap, &smp->prsp[1], 3); in sc_dhkey_check()
1441 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in sc_dhkey_check()
1444 if (smp->method == REQ_OOB) in sc_dhkey_check()
1445 memcpy(r, smp->rr, 16); in sc_dhkey_check()
1447 smp_f6(smp->tfm_cmac, smp->mackey, smp->prnd, smp->rrnd, r, io_cap, in sc_dhkey_check()
1450 smp_send_cmd(smp->conn, SMP_CMD_DHKEY_CHECK, sizeof(check), &check); in sc_dhkey_check()
1453 static u8 sc_passkey_send_confirm(struct smp_chan *smp) in sc_passkey_send_confirm() argument
1455 struct l2cap_conn *conn = smp->conn; in sc_passkey_send_confirm()
1460 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1463 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in sc_passkey_send_confirm()
1465 if (smp_f4(smp->tfm_cmac, smp->local_pk, smp->remote_pk, smp->prnd, r, in sc_passkey_send_confirm()
1474 static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op) in sc_passkey_round() argument
1476 struct l2cap_conn *conn = smp->conn; in sc_passkey_round()
1482 if (smp->passkey_round >= 20) in sc_passkey_round()
1487 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1490 if (smp_f4(smp->tfm_cmac, smp->remote_pk, smp->local_pk, in sc_passkey_round()
1491 smp->rrnd, r, cfm)) in sc_passkey_round()
1494 if (memcmp(smp->pcnf, cfm, 16)) in sc_passkey_round()
1497 smp->passkey_round++; in sc_passkey_round()
1499 if (smp->passkey_round == 20) { in sc_passkey_round()
1501 if (sc_mackey_and_ltk(smp, smp->mackey, smp->tk)) in sc_passkey_round()
1510 sizeof(smp->prnd), smp->prnd); in sc_passkey_round()
1511 if (smp->passkey_round == 20) in sc_passkey_round()
1512 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_passkey_round()
1514 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in sc_passkey_round()
1519 if (smp->passkey_round != 20) in sc_passkey_round()
1520 return sc_passkey_round(smp, 0); in sc_passkey_round()
1523 sc_dhkey_check(smp); in sc_passkey_round()
1524 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_passkey_round()
1529 if (test_bit(SMP_FLAG_WAIT_USER, &smp->flags)) { in sc_passkey_round()
1530 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in sc_passkey_round()
1534 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in sc_passkey_round()
1538 sizeof(smp->prnd), smp->prnd); in sc_passkey_round()
1542 return sc_passkey_send_confirm(smp); in sc_passkey_round()
1551 smp->passkey_round + 1); in sc_passkey_round()
1553 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in sc_passkey_round()
1555 return sc_passkey_send_confirm(smp); in sc_passkey_round()
1561 static int sc_user_reply(struct smp_chan *smp, u16 mgmt_op, __le32 passkey) in sc_user_reply() argument
1563 struct l2cap_conn *conn = smp->conn; in sc_user_reply()
1567 clear_bit(SMP_FLAG_WAIT_USER, &smp->flags); in sc_user_reply()
1571 smp_failure(smp->conn, SMP_PASSKEY_ENTRY_FAILED); in sc_user_reply()
1574 smp_failure(smp->conn, SMP_NUMERIC_COMP_FAILED); in sc_user_reply()
1578 smp->passkey_round = 0; in sc_user_reply()
1580 if (test_and_clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) in sc_user_reply()
1585 if (sc_passkey_round(smp, smp_op)) in sc_user_reply()
1593 sc_dhkey_check(smp); in sc_user_reply()
1594 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in sc_user_reply()
1595 } else if (test_and_clear_bit(SMP_FLAG_DHKEY_PENDING, &smp->flags)) { in sc_user_reply()
1596 sc_dhkey_check(smp); in sc_user_reply()
1597 sc_add_ltk(smp); in sc_user_reply()
1607 struct smp_chan *smp; in smp_user_confirm_reply() local
1616 chan = conn->smp; in smp_user_confirm_reply()
1626 smp = chan->data; in smp_user_confirm_reply()
1628 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_user_confirm_reply()
1629 err = sc_user_reply(smp, mgmt_op, passkey); in smp_user_confirm_reply()
1636 memset(smp->tk, 0, sizeof(smp->tk)); in smp_user_confirm_reply()
1638 put_unaligned_le32(value, smp->tk); in smp_user_confirm_reply()
1641 set_bit(SMP_FLAG_TK_VALID, &smp->flags); in smp_user_confirm_reply()
1657 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) { in smp_user_confirm_reply()
1658 u8 rsp = smp_confirm(smp); in smp_user_confirm_reply()
1668 static void build_bredr_pairing_cmd(struct smp_chan *smp, in build_bredr_pairing_cmd() argument
1672 struct l2cap_conn *conn = smp->conn; in build_bredr_pairing_cmd()
1694 smp->remote_key_dist = remote_dist; in build_bredr_pairing_cmd()
1705 smp->remote_key_dist = rsp->init_key_dist; in build_bredr_pairing_cmd()
1711 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_req()
1713 struct smp_chan *smp; in smp_cmd_pairing_req() local
1726 smp = smp_chan_create(conn); in smp_cmd_pairing_req()
1728 smp = chan->data; in smp_cmd_pairing_req()
1730 if (!smp) in smp_cmd_pairing_req()
1743 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_cmd_pairing_req()
1744 memcpy(&smp->preq[1], req, sizeof(*req)); in smp_cmd_pairing_req()
1752 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); in smp_cmd_pairing_req()
1761 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_req()
1763 build_bredr_pairing_cmd(smp, req, &rsp); in smp_cmd_pairing_req()
1770 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_req()
1772 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_req()
1773 memcpy(&smp->prsp[1], &rsp, sizeof(rsp)); in smp_cmd_pairing_req()
1776 smp_distribute_keys(smp); in smp_cmd_pairing_req()
1783 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_req()
1797 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1807 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in smp_cmd_pairing_req()
1809 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_req()
1810 memcpy(&smp->prsp[1], &rsp, sizeof(rsp)); in smp_cmd_pairing_req()
1814 clear_bit(SMP_FLAG_INITIATOR, &smp->flags); in smp_cmd_pairing_req()
1821 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_pairing_req()
1823 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_req()
1824 SMP_ALLOW_CMD(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_pairing_req()
1826 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_req()
1839 static u8 sc_send_public_key(struct smp_chan *smp) in sc_send_public_key() argument
1841 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1845 if (test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) { in sc_send_public_key()
1854 memcpy(smp->local_pk, smp_dev->local_pk, 64); in sc_send_public_key()
1855 memcpy(smp->local_sk, smp_dev->local_sk, 32); in sc_send_public_key()
1856 memcpy(smp->lr, smp_dev->local_rand, 16); in sc_send_public_key()
1859 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_send_public_key()
1866 memcpy(smp->local_pk, debug_pk, 64); in sc_send_public_key()
1867 memcpy(smp->local_sk, debug_sk, 32); in sc_send_public_key()
1868 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in sc_send_public_key()
1872 if (!ecc_make_key(smp->local_pk, smp->local_sk)) in sc_send_public_key()
1878 if (memcmp(smp->local_sk, debug_sk, 32)) in sc_send_public_key()
1884 SMP_DBG("Local Public Key X: %32phN", smp->local_pk); in sc_send_public_key()
1885 SMP_DBG("Local Public Key Y: %32phN", smp->local_pk + 32); in sc_send_public_key()
1886 SMP_DBG("Local Private Key: %32phN", smp->local_sk); in sc_send_public_key()
1888 smp_send_cmd(smp->conn, SMP_CMD_PUBLIC_KEY, 64, smp->local_pk); in sc_send_public_key()
1896 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_rsp()
1897 struct smp_chan *smp = chan->data; in smp_cmd_pairing_rsp() local
1912 req = (void *) &smp->preq[1]; in smp_cmd_pairing_rsp()
1928 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); in smp_cmd_pairing_rsp()
1930 smp->prsp[0] = SMP_CMD_PAIRING_RSP; in smp_cmd_pairing_rsp()
1931 memcpy(&smp->prsp[1], rsp, sizeof(*rsp)); in smp_cmd_pairing_rsp()
1936 smp->remote_key_dist &= rsp->resp_key_dist; in smp_cmd_pairing_rsp()
1941 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_rsp()
1942 smp_distribute_keys(smp); in smp_cmd_pairing_rsp()
1947 set_bit(SMP_FLAG_SC, &smp->flags); in smp_cmd_pairing_rsp()
1955 method = get_auth_method(smp, req->io_capability, in smp_cmd_pairing_rsp()
1961 get_random_bytes(smp->prnd, sizeof(smp->prnd)); in smp_cmd_pairing_rsp()
1966 smp->remote_key_dist &= rsp->resp_key_dist; in smp_cmd_pairing_rsp()
1968 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_rsp()
1970 smp->remote_key_dist &= ~SMP_SC_NO_DIST; in smp_cmd_pairing_rsp()
1971 SMP_ALLOW_CMD(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_pairing_rsp()
1972 return sc_send_public_key(smp); in smp_cmd_pairing_rsp()
1981 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_cmd_pairing_rsp()
1984 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) in smp_cmd_pairing_rsp()
1985 return smp_confirm(smp); in smp_cmd_pairing_rsp()
1990 static u8 sc_check_confirm(struct smp_chan *smp) in sc_check_confirm() argument
1992 struct l2cap_conn *conn = smp->conn; in sc_check_confirm()
1996 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in sc_check_confirm()
1997 return sc_passkey_round(smp, SMP_CMD_PAIRING_CONFIRM); in sc_check_confirm()
2000 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in sc_check_confirm()
2001 smp->prnd); in sc_check_confirm()
2002 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in sc_check_confirm()
2012 static int fixup_sc_false_positive(struct smp_chan *smp) in fixup_sc_false_positive() argument
2014 struct l2cap_conn *conn = smp->conn; in fixup_sc_false_positive()
2031 req = (void *) &smp->preq[1]; in fixup_sc_false_positive()
2032 rsp = (void *) &smp->prsp[1]; in fixup_sc_false_positive()
2035 smp->remote_key_dist = (req->init_key_dist & rsp->resp_key_dist); in fixup_sc_false_positive()
2044 clear_bit(SMP_FLAG_SC, &smp->flags); in fixup_sc_false_positive()
2051 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_confirm()
2052 struct smp_chan *smp = chan->data; in smp_cmd_pairing_confirm() local
2056 if (skb->len < sizeof(smp->pcnf)) in smp_cmd_pairing_confirm()
2059 memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf)); in smp_cmd_pairing_confirm()
2060 skb_pull(skb, sizeof(smp->pcnf)); in smp_cmd_pairing_confirm()
2062 if (test_bit(SMP_FLAG_SC, &smp->flags)) { in smp_cmd_pairing_confirm()
2066 if (test_bit(SMP_FLAG_REMOTE_PK, &smp->flags)) in smp_cmd_pairing_confirm()
2067 return sc_check_confirm(smp); in smp_cmd_pairing_confirm()
2071 ret = fixup_sc_false_positive(smp); in smp_cmd_pairing_confirm()
2077 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_confirm()
2078 smp->prnd); in smp_cmd_pairing_confirm()
2079 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_pairing_confirm()
2083 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) in smp_cmd_pairing_confirm()
2084 return smp_confirm(smp); in smp_cmd_pairing_confirm()
2086 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); in smp_cmd_pairing_confirm()
2093 struct l2cap_chan *chan = conn->smp; in smp_cmd_pairing_random()
2094 struct smp_chan *smp = chan->data; in smp_cmd_pairing_random() local
2102 if (skb->len < sizeof(smp->rrnd)) in smp_cmd_pairing_random()
2105 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); in smp_cmd_pairing_random()
2106 skb_pull(skb, sizeof(smp->rrnd)); in smp_cmd_pairing_random()
2108 if (!test_bit(SMP_FLAG_SC, &smp->flags)) in smp_cmd_pairing_random()
2109 return smp_random(smp); in smp_cmd_pairing_random()
2112 pkax = smp->local_pk; in smp_cmd_pairing_random()
2113 pkbx = smp->remote_pk; in smp_cmd_pairing_random()
2114 na = smp->prnd; in smp_cmd_pairing_random()
2115 nb = smp->rrnd; in smp_cmd_pairing_random()
2117 pkax = smp->remote_pk; in smp_cmd_pairing_random()
2118 pkbx = smp->local_pk; in smp_cmd_pairing_random()
2119 na = smp->rrnd; in smp_cmd_pairing_random()
2120 nb = smp->prnd; in smp_cmd_pairing_random()
2123 if (smp->method == REQ_OOB) { in smp_cmd_pairing_random()
2126 sizeof(smp->prnd), smp->prnd); in smp_cmd_pairing_random()
2127 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2132 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in smp_cmd_pairing_random()
2133 return sc_passkey_round(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_pairing_random()
2138 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->local_pk, in smp_cmd_pairing_random()
2139 smp->rrnd, 0, cfm); in smp_cmd_pairing_random()
2143 if (memcmp(smp->pcnf, cfm, 16)) in smp_cmd_pairing_random()
2146 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), in smp_cmd_pairing_random()
2147 smp->prnd); in smp_cmd_pairing_random()
2148 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2153 err = sc_mackey_and_ltk(smp, smp->mackey, smp->tk); in smp_cmd_pairing_random()
2157 if (smp->method == JUST_WORKS || smp->method == REQ_OOB) { in smp_cmd_pairing_random()
2159 sc_dhkey_check(smp); in smp_cmd_pairing_random()
2160 SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK); in smp_cmd_pairing_random()
2165 err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); in smp_cmd_pairing_random()
2174 set_bit(SMP_FLAG_WAIT_USER, &smp->flags); in smp_cmd_pairing_random()
2232 struct smp_chan *smp; in smp_cmd_security_req() local
2262 smp = smp_chan_create(conn); in smp_cmd_security_req()
2263 if (!smp) in smp_cmd_security_req()
2275 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_cmd_security_req()
2276 memcpy(&smp->preq[1], &cp, sizeof(cp)); in smp_cmd_security_req()
2279 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in smp_cmd_security_req()
2288 struct smp_chan *smp; in smp_conn_security() local
2311 chan = conn->smp; in smp_conn_security()
2325 smp = smp_chan_create(conn); in smp_conn_security()
2326 if (!smp) { in smp_conn_security()
2347 smp->preq[0] = SMP_CMD_PAIRING_REQ; in smp_conn_security()
2348 memcpy(&smp->preq[1], &cp, sizeof(cp)); in smp_conn_security()
2351 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in smp_conn_security()
2356 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_REQ); in smp_conn_security()
2359 set_bit(SMP_FLAG_INITIATOR, &smp->flags); in smp_conn_security()
2371 struct smp_chan *smp; in smp_cancel_pairing() local
2376 chan = conn->smp; in smp_cancel_pairing()
2382 smp = chan->data; in smp_cancel_pairing()
2383 if (smp) { in smp_cancel_pairing()
2384 if (test_bit(SMP_FLAG_COMPLETE, &smp->flags)) in smp_cancel_pairing()
2396 struct l2cap_chan *chan = conn->smp; in smp_cmd_encrypt_info()
2397 struct smp_chan *smp = chan->data; in smp_cmd_encrypt_info() local
2404 SMP_ALLOW_CMD(smp, SMP_CMD_MASTER_IDENT); in smp_cmd_encrypt_info()
2408 memcpy(smp->tk, rp->ltk, sizeof(smp->tk)); in smp_cmd_encrypt_info()
2416 struct l2cap_chan *chan = conn->smp; in smp_cmd_master_ident()
2417 struct smp_chan *smp = chan->data; in smp_cmd_master_ident() local
2429 smp->remote_key_dist &= ~SMP_DIST_ENC_KEY; in smp_cmd_master_ident()
2431 if (smp->remote_key_dist & SMP_DIST_ID_KEY) in smp_cmd_master_ident()
2432 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_INFO); in smp_cmd_master_ident()
2433 else if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_cmd_master_ident()
2434 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_cmd_master_ident()
2440 authenticated, smp->tk, smp->enc_key_size, in smp_cmd_master_ident()
2442 smp->ltk = ltk; in smp_cmd_master_ident()
2443 if (!(smp->remote_key_dist & KEY_DIST_MASK)) in smp_cmd_master_ident()
2444 smp_distribute_keys(smp); in smp_cmd_master_ident()
2452 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_info()
2453 struct smp_chan *smp = chan->data; in smp_cmd_ident_info() local
2460 SMP_ALLOW_CMD(smp, SMP_CMD_IDENT_ADDR_INFO); in smp_cmd_ident_info()
2464 memcpy(smp->irk, info->irk, 16); in smp_cmd_ident_info()
2473 struct l2cap_chan *chan = conn->smp; in smp_cmd_ident_addr_info()
2474 struct smp_chan *smp = chan->data; in smp_cmd_ident_addr_info() local
2484 smp->remote_key_dist &= ~SMP_DIST_ID_KEY; in smp_cmd_ident_addr_info()
2486 if (smp->remote_key_dist & SMP_DIST_SIGN) in smp_cmd_ident_addr_info()
2487 SMP_ALLOW_CMD(smp, SMP_CMD_SIGN_INFO); in smp_cmd_ident_addr_info()
2507 bacpy(&smp->id_addr, &info->bdaddr); in smp_cmd_ident_addr_info()
2508 smp->id_addr_type = info->addr_type; in smp_cmd_ident_addr_info()
2515 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2516 smp->id_addr_type, smp->irk, &rpa); in smp_cmd_ident_addr_info()
2519 if (!(smp->remote_key_dist & KEY_DIST_MASK)) in smp_cmd_ident_addr_info()
2520 smp_distribute_keys(smp); in smp_cmd_ident_addr_info()
2528 struct l2cap_chan *chan = conn->smp; in smp_cmd_sign_info()
2529 struct smp_chan *smp = chan->data; in smp_cmd_sign_info() local
2538 smp->remote_key_dist &= ~SMP_DIST_SIGN; in smp_cmd_sign_info()
2550 smp->csrk = csrk; in smp_cmd_sign_info()
2551 smp_distribute_keys(smp); in smp_cmd_sign_info()
2556 static u8 sc_select_method(struct smp_chan *smp) in sc_select_method() argument
2558 struct l2cap_conn *conn = smp->conn; in sc_select_method()
2563 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags) || in sc_select_method()
2564 test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) in sc_select_method()
2573 local = (void *) &smp->preq[1]; in sc_select_method()
2574 remote = (void *) &smp->prsp[1]; in sc_select_method()
2576 local = (void *) &smp->prsp[1]; in sc_select_method()
2577 remote = (void *) &smp->preq[1]; in sc_select_method()
2590 method = get_auth_method(smp, local_io, remote_io); in sc_select_method()
2595 if (method == JUST_CFM && test_bit(SMP_FLAG_INITIATOR, &smp->flags)) in sc_select_method()
2605 struct l2cap_chan *chan = conn->smp; in smp_cmd_public_key()
2606 struct smp_chan *smp = chan->data; in smp_cmd_public_key() local
2616 memcpy(smp->remote_pk, key, 64); in smp_cmd_public_key()
2618 if (test_bit(SMP_FLAG_REMOTE_OOB, &smp->flags)) { in smp_cmd_public_key()
2619 err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->remote_pk, in smp_cmd_public_key()
2620 smp->rr, 0, cfm.confirm_val); in smp_cmd_public_key()
2624 if (memcmp(cfm.confirm_val, smp->pcnf, 16)) in smp_cmd_public_key()
2632 err = sc_send_public_key(smp); in smp_cmd_public_key()
2637 SMP_DBG("Remote Public Key X: %32phN", smp->remote_pk); in smp_cmd_public_key()
2638 SMP_DBG("Remote Public Key Y: %32phN", smp->remote_pk + 32); in smp_cmd_public_key()
2640 if (!ecdh_shared_secret(smp->remote_pk, smp->local_sk, smp->dhkey)) in smp_cmd_public_key()
2643 SMP_DBG("DHKey %32phN", smp->dhkey); in smp_cmd_public_key()
2645 set_bit(SMP_FLAG_REMOTE_PK, &smp->flags); in smp_cmd_public_key()
2647 smp->method = sc_select_method(smp); in smp_cmd_public_key()
2649 BT_DBG("%s selected method 0x%02x", hdev->name, smp->method); in smp_cmd_public_key()
2652 if (smp->method == JUST_WORKS || smp->method == JUST_CFM) in smp_cmd_public_key()
2657 if (!memcmp(debug_pk, smp->remote_pk, 64)) in smp_cmd_public_key()
2658 set_bit(SMP_FLAG_DEBUG_KEY, &smp->flags); in smp_cmd_public_key()
2660 if (smp->method == DSP_PASSKEY) { in smp_cmd_public_key()
2665 smp->passkey_round = 0; in smp_cmd_public_key()
2671 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2672 return sc_passkey_round(smp, SMP_CMD_PUBLIC_KEY); in smp_cmd_public_key()
2675 if (smp->method == REQ_OOB) { in smp_cmd_public_key()
2678 sizeof(smp->prnd), smp->prnd); in smp_cmd_public_key()
2680 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_public_key()
2686 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2688 if (smp->method == REQ_PASSKEY) { in smp_cmd_public_key()
2692 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_CONFIRM); in smp_cmd_public_key()
2693 set_bit(SMP_FLAG_WAIT_USER, &smp->flags); in smp_cmd_public_key()
2703 err = smp_f4(smp->tfm_cmac, smp->local_pk, smp->remote_pk, smp->prnd, in smp_cmd_public_key()
2709 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RANDOM); in smp_cmd_public_key()
2717 struct l2cap_chan *chan = conn->smp; in smp_cmd_dhkey_check()
2719 struct smp_chan *smp = chan->data; in smp_cmd_dhkey_check() local
2737 memcpy(io_cap, &smp->prsp[1], 3); in smp_cmd_dhkey_check()
2741 memcpy(io_cap, &smp->preq[1], 3); in smp_cmd_dhkey_check()
2746 if (smp->method == REQ_PASSKEY || smp->method == DSP_PASSKEY) in smp_cmd_dhkey_check()
2748 else if (smp->method == REQ_OOB) in smp_cmd_dhkey_check()
2749 memcpy(r, smp->lr, 16); in smp_cmd_dhkey_check()
2751 err = smp_f6(smp->tfm_cmac, smp->mackey, smp->rrnd, smp->prnd, r, in smp_cmd_dhkey_check()
2760 if (test_bit(SMP_FLAG_WAIT_USER, &smp->flags)) { in smp_cmd_dhkey_check()
2761 set_bit(SMP_FLAG_DHKEY_PENDING, &smp->flags); in smp_cmd_dhkey_check()
2766 sc_dhkey_check(smp); in smp_cmd_dhkey_check()
2769 sc_add_ltk(smp); in smp_cmd_dhkey_check()
2772 hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size); in smp_cmd_dhkey_check()
2773 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2793 struct smp_chan *smp; in smp_sig_channel() local
2808 smp = chan->data; in smp_sig_channel()
2813 if (smp && !test_and_clear_bit(code, &smp->allow_cmd)) in smp_sig_channel()
2819 if (!smp && code != SMP_CMD_PAIRING_REQ && code != SMP_CMD_SECURITY_REQ) in smp_sig_channel()
2911 conn->smp = NULL; in smp_teardown_cb()
2921 struct smp_chan *smp; in bredr_pairing() local
2962 smp = smp_chan_create(conn); in bredr_pairing()
2963 if (!smp) { in bredr_pairing()
2969 set_bit(SMP_FLAG_SC, &smp->flags); in bredr_pairing()
2974 build_bredr_pairing_cmd(smp, &req, NULL); in bredr_pairing()
2976 smp->preq[0] = SMP_CMD_PAIRING_REQ; in bredr_pairing()
2977 memcpy(&smp->preq[1], &req, sizeof(req)); in bredr_pairing()
2980 SMP_ALLOW_CMD(smp, SMP_CMD_PAIRING_RSP); in bredr_pairing()
2985 struct smp_chan *smp = chan->data; in smp_resume_cb() local
2996 if (!smp) in smp_resume_cb()
3002 cancel_delayed_work(&smp->security_timer); in smp_resume_cb()
3004 smp_distribute_keys(smp); in smp_resume_cb()
3020 conn->smp = chan; in smp_ready_cb()
3034 struct smp_chan *smp = chan->data; in smp_recv_cb() local
3036 if (smp) in smp_recv_cb()
3037 cancel_delayed_work_sync(&smp->security_timer); in smp_recv_cb()
3129 struct smp_dev *smp; in smp_add_cid() local
3134 smp = NULL; in smp_add_cid()
3138 smp = kzalloc(sizeof(*smp), GFP_KERNEL); in smp_add_cid()
3139 if (!smp) in smp_add_cid()
3145 kzfree(smp); in smp_add_cid()
3153 kzfree(smp); in smp_add_cid()
3157 smp->tfm_aes = tfm_aes; in smp_add_cid()
3158 smp->tfm_cmac = tfm_cmac; in smp_add_cid()
3159 smp->min_key_size = SMP_MIN_ENC_KEY_SIZE; in smp_add_cid()
3160 smp->max_key_size = SMP_MAX_ENC_KEY_SIZE; in smp_add_cid()
3165 if (smp) { in smp_add_cid()
3166 crypto_free_blkcipher(smp->tfm_aes); in smp_add_cid()
3167 crypto_free_hash(smp->tfm_cmac); in smp_add_cid()
3168 kzfree(smp); in smp_add_cid()
3173 chan->data = smp; in smp_add_cid()
3206 struct smp_dev *smp; in smp_del_chan() local
3210 smp = chan->data; in smp_del_chan()
3211 if (smp) { in smp_del_chan()
3213 if (smp->tfm_aes) in smp_del_chan()
3214 crypto_free_blkcipher(smp->tfm_aes); in smp_del_chan()
3215 if (smp->tfm_cmac) in smp_del_chan()
3216 crypto_free_hash(smp->tfm_cmac); in smp_del_chan()
3217 kzfree(smp); in smp_del_chan()