Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Fork of nrf51-sdk by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
vcoubard
Date:
Thu Apr 07 17:38:10 2016 +0100
Parent:
35:078fe5fe05d5
Child:
37:8f65b11f95aa
Commit message:
Synchronized with git rev b0017f9f
Author: Andres Amaya Garcia
Expose function in DM to calculate BLE hash

The hash function is needed to generate this a new Private Resolvable address.
This functionality is required to generate a table with a list of addresses
from the information in the bond table (See the getAddressesFromBondTable() API
in BLE API SecurityManager). However, this function is not exposed by the
nRF51 SDK to external code. This pull requests simply adds the function
declaration to the relevant .h file to make external use possible.

Changed in this revision

source/nordic_sdk/components/ble/peer_manager/id_manager.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/nordic_sdk/components/ble/peer_manager/id_manager.h	Thu Apr 07 17:38:08 2016 +0100
+++ b/source/nordic_sdk/components/ble/peer_manager/id_manager.h	Thu Apr 07 17:38:10 2016 +0100
@@ -229,6 +229,31 @@
  */
 bool im_address_resolve(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk);
 
+/**@brief Function for calculating the ah() hash function described in Bluetooth core specification
+ *        4.2 section 3.H.2.2.2.
+ *
+ * @detail  BLE uses a hash function to calculate the first half of a resolvable address
+ *          from the second half of the address and an irk. This function will use the ECB
+ *          periferal to hash these data acording to the Bluetooth core specification.
+ *
+ * @note The ECB expect little endian input and output.
+ *       This function expect big endian and will reverse the data as necessary.
+ *
+ * @param[in]  p_k          The key used in the hash function.
+ *                          For address resolution this is should be the irk.
+ *                          The array must have a length of 16.
+ * @param[in]  p_r          The rand used in the hash function. For generating a new address
+ *                          this would be a random number. For resolving a resolvable address
+ *                          this would be the last half of the address being resolved.
+ *                          The array must have a length of 3.
+ * @param[out] p_local_hash The result of the hash operation. For address resolution this
+ *                          will match the first half of the address being resolved if and only
+ *                          if the irk used in the hash function is the same one used to generate
+ *                          the address.
+ *                          The array must have a length of 16.
+ */
+void ah(uint8_t const * p_k, uint8_t const * p_r, uint8_t * p_local_hash);
+
 /** @} */
 
 #endif /* PEER_ID_MANAGER_H__ */
\ No newline at end of file