/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/******************************************************************************
*
* This file contains functions for the Bluetooth Security Manager
*
******************************************************************************/
#define LOG_TAG "bt_btm_sec"
#include <stdarg.h>
#include <string.h>
#include "bt_types.h"
#include "device/include/controller.h"
#include "hcimsgs.h"
#include "btu.h"
#include "btm_int.h"
#include "l2c_int.h"
#include "bt_utils.h"
#include "osi/include/log.h"
#if (BT_USE_TRACES == TRUE && BT_TRACE_VERBOSE == FALSE)
/* needed for sprintf() */
#include <stdio.h>
#endif
#if BLE_INCLUDED == TRUE
#include "gatt_int.h"
#endif
#define BTM_SEC_MAX_COLLISION_DELAY (5000)
#ifdef APPL_AUTH_WRITE_EXCEPTION
BOOLEAN (APPL_AUTH_WRITE_EXCEPTION)(BD_ADDR bd_addr);
#endif
/********************************************************************************
** L O C A L F U N C T I O N P R O T O T Y P E S *
*********************************************************************************/
static tBTM_SEC_SERV_REC *btm_sec_find_first_serv (BOOLEAN is_originator, UINT16 psm);
static tBTM_SEC_SERV_REC *btm_sec_find_next_serv (tBTM_SEC_SERV_REC *p_cur);
static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm,
UINT32 mx_proto_id,
UINT32 mx_chan_id);
static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec);
static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle);
static void btm_restore_mode(void);
static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle);
static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec);
static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state);
#if (BT_USE_TRACES == TRUE)
static char *btm_pair_state_descr (tBTM_PAIRING_STATE state);
#endif
static void btm_sec_check_pending_reqs(void);
static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_orig,
UINT32 mx_proto_id, UINT32 mx_chan_id,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
static void btm_sec_bond_cancel_complete (void);
static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec);
static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec);
BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[]);
static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 reason, UINT16 conn_handle);
UINT8 btm_sec_start_role_switch (tBTM_SEC_DEV_REC *p_dev_rec);
tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state);
static BOOLEAN btm_sec_set_security_level ( CONNECTION_TYPE conn_type, char *p_name, UINT8 service_id,
UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id);
static BOOLEAN btm_dev_authenticated(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_dev_encrypted(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_dev_authorized(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC *p_serv_rec);
static BOOLEAN btm_sec_is_serv_level0 (UINT16 psm);
static UINT16 btm_sec_set_serv_level4_flags (UINT16 cur_security, BOOLEAN is_originator);
static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT transport,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
static void btm_sec_clean_pending_req_queue (BD_ADDR remote_bda, tBT_TRANSPORT transport) ;
static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport,
UINT8 encr_enable);
static BOOLEAN btm_sec_acceptor_rejects_bonding (tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec);
static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec);
/* TRUE - authenticated link key is possible */
static const BOOLEAN btm_sec_io_map [BTM_IO_CAP_MAX][BTM_IO_CAP_MAX] =
{
/* OUT, IO, IN, NONE */
/* OUT */ {FALSE, FALSE, TRUE, FALSE},
/* IO */ {FALSE, TRUE, TRUE, FALSE},
/* IN */ {TRUE, TRUE, TRUE, FALSE},
/* NONE */ {FALSE, FALSE, FALSE, FALSE}
};
/* BTM_IO_CAP_OUT 0 DisplayOnly */
/* BTM_IO_CAP_IO 1 DisplayYesNo */
/* BTM_IO_CAP_IN 2 KeyboardOnly */
/* BTM_IO_CAP_NONE 3 NoInputNoOutput */
/*******************************************************************************
**
** Function btm_dev_authenticated
**
** Description check device is authenticated
**
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
static BOOLEAN btm_dev_authenticated (tBTM_SEC_DEV_REC *p_dev_rec)
{
if(p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)
{
return(TRUE);
}
return(FALSE);
}
/*******************************************************************************
**
** Function btm_dev_encrypted
**
** Description check device is encrypted
**
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
static BOOLEAN btm_dev_encrypted (tBTM_SEC_DEV_REC *p_dev_rec)
{
if(p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED)
{
return(TRUE);
}
return(FALSE);
}
/*******************************************************************************
**
** Function btm_dev_authorized
**
** Description check device is authorized
**
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
static BOOLEAN btm_dev_authorized (tBTM_SEC_DEV_REC *p_dev_rec)
{
if(p_dev_rec->sec_flags & BTM_SEC_AUTHORIZED)
{
return(TRUE);
}
return(FALSE);
}
/*******************************************************************************
**
** Function btm_dev_16_digit_authenticated
**
** Description check device is authenticated by using 16 digit pin or MITM
**
** Returns BOOLEAN TRUE or FALSE
**
*******************************************************************************/
static BOOLEAN btm_dev_16_digit_authenticated(tBTM_SEC_DEV_REC *p_dev_rec)
{
// BTM_SEC_16_DIGIT_PIN_AUTHED is set if MITM or 16 digit pin is used
if(p_dev_rec->sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED)
{
return(TRUE);
}
return(FALSE);
}
/*******************************************************************************
**
** Function btm_serv_trusted
**
** Description check service is trusted
**
** Returns BOOLEAN TRUE or FALSE
**
******************************************
没有合适的资源?快使用搜索试试~ 我知道了~
ard6-r1 system.rar
共2000个文件
h:775个
c:579个
cpp:438个
需积分: 0 0 下载量 98 浏览量
2024-01-31
22:37:48
上传
评论
收藏 5.6MB RAR 举报
温馨提示
ard6_r1 system
资源推荐
资源详情
资源评论
收起资源包目录
ard6-r1 system.rar (2000个子文件)
km1_sw_rsa_512.blob 486B
km1_sw_rsa_512_unversioned.blob 477B
km0_sw_rsa_512.blob 333B
km1_sw_ecdsa_256.blob 270B
boot_signer 193B
btm_sec.c 248KB
bta_dm_act.c 202KB
btif_hl.c 180KB
btm_ble_gap.c 126KB
cryptfs.c 118KB
l2c_utils.c 117KB
btif_dm.c 116KB
bta_hl_utils.c 109KB
btm_inq.c 106KB
bta_av_aact.c 105KB
bta_hh_le.c 104KB
bta_hl_act.c 97KB
camera_metadata_tag_info.c 95KB
btm_ble.c 92KB
btif_gatt_client.c 89KB
l2c_fcr.c 88KB
btif_media_task.c 88KB
btm_acl.c 87KB
bta_jv_act.c 86KB
gatt_utils.c 83KB
smp_act.c 79KB
bta_gattc_act.c 78KB
bta_hl_main.c 77KB
smp_keys.c 76KB
avdt_scb_act.c 72KB
bta_dm_api.c 71KB
bta_av_act.c 70KB
l2c_api.c 68KB
btif_rc.c 66KB
btif_hh.c 64KB
avdt_msg.c 63KB
sdcard.c 62KB
bta_av_co.c 62KB
btif_storage.c 62KB
btm_sco.c 62KB
bta_ag_sco.c 59KB
bta_ag_cmd.c 58KB
bta_gattc_cache.c 58KB
port_api.c 57KB
gatt_api.c 55KB
btif_hf.c 55KB
smp_utils.c 55KB
ocb.c 54KB
btu_hcif.c 54KB
l2c_link.c 54KB
l2c_csm.c 53KB
sbc_analysis.c 53KB
gatt_sr.c 52KB
avdt_api.c 49KB
bta_av_main.c 48KB
btif_av.c 48KB
btm_ble_adv_filter.c 48KB
p256_ec.c 47KB
hcicmds.c 45KB
avdt_scb.c 45KB
sdp_api.c 45KB
bta_hf_client_at.c 44KB
btif_core.c 44KB
bnep_utils.c 44KB
gatt_db.c 43KB
avrc_api.c 43KB
gatt_cl.c 42KB
smp_main.c 42KB
bta_hh_act.c 42KB
bta_jv_api.c 41KB
bta_dm_pm.c 41KB
l2c_ble.c 40KB
gap_conn.c 40KB
bta_gattc_api.c 39KB
gatt_main.c 39KB
l2c_ucd.c 38KB
btm_ble_batchscan.c 37KB
hidh_conn.c 37KB
newfs_msdos.c 36KB
audio_a2dp_hw.c 36KB
btif_sock_l2cap.c 36KB
port_rfc.c 36KB
rsa_test.c 36KB
l2c_main.c 36KB
avdt_ccb_act.c 35KB
bta_ag_main.c 35KB
sdp_db.c 35KB
lookup3.c 35KB
camera_metadata.c 34KB
sdp_discovery.c 34KB
btm_ble_privacy.c 33KB
btm_devctl.c 33KB
btif_hf_client.c 32KB
mca_api.c 32KB
bta_gatts_act.c 32KB
logprint.c 32KB
aes.c 32KB
sdp_server.c 32KB
btm_pm.c 31KB
btm_ble_multi_adv.c 30KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Its_MyLife
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功