/** ***************************************************************************************** * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved. ***************************************************************************************** * @file gap_privacy.h * @brief This file contains all the functions prototypes for the GAP bond and pairing * related functions. * @details * @author ranhui * @date 2016-02-18 * @version v1.0 * ************************************************************************************* */ /*============================================================================* * Define to prevent recursive inclusion *============================================================================*/ #ifndef GAP_PRIVACY_H #define GAP_PRIVACY_H #ifdef __cplusplus extern "C" { #endif /*============================================================================* * Header Files *============================================================================*/ #include "upperstack_config.h" #include "gap_le.h" #include "gap_conn_le.h" #include "gap_storage_le.h" #if F_BT_LE_PRIVACY_SUPPORT /** @defgroup GAP_PRIVACY_MODULE GAP LE Privacy * @brief GAP LE privacy * @{ */ /*============================================================================* * Types *============================================================================*/ /** @defgroup Gap_Privacy_Exported_Types GAP Privacy Exported Types * @{ */ /** @brief Define the privacy callback type */ #define GAP_MSG_LE_PRIVACY_RESOLUTION_STATUS_INFO 0x00 //! Use gap defualt callback function. * @arg Other -> Use application defined callback function. * @return none */ void le_privacy_register_cb(P_FUN_PRIVACY_CB p_privacy_cb); /** * @brief Enable/disable le privacy address resolution mode. * @param[in] enable Enable or disable address resolution. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_set_addr_resolution(bool enable); /** * @brief Read peer resolvable random address. * @param[in] peer_identity_address_type Peer identity address type. * @param[in] peer_identity_address Peer identity address. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_read_peer_resolv_addr(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type, uint8_t *peer_identity_address); /** * @brief Read local resolvable random address. * @param[in] peer_identity_address_type Peer identity address type. * @param[in] peer_identity_address Peer identity address. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_read_local_resolv_addr(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type, uint8_t *peer_identity_address); /** * @brief Set resolvable private address timeout. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_set_resolv_priv_addr_timeout(void); /** * @brief Modicy local resolvable device list. * NOTE: You can call this function to add, remove or clear the resolvable list * * When the default value of @ref gap_config_local_addr_storage is true or * @ref gap_config_local_addr_storage (true) has been configured and operation * equals @ref GAP_RESOLV_LIST_OP_ADD, this function cannot be used if local * device uses different local addresses to bond with the same remote device. * In this situation, @ref le_privacy_add_resolv_list shall be called. * * @param[in] operation type, @ref T_GAP_RESOLV_LIST_OP. * @param[in] peer_identity_address_type Peer identity address type. * @param[in] peer_identity_address Peer identity address. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_modify_resolv_list(T_GAP_RESOLV_LIST_OP operation, T_GAP_IDENT_ADDR_TYPE peer_identity_address_type, uint8_t *peer_identity_address); /** * @brief Add device to local resolving list. * * @param[in] peer_identity_address_type Peer identity address type. * @param[in] peer_identity_address Peer identity address. * @param[in] peer_irk Pointer to peer IRK (16 octets). Note: NULL: no peer IRK, use all-zero IRK. * @param[in] use_local_irk Indicates whether local IRK has been distributed to peer device. False: local IRK has not been distributed to peer device True: local IRK has been distributed to peer device. * @return Operation result. * @retval GAP_CAUSE_SUCCESS Operation success. * @retval Others Operation failure. */ T_GAP_CAUSE le_privacy_add_resolv_list(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type, uint8_t *peer_identity_address, uint8_t *peer_irk, bool use_local_irk); /** * @brief Set privacy mode. * @param[in] peer_identity_address_type Peer identity address type. * @param[in] peer_identity_address Peer identity address. * @param[in] privacy_mode Privacy mode @ref T_GAP_PRIVACY_MODE. * @return Operation result * @retval GAP_CAUSE_SUCCESS Operation success. * @retval GAP_CAUSE_SEND_REQ_FAILED Operation failure. */ T_GAP_CAUSE le_privacy_set_mode(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type, uint8_t *peer_identity_address, T_GAP_PRIVACY_MODE privacy_mode); /** * @brief Convert remote bluetooth device address type to identity address type. * @param[in] type Bluetooth device address type @ref T_GAP_REMOTE_ADDR_TYPE. * @return Identity address type @ref T_GAP_IDENT_ADDR_TYPE * @retval GAP_IDENT_ADDR_PUBLIC Public identity address. * @retval GAP_IDENT_ADDR_RAND Random identity address. */ T_GAP_IDENT_ADDR_TYPE le_privacy_convert_addr_type(T_GAP_REMOTE_ADDR_TYPE type); #endif /** * @brief Check if a given Resolvable Private Address (RPA) can be resolved using a specified Identity Resolving Key (IRK). * * This function determines if a provided Resolvable Private Address (RPA) associated with Bluetooth Low Energy (BLE) privacy * mechanisms can be resolved using the specified Identity Resolving Key (IRK). It achieves this by utilizing encryption and * comparison methods as defined in the Bluetooth specification for privacy address resolution. * * @param[in] rpa Pointer to a 6-byte Resolvable Private Address that needs to be resolved. This address is typically a random * address generated for privacy protection during BLE operations. * @param[in] irk Pointer to a 16-byte Identity Resolving Key used for resolving the Resolvable Private Address. * * @return Check result. * @retval true The Resolvable Private Address matches the IRK and successfully resolves. This indicates that the provided RPA * is associated with the given IRK and should be accepted as a legitimate identity. * @retval false The Resolvable Private Address does not match the IRK and fails to resolve. This means that the RPA is either * not associated with the given IRK or could not be resolved, indicating it is not recognized as a valid identity * with the provided key. */ bool le_privacy_check_resolvable_private_address(uint8_t *rpa, uint8_t *irk); /** @} */ /* End of group Gap_Privacy_Exported_Functions */ /** @} */ /* End of group GAP_PRIVACY_MODULE */ #ifdef __cplusplus } #endif #endif /* GAP_PRIVACY_H */