diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h index 58ad280468..a603689769 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -67,9 +67,9 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers); * So as an unprovisioned device, it should use this function to input * the Public Key exchanged through the out-of-band mechanism. * - * @param[in] pub_key_x: Unprovisioned device's Public Key X - * @param[in] pub_key_y: Unprovisioned device's Public Key Y - * @param[in] private_key: Unprovisioned device's Private Key + * @param[in] pub_key_x: Unprovisioned device's Public Key X(Little Endian) + * @param[in] pub_key_y: Unprovisioned device's Public Key Y(Little Endian) + * @param[in] private_key: Unprovisioned device's Private Key(Little Endian) * * @return ESP_OK on success or error code otherwise. */ diff --git a/components/bt/esp_ble_mesh/common/crypto_mbedtls.c b/components/bt/esp_ble_mesh/common/crypto_mbedtls.c index 5ff9670b5f..45fe7a78bb 100644 --- a/components/bt/esp_ble_mesh/common/crypto_mbedtls.c +++ b/components/bt/esp_ble_mesh/common/crypto_mbedtls.c @@ -335,6 +335,8 @@ void bt_mesh_set_private_key_raw(const uint8_t pri_key[32]) goto cleanup; } + BT_DBG("Pubkey:%s", bt_hex(dh_pair.public_key, PUB_KEY_SIZE)); + BT_DBG("Privkey:%s", bt_hex(dh_pair.private_key, PRIV_KEY_SIZE)); dh_pair.is_ready = true; cleanup: diff --git a/components/bt/esp_ble_mesh/common/crypto_psa.c b/components/bt/esp_ble_mesh/common/crypto_psa.c index 16dd15bca0..3655c48cb6 100644 --- a/components/bt/esp_ble_mesh/common/crypto_psa.c +++ b/components/bt/esp_ble_mesh/common/crypto_psa.c @@ -392,6 +392,8 @@ void bt_mesh_set_private_key_raw(const uint8_t pri_key[32]) return; } + BT_DBG("Pubkey:%s", bt_hex(&dh_pair.public_key[1], PUB_KEY_SIZE)); + BT_DBG("Privkey:%s", bt_hex(pri_key, PRIV_KEY_SIZE)); dh_pair.is_ready = true; psa_reset_key_attributes(&attributes); } diff --git a/components/bt/esp_ble_mesh/common/crypto_tc.c b/components/bt/esp_ble_mesh/common/crypto_tc.c index f4c780edd6..2c4d39499b 100644 --- a/components/bt/esp_ble_mesh/common/crypto_tc.c +++ b/components/bt/esp_ble_mesh/common/crypto_tc.c @@ -236,6 +236,8 @@ void bt_mesh_set_private_key_raw(const uint8_t pri_key[32]) return; } + BT_DBG("Pubkey:%s", bt_hex(dh_pair.public_key, PUB_KEY_SIZE)); + BT_DBG("Privkey:%s", bt_hex(dh_pair.private_key, PRIV_KEY_SIZE)); dh_pair.is_ready = true; } diff --git a/components/bt/esp_ble_mesh/common/include/mesh/crypto.h b/components/bt/esp_ble_mesh/common/include/mesh/crypto.h index 806e84f479..0ae0cad1cb 100644 --- a/components/bt/esp_ble_mesh/common/include/mesh/crypto.h +++ b/components/bt/esp_ble_mesh/common/include/mesh/crypto.h @@ -345,11 +345,11 @@ int bt_mesh_pub_key_gen(void); * * @return 0 on success, -EAGAIN if public key not ready */ -static inline int bt_mesh_pub_key_copy(uint8_t buf[64]) +static inline int bt_mesh_pub_key_copy(uint8_t *buf) { const uint8_t *key = bt_mesh_pub_key_get_raw(); - if (key == NULL) { + if (key == NULL || buf == NULL) { return -EAGAIN; } diff --git a/components/bt/esp_ble_mesh/core/prov_node.c b/components/bt/esp_ble_mesh/core/prov_node.c index dc550594df..15f24bf3d6 100644 --- a/components/bt/esp_ble_mesh/core/prov_node.c +++ b/components/bt/esp_ble_mesh/core/prov_node.c @@ -703,6 +703,8 @@ int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], const uint8_t pub_key_y[32], const uint8_t pri_key[32]) { + uint8_t privkey[32] = {0}; + if (!pub_key_x || !pub_key_y || !pri_key) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; @@ -714,7 +716,8 @@ int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], */ sys_memcpy_swap(&prov_link.conf_inputs[81], pub_key_x, 32); sys_memcpy_swap(&prov_link.conf_inputs[81] + 32, pub_key_y, 32); - bt_mesh_set_private_key(pri_key); + sys_memcpy_swap(privkey, pri_key, 32); + bt_mesh_set_private_key(privkey); bt_mesh_atomic_set_bit(prov_link.flags, OOB_PUB_KEY);