The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_TY51822R3/TOOLCHAIN_IAR/security_dispatcher.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2015 Nordic Semiconductor ASA |
AnnaBridge | 143:86740a56073b | 3 | * All rights reserved. |
AnnaBridge | 143:86740a56073b | 4 | * |
AnnaBridge | 143:86740a56073b | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 143:86740a56073b | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 143:86740a56073b | 7 | * |
AnnaBridge | 143:86740a56073b | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 143:86740a56073b | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 143:86740a56073b | 10 | * |
AnnaBridge | 143:86740a56073b | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
AnnaBridge | 143:86740a56073b | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
AnnaBridge | 143:86740a56073b | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
AnnaBridge | 143:86740a56073b | 14 | * the documentation and/or other materials provided with the distribution. |
AnnaBridge | 143:86740a56073b | 15 | * |
AnnaBridge | 143:86740a56073b | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
AnnaBridge | 143:86740a56073b | 17 | * used to endorse or promote products derived from this software without specific prior |
AnnaBridge | 143:86740a56073b | 18 | * written permission. |
AnnaBridge | 143:86740a56073b | 19 | * |
AnnaBridge | 143:86740a56073b | 20 | * 4. This software, with or without modification, must only be used with a |
AnnaBridge | 143:86740a56073b | 21 | * Nordic Semiconductor ASA integrated circuit. |
AnnaBridge | 143:86740a56073b | 22 | * |
AnnaBridge | 143:86740a56073b | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
AnnaBridge | 143:86740a56073b | 24 | * engineered, decompiled, modified and/or disassembled. |
AnnaBridge | 143:86740a56073b | 25 | * |
AnnaBridge | 143:86740a56073b | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 143:86740a56073b | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 143:86740a56073b | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 143:86740a56073b | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 143:86740a56073b | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 143:86740a56073b | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 143:86740a56073b | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 143:86740a56073b | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 143:86740a56073b | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 143:86740a56073b | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 143:86740a56073b | 36 | * |
AnnaBridge | 143:86740a56073b | 37 | */ |
AnnaBridge | 143:86740a56073b | 38 | |
AnnaBridge | 143:86740a56073b | 39 | |
AnnaBridge | 143:86740a56073b | 40 | |
AnnaBridge | 143:86740a56073b | 41 | #ifndef SECURITY_DISPATCHER_H__ |
AnnaBridge | 143:86740a56073b | 42 | #define SECURITY_DISPATCHER_H__ |
AnnaBridge | 143:86740a56073b | 43 | |
AnnaBridge | 143:86740a56073b | 44 | #include <stdint.h> |
AnnaBridge | 143:86740a56073b | 45 | #include "sdk_errors.h" |
AnnaBridge | 143:86740a56073b | 46 | #include "nrf_ble.h" |
AnnaBridge | 143:86740a56073b | 47 | #include "nrf_ble_gap.h" |
AnnaBridge | 143:86740a56073b | 48 | #include "peer_manager_types.h" |
AnnaBridge | 143:86740a56073b | 49 | |
AnnaBridge | 143:86740a56073b | 50 | |
AnnaBridge | 143:86740a56073b | 51 | /** |
AnnaBridge | 143:86740a56073b | 52 | * @cond NO_DOXYGEN |
AnnaBridge | 143:86740a56073b | 53 | * @defgroup security_dispatcher Security Dispatcher |
AnnaBridge | 143:86740a56073b | 54 | * @ingroup peer_manager |
AnnaBridge | 143:86740a56073b | 55 | * @{ |
AnnaBridge | 143:86740a56073b | 56 | * @brief An internal module of @ref peer_manager. A module for streamlining pairing, bonding, and |
AnnaBridge | 143:86740a56073b | 57 | * encryption, including flash storage of shared data. |
AnnaBridge | 143:86740a56073b | 58 | * |
AnnaBridge | 143:86740a56073b | 59 | */ |
AnnaBridge | 143:86740a56073b | 60 | |
AnnaBridge | 143:86740a56073b | 61 | |
AnnaBridge | 143:86740a56073b | 62 | /**@brief Events that can come from the Security Dispatcher module. |
AnnaBridge | 143:86740a56073b | 63 | */ |
AnnaBridge | 143:86740a56073b | 64 | typedef enum |
AnnaBridge | 143:86740a56073b | 65 | { |
AnnaBridge | 143:86740a56073b | 66 | SMD_EVT_PARAMS_REQ, /**< Parameters are required for a pairing procedure on the specified connection. The user must provide them using @ref smd_params_reply. */ |
AnnaBridge | 143:86740a56073b | 67 | SMD_EVT_SLAVE_SECURITY_REQ, /**< The peer (slave) has requested link encryption. Call @ref smd_link_secure to honor the request. The data in the event structure must be used in the parameters. */ |
AnnaBridge | 143:86740a56073b | 68 | SMD_EVT_SEC_PROCEDURE_START, /**< A security procedure has started. */ |
AnnaBridge | 143:86740a56073b | 69 | SMD_EVT_PAIRING_SUCCESS, /**< A pairing procedure (and bonding if applicable) has completed with success. */ |
AnnaBridge | 143:86740a56073b | 70 | SMD_EVT_PAIRING_FAIL, /**< A pairing procedure has failed which means no encryption and no bond could be established. */ |
AnnaBridge | 143:86740a56073b | 71 | SMD_EVT_LINK_ENCRYPTION_UPDATE, /**< The security level of the link has been updated. The link is encrypted. */ |
AnnaBridge | 143:86740a56073b | 72 | SMD_EVT_LINK_ENCRYPTION_FAILED, /**< An attempt to start encryption on an unencrypted link failed because the peripheral did not have the correct keys. If the peer is the peripheral, the force_repairing flag should be set when reattempting @ref smd_link_secure. */ |
AnnaBridge | 143:86740a56073b | 73 | SMD_EVT_BONDING_INFO_STORED, /**< Information exchanged during bonding with a peer has been stored persistently. */ |
AnnaBridge | 143:86740a56073b | 74 | SMD_EVT_ERROR_BONDING_INFO, /**< Information exchanged during bonding with a peer could not be stored persistently, because of an unexpected error. */ |
AnnaBridge | 143:86740a56073b | 75 | // SMD_EVT_ERROR_NO_MEM, /**< An operation failed because there was no available storage room in persistent storage. Please free up room, and the operation will automatically continue. */ |
AnnaBridge | 143:86740a56073b | 76 | SMD_EVT_ERROR_UNEXPECTED, /**< An operation failed with an unexpected error. The error is provided. This is possibly a fatal error. */ |
AnnaBridge | 143:86740a56073b | 77 | } smd_evt_id_t; |
AnnaBridge | 143:86740a56073b | 78 | |
AnnaBridge | 143:86740a56073b | 79 | |
AnnaBridge | 143:86740a56073b | 80 | /**@brief Events parameters specific to the @ref SMD_EVT_SLAVE_SECURITY_REQ event. |
AnnaBridge | 143:86740a56073b | 81 | */ |
AnnaBridge | 143:86740a56073b | 82 | typedef struct |
AnnaBridge | 143:86740a56073b | 83 | { |
AnnaBridge | 143:86740a56073b | 84 | bool bond; |
AnnaBridge | 143:86740a56073b | 85 | bool mitm; |
AnnaBridge | 143:86740a56073b | 86 | } smd_evt_slave_security_req_t; |
AnnaBridge | 143:86740a56073b | 87 | |
AnnaBridge | 143:86740a56073b | 88 | |
AnnaBridge | 143:86740a56073b | 89 | /**@brief Events parameters specific to the @ref SMD_EVT_SEC_PROCEDURE_START event. |
AnnaBridge | 143:86740a56073b | 90 | */ |
AnnaBridge | 143:86740a56073b | 91 | typedef struct |
AnnaBridge | 143:86740a56073b | 92 | { |
AnnaBridge | 143:86740a56073b | 93 | pm_conn_sec_procedure_t procedure; /**< The procedure that has started. */ |
AnnaBridge | 143:86740a56073b | 94 | } smd_evt_sec_procedure_start_t; |
AnnaBridge | 143:86740a56073b | 95 | |
AnnaBridge | 143:86740a56073b | 96 | |
AnnaBridge | 143:86740a56073b | 97 | /**@brief Events parameters specific to the @ref SMD_EVT_PAIRING_SUCCESS event. |
AnnaBridge | 143:86740a56073b | 98 | */ |
AnnaBridge | 143:86740a56073b | 99 | typedef struct |
AnnaBridge | 143:86740a56073b | 100 | { |
AnnaBridge | 143:86740a56073b | 101 | bool bonded; /**< Whether bonding was performed. */ |
AnnaBridge | 143:86740a56073b | 102 | bool mitm; /**< Whether MITM protection was used during pairing. */ |
AnnaBridge | 143:86740a56073b | 103 | ble_gap_sec_kdist_t kdist_own; /**< Which keys were distributed to the peer. Only relevant if bonding was performed. */ |
AnnaBridge | 143:86740a56073b | 104 | ble_gap_sec_kdist_t kdist_peer; /**< Which keys were distributed by the peer. Only relevant if bonding was performed. */ |
AnnaBridge | 143:86740a56073b | 105 | } smd_evt_pairing_success_t; |
AnnaBridge | 143:86740a56073b | 106 | |
AnnaBridge | 143:86740a56073b | 107 | |
AnnaBridge | 143:86740a56073b | 108 | /**@brief Events parameters specific to the @ref SMD_EVT_PAIRING_FAIL event. |
AnnaBridge | 143:86740a56073b | 109 | */ |
AnnaBridge | 143:86740a56073b | 110 | typedef struct |
AnnaBridge | 143:86740a56073b | 111 | { |
AnnaBridge | 143:86740a56073b | 112 | pm_sec_error_code_t error; /**< What went wrong. */ |
AnnaBridge | 143:86740a56073b | 113 | uint8_t error_src; /**< The party that raised the error, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ |
AnnaBridge | 143:86740a56073b | 114 | } smd_evt_pairing_failed_t; |
AnnaBridge | 143:86740a56073b | 115 | |
AnnaBridge | 143:86740a56073b | 116 | |
AnnaBridge | 143:86740a56073b | 117 | /**@brief Events parameters specific to the @ref SMD_EVT_LINK_ENCRYPTION_UPDATE event. |
AnnaBridge | 143:86740a56073b | 118 | */ |
AnnaBridge | 143:86740a56073b | 119 | typedef struct |
AnnaBridge | 143:86740a56073b | 120 | { |
AnnaBridge | 143:86740a56073b | 121 | bool mitm_protected; /**< Whether the link is now MITM protected. */ |
AnnaBridge | 143:86740a56073b | 122 | } smd_evt_link_encryption_update_t; |
AnnaBridge | 143:86740a56073b | 123 | |
AnnaBridge | 143:86740a56073b | 124 | |
AnnaBridge | 143:86740a56073b | 125 | /**@brief Events parameters specific to the @ref SMD_EVT_LINK_ENCRYPTION_FAILED event. |
AnnaBridge | 143:86740a56073b | 126 | */ |
AnnaBridge | 143:86740a56073b | 127 | typedef struct |
AnnaBridge | 143:86740a56073b | 128 | { |
AnnaBridge | 143:86740a56073b | 129 | pm_sec_error_code_t error; /**< What went wrong. */ |
AnnaBridge | 143:86740a56073b | 130 | uint8_t error_src; /**< The party that raised the error, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ |
AnnaBridge | 143:86740a56073b | 131 | } smd_evt_link_encryption_failed_t; |
AnnaBridge | 143:86740a56073b | 132 | |
AnnaBridge | 143:86740a56073b | 133 | |
AnnaBridge | 143:86740a56073b | 134 | /**@brief Events parameters specific to the @ref SMD_EVT_BONDING_INFO_STORED event. |
AnnaBridge | 143:86740a56073b | 135 | */ |
AnnaBridge | 143:86740a56073b | 136 | typedef struct |
AnnaBridge | 143:86740a56073b | 137 | { |
AnnaBridge | 143:86740a56073b | 138 | pm_peer_id_t peer_id; /**< The peer this event pertains to. */ |
AnnaBridge | 143:86740a56073b | 139 | } smd_evt_bonding_info_stored_t; |
AnnaBridge | 143:86740a56073b | 140 | |
AnnaBridge | 143:86740a56073b | 141 | |
AnnaBridge | 143:86740a56073b | 142 | /**@brief Events parameters specific to the @ref SMD_EVT_ERROR_BONDING_INFO event. |
AnnaBridge | 143:86740a56073b | 143 | */ |
AnnaBridge | 143:86740a56073b | 144 | typedef struct |
AnnaBridge | 143:86740a56073b | 145 | { |
AnnaBridge | 143:86740a56073b | 146 | pm_peer_id_t peer_id; /**< The peer this event pertains to, if previously bonded. @ref PM_PEER_ID_INVALID if no successful bonding has happened with the peer before. */ |
AnnaBridge | 143:86740a56073b | 147 | ret_code_t error; /**< The unexpected error that occurred. */ |
AnnaBridge | 143:86740a56073b | 148 | } smd_evt_error_bonding_info_t; |
AnnaBridge | 143:86740a56073b | 149 | |
AnnaBridge | 143:86740a56073b | 150 | |
AnnaBridge | 143:86740a56073b | 151 | // typedef struct |
AnnaBridge | 143:86740a56073b | 152 | // { |
AnnaBridge | 143:86740a56073b | 153 | // pm_peer_id_t peer_id; /**< The peer this event pertains to. */ |
AnnaBridge | 143:86740a56073b | 154 | // } smd_evt_error_no_mem_t; |
AnnaBridge | 143:86740a56073b | 155 | |
AnnaBridge | 143:86740a56073b | 156 | |
AnnaBridge | 143:86740a56073b | 157 | /**@brief Events parameters specific to the @ref SMD_EVT_ERROR_UNEXPECTED event. |
AnnaBridge | 143:86740a56073b | 158 | */ |
AnnaBridge | 143:86740a56073b | 159 | typedef struct |
AnnaBridge | 143:86740a56073b | 160 | { |
AnnaBridge | 143:86740a56073b | 161 | ret_code_t error; /**< The unexpected error that occurred. */ |
AnnaBridge | 143:86740a56073b | 162 | } smd_evt_error_unexpected_t; |
AnnaBridge | 143:86740a56073b | 163 | |
AnnaBridge | 143:86740a56073b | 164 | |
AnnaBridge | 143:86740a56073b | 165 | typedef union |
AnnaBridge | 143:86740a56073b | 166 | { |
AnnaBridge | 143:86740a56073b | 167 | smd_evt_slave_security_req_t slave_security_req; |
AnnaBridge | 143:86740a56073b | 168 | smd_evt_sec_procedure_start_t sec_procedure_start; |
AnnaBridge | 143:86740a56073b | 169 | smd_evt_pairing_success_t pairing_success; |
AnnaBridge | 143:86740a56073b | 170 | smd_evt_pairing_failed_t pairing_failed; |
AnnaBridge | 143:86740a56073b | 171 | smd_evt_link_encryption_update_t link_encryption_update; |
AnnaBridge | 143:86740a56073b | 172 | smd_evt_link_encryption_failed_t link_encryption_failed; |
AnnaBridge | 143:86740a56073b | 173 | smd_evt_bonding_info_stored_t bonding_info_stored; |
AnnaBridge | 143:86740a56073b | 174 | smd_evt_error_bonding_info_t error_bonding_info; |
AnnaBridge | 143:86740a56073b | 175 | // smd_evt_error_no_mem_t error_no_mem; |
AnnaBridge | 143:86740a56073b | 176 | smd_evt_error_unexpected_t error_unexpected; |
AnnaBridge | 143:86740a56073b | 177 | } smd_evt_params_t; /**< Event specific parameters. Chosen based on evt_id. */ |
AnnaBridge | 143:86740a56073b | 178 | |
AnnaBridge | 143:86740a56073b | 179 | |
AnnaBridge | 143:86740a56073b | 180 | /**@brief Structure describing events from the Security Dispatcher module. |
AnnaBridge | 143:86740a56073b | 181 | */ |
AnnaBridge | 143:86740a56073b | 182 | typedef struct |
AnnaBridge | 143:86740a56073b | 183 | { |
AnnaBridge | 143:86740a56073b | 184 | smd_evt_id_t evt_id; /**< The type of event. */ |
AnnaBridge | 143:86740a56073b | 185 | uint16_t conn_handle; /**< The connection this event pertains to. */ |
AnnaBridge | 143:86740a56073b | 186 | smd_evt_params_t params; /**< Event specific parameters. Chosen based on evt_id. */ |
AnnaBridge | 143:86740a56073b | 187 | } smd_evt_t; |
AnnaBridge | 143:86740a56073b | 188 | |
AnnaBridge | 143:86740a56073b | 189 | |
AnnaBridge | 143:86740a56073b | 190 | |
AnnaBridge | 143:86740a56073b | 191 | /**@brief Event handler for events from the Security Dispatcher module. |
AnnaBridge | 143:86740a56073b | 192 | * |
AnnaBridge | 143:86740a56073b | 193 | * @param[in] p_event The event that has happened. |
AnnaBridge | 143:86740a56073b | 194 | */ |
AnnaBridge | 143:86740a56073b | 195 | typedef void (*smd_evt_handler_t)(smd_evt_t const * p_event); |
AnnaBridge | 143:86740a56073b | 196 | |
AnnaBridge | 143:86740a56073b | 197 | |
AnnaBridge | 143:86740a56073b | 198 | /**@brief Function for registering with the Security Dispatcher module. This function also |
AnnaBridge | 143:86740a56073b | 199 | * initializes the module if uninitialized. |
AnnaBridge | 143:86740a56073b | 200 | * |
AnnaBridge | 143:86740a56073b | 201 | * @param[in] evt_handler Callback for events from the Security Dispatcher module. |
AnnaBridge | 143:86740a56073b | 202 | * |
AnnaBridge | 143:86740a56073b | 203 | * @retval NRF_SUCCESS Registration was successful. |
AnnaBridge | 143:86740a56073b | 204 | * @retval NRF_ERROR_NO_MEM No more registrations possible. |
AnnaBridge | 143:86740a56073b | 205 | * @retval NRF_ERROR_NULL evt_handler was NULL. |
AnnaBridge | 143:86740a56073b | 206 | */ |
AnnaBridge | 143:86740a56073b | 207 | ret_code_t smd_register(smd_evt_handler_t evt_handler); |
AnnaBridge | 143:86740a56073b | 208 | |
AnnaBridge | 143:86740a56073b | 209 | |
AnnaBridge | 143:86740a56073b | 210 | /**@brief Function for dispatching SoftDevice events to the Security Dispatcher module. |
AnnaBridge | 143:86740a56073b | 211 | * |
AnnaBridge | 143:86740a56073b | 212 | * @param[in] ble_evt The SoftDevice event. |
AnnaBridge | 143:86740a56073b | 213 | */ |
AnnaBridge | 143:86740a56073b | 214 | void smd_ble_evt_handler(ble_evt_t * ble_evt); |
AnnaBridge | 143:86740a56073b | 215 | |
AnnaBridge | 143:86740a56073b | 216 | |
AnnaBridge | 143:86740a56073b | 217 | /**@brief Function for providing pairing and bonding parameters to use for the current pairing |
AnnaBridge | 143:86740a56073b | 218 | * procedure on a connection. |
AnnaBridge | 143:86740a56073b | 219 | * |
AnnaBridge | 143:86740a56073b | 220 | * @note If this function returns an @ref NRF_ERROR_NULL, @ref NRF_ERROR_INVALID_PARAM, @ref |
AnnaBridge | 143:86740a56073b | 221 | * BLE_ERROR_INVALID_CONN_HANDLE, or @ref NRF_ERROR_NO_MEM, this function can be called again |
AnnaBridge | 143:86740a56073b | 222 | * after corrective action. |
AnnaBridge | 143:86740a56073b | 223 | * |
AnnaBridge | 143:86740a56073b | 224 | * @note To reject a request, call this function with NULL p_sec_params. |
AnnaBridge | 143:86740a56073b | 225 | * |
AnnaBridge | 143:86740a56073b | 226 | * @param[in] conn_handle The connection handle of the connection the pairing is happening on. |
AnnaBridge | 143:86740a56073b | 227 | * @param[in] p_sec_params The security parameters to use for this link. |
AnnaBridge | 143:86740a56073b | 228 | * @param[in] p_public_key A pointer to the public key to use if using LESC, or NULL. |
AnnaBridge | 143:86740a56073b | 229 | * |
AnnaBridge | 143:86740a56073b | 230 | * @retval NRF_SUCCESS Success. |
AnnaBridge | 143:86740a56073b | 231 | * @retval NRF_ERROR_INVALID_STATE Module is not initialized, or no parameters have been |
AnnaBridge | 143:86740a56073b | 232 | * requested on that conn_handle, or this error originates |
AnnaBridge | 143:86740a56073b | 233 | * from the SoftDevice. |
AnnaBridge | 143:86740a56073b | 234 | * @retval NRF_ERROR_INVALID_PARAM Invalid combination of parameters (not including conn_handle). |
AnnaBridge | 143:86740a56073b | 235 | * @retval NRF_ERROR_TIMEOUT There has been an SMP timeout, so no more SMP operations |
AnnaBridge | 143:86740a56073b | 236 | * can be performed on this link. |
AnnaBridge | 143:86740a56073b | 237 | * @retval BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. |
AnnaBridge | 143:86740a56073b | 238 | * @retval NRF_ERROR_NO_MEM No more room in flash. Fix and reattempt later. |
AnnaBridge | 143:86740a56073b | 239 | * @retval NRF_ERROR_BUSY No write buffer. Reattempt later. |
AnnaBridge | 143:86740a56073b | 240 | */ |
AnnaBridge | 143:86740a56073b | 241 | ret_code_t smd_params_reply(uint16_t conn_handle, |
AnnaBridge | 143:86740a56073b | 242 | ble_gap_sec_params_t * p_sec_params, |
AnnaBridge | 143:86740a56073b | 243 | ble_gap_lesc_p256_pk_t * p_public_key); |
AnnaBridge | 143:86740a56073b | 244 | |
AnnaBridge | 143:86740a56073b | 245 | |
AnnaBridge | 143:86740a56073b | 246 | /**@brief Function for initiating security on the link, with the specified parameters. |
AnnaBridge | 143:86740a56073b | 247 | * |
AnnaBridge | 143:86740a56073b | 248 | * @note If the connection is a peripheral connection, this will send a security request to the |
AnnaBridge | 143:86740a56073b | 249 | * master, but the master is not obligated to initiate pairing or encryption in response. |
AnnaBridge | 143:86740a56073b | 250 | * @note If the connection is a central connection and a key is available, the parameters will be |
AnnaBridge | 143:86740a56073b | 251 | * used to determine whether to re-pair or to encrypt using the existing key. If no key is |
AnnaBridge | 143:86740a56073b | 252 | * available, pairing will be started. |
AnnaBridge | 143:86740a56073b | 253 | * |
AnnaBridge | 143:86740a56073b | 254 | * @param[in] conn_handle Handle of the connection to initiate pairing on. |
AnnaBridge | 143:86740a56073b | 255 | * @param[in] p_sec_params The security parameters to use for this link. As a central, this can |
AnnaBridge | 143:86740a56073b | 256 | * be NULL to reject a slave security request. |
AnnaBridge | 143:86740a56073b | 257 | * @param[in] force_repairing Whether to force a pairing procedure to happen regardless of whether |
AnnaBridge | 143:86740a56073b | 258 | * an encryption key already exists. This argument is only relevant for |
AnnaBridge | 143:86740a56073b | 259 | * the central role. Recommended value: false |
AnnaBridge | 143:86740a56073b | 260 | * |
AnnaBridge | 143:86740a56073b | 261 | * @retval NRF_SUCCESS Success. |
AnnaBridge | 143:86740a56073b | 262 | * @retval NRF_ERROR_NULL p_sec_params was NULL (peripheral only). |
AnnaBridge | 143:86740a56073b | 263 | * @retval NRF_ERROR_INVALID_STATE Module is not initialized, or this error originates from |
AnnaBridge | 143:86740a56073b | 264 | * the SoftDevice. |
AnnaBridge | 143:86740a56073b | 265 | * @retval NRF_ERROR_INVALID_PARAM Invalid combination of parameters (not including conn_handle). |
AnnaBridge | 143:86740a56073b | 266 | * @retval NRF_ERROR_BUSY Unable to initiate procedure at this time. |
AnnaBridge | 143:86740a56073b | 267 | * @retval NRF_ERROR_TIMEOUT There has been an SMP timeout, so no more SMP operations |
AnnaBridge | 143:86740a56073b | 268 | * can be performed on this link. |
AnnaBridge | 143:86740a56073b | 269 | * @retval BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. |
AnnaBridge | 143:86740a56073b | 270 | * @retval NRF_ERROR_NO_MEM No more room in flash. |
AnnaBridge | 143:86740a56073b | 271 | * @retval NRF_ERROR_INTERNAL No more available peer IDs. |
AnnaBridge | 143:86740a56073b | 272 | */ |
AnnaBridge | 143:86740a56073b | 273 | ret_code_t smd_link_secure(uint16_t conn_handle, |
AnnaBridge | 143:86740a56073b | 274 | ble_gap_sec_params_t * p_sec_params, |
AnnaBridge | 143:86740a56073b | 275 | bool force_repairing); |
AnnaBridge | 143:86740a56073b | 276 | |
AnnaBridge | 143:86740a56073b | 277 | /** @} |
AnnaBridge | 143:86740a56073b | 278 | * @endcond |
AnnaBridge | 143:86740a56073b | 279 | */ |
AnnaBridge | 143:86740a56073b | 280 | |
AnnaBridge | 143:86740a56073b | 281 | #endif /* SECURITY_DISPATCHER_H__ */ |