Merge branch 'fix/ble_issue_10032025_v5.3' into 'release/v5.3'

fix(nimble): Fix some nimble issues ble_issue_10032025_v5.3

See merge request espressif/esp-idf!37623
This commit is contained in:
Rahul Tank
2025-04-15 12:32:44 +08:00
46 changed files with 410 additions and 69 deletions

View File

@ -658,23 +658,25 @@ if(CONFIG_BT_ENABLED)
if(NOT (CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS OR CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS))
list(APPEND include_dirs
porting/ext/tinycrypt/include
common/tinycrypt/include
common/tinycrypt/port
)
list(APPEND srcs "porting/ext/tinycrypt/src/utils.c"
"porting/ext/tinycrypt/src/sha256.c"
"porting/ext/tinycrypt/src/ecc.c"
"porting/ext/tinycrypt/src/ctr_prng.c"
"porting/ext/tinycrypt/src/ctr_mode.c"
"porting/ext/tinycrypt/src/aes_decrypt.c"
"porting/ext/tinycrypt/src/aes_encrypt.c"
"porting/ext/tinycrypt/src/ccm_mode.c"
"porting/ext/tinycrypt/src/ecc_dsa.c"
"porting/ext/tinycrypt/src/cmac_mode.c"
"porting/ext/tinycrypt/src/ecc_dh.c"
"porting/ext/tinycrypt/src/hmac_prng.c"
"porting/ext/tinycrypt/src/ecc_platform_specific.c"
"porting/ext/tinycrypt/src/hmac.c"
"porting/ext/tinycrypt/src/cbc_mode.c")
list(APPEND srcs "common/tinycrypt/src/utils.c"
"common/tinycrypt/src/sha256.c"
"common/tinycrypt/src/ecc.c"
"common/tinycrypt/src/ctr_prng.c"
"common/tinycrypt/src/ctr_mode.c"
"common/tinycrypt/src/aes_decrypt.c"
"common/tinycrypt/src/aes_encrypt.c"
"common/tinycrypt/src/ccm_mode.c"
"common/tinycrypt/src/ecc_dsa.c"
"common/tinycrypt/src/cmac_mode.c"
"common/tinycrypt/src/ecc_dh.c"
"common/tinycrypt/src/hmac_prng.c"
"common/tinycrypt/src/ecc_platform_specific.c"
"common/tinycrypt/src/hmac.c"
"common/tinycrypt/src/cbc_mode.c"
"common/tinycrypt/port/esp_tinycrypt_port.c")
endif()
if(CONFIG_BT_NIMBLE_ENABLED)

View File

@ -1,4 +1,8 @@
/* aes.h - TinyCrypt interface to an AES-128 implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* ccm_mode.h - TinyCrypt interface to a CCM mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* cmac_mode.h -- interface to a CMAC implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved

View File

@ -1,4 +1,8 @@
/* constants.h - TinyCrypt interface to constants */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* ctr_mode.h - TinyCrypt interface to CTR mode */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ctr_prng.h - TinyCrypt interface to a CTR-PRNG implementation */
/*

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ecc.h - TinyCrypt interface to common ECC functions */
/* Copyright (c) 2014, Kenneth MacKay

View File

@ -1,4 +1,8 @@
/* ecc_dh.h - TinyCrypt interface to EC-DH implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ecc_dh.h - TinyCrypt interface to EC-DSA implementation */
/*

View File

@ -1,4 +1,8 @@
/* uECC_platform_specific.h - Interface to platform specific functions*/
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Copyright (c) 2014, Kenneth MacKay
* All rights reserved.

View File

@ -1,4 +1,8 @@
/* hmac.h - TinyCrypt interface to an HMAC implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@ -124,7 +128,7 @@ int tc_hmac_update(TCHmacState_t ctx, const void *data,
* key == NULL or
* taglen != TC_SHA256_DIGEST_SIZE
* @note ctx is erased before exiting. This should never be changed/removed.
* @note Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes
* @note Assumes the tag buffer is at least sizeof(hmac_tag_size(state)) bytes
* state has been initialized by tc_hmac_init
* @param tag IN/OUT -- buffer to receive computed HMAC tag
* @param taglen IN -- size of tag in bytes

View File

@ -1,4 +1,8 @@
/* hmac_prng.h - TinyCrypt interface to an HMAC-PRNG implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* sha256.h - TinyCrypt interface to a SHA-256 implementation */
/*

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* utils.h - TinyCrypt interface to platform-dependent run-time operations */
/*

View File

@ -0,0 +1,87 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_tinycrypt_port.h"
#include "esp_crypto_lock.h"
#include "esp_private/esp_crypto_lock_internal.h"
#if SOC_ECC_SUPPORTED
#include "hal/ecc_hal.h"
#include "hal/ecc_ll.h"
#endif /* SOC_ECC_SUPPORTED */
#if SOC_ECC_SUPPORTED
static void esp_tinycrypt_acquire_ecc_hardware(void)
{
esp_crypto_ecc_lock_acquire();
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(true);
ecc_ll_power_up();
ecc_ll_reset_register();
}
}
static void esp_tinycrypt_release_ecc_hardware(void)
{
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(false);
ecc_ll_power_down();
}
esp_crypto_ecc_lock_release();
}
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length)
{
int result;
esp_tinycrypt_acquire_ecc_hardware();
ecc_hal_write_verify_param(pk_x, pk_y, length);
ecc_hal_set_mode(ECC_MODE_VERIFY);
ecc_hal_start_calc();
while (!ecc_hal_is_calc_finished());
result = ecc_hal_read_verify_result();
esp_tinycrypt_release_ecc_hardware();
if (result == 1) {
return 0;
} else {
return -1;
}
}
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first)
{
int ret = -1;
ecc_mode_t work_mode = verify_first ? ECC_MODE_VERIFY_THEN_POINT_MUL : ECC_MODE_POINT_MUL;
esp_tinycrypt_acquire_ecc_hardware();
ecc_hal_write_mul_param(scalar, p_x, p_y, num_bytes);
ecc_hal_set_mode(work_mode);
/*
* Enable constant-time point multiplication operations for the ECC hardware accelerator,
* if supported for the given target. This protects the ECC multiplication operation from
* timing attacks. This increases the time taken (by almost 50%) for some point
* multiplication operations performed by the ECC hardware accelerator.
*/
ecc_hal_enable_constant_time_point_mul(true);
ecc_hal_start_calc();
while (!ecc_hal_is_calc_finished());
ret = ecc_hal_read_mul_result(r_x, r_y, num_bytes);
esp_tinycrypt_release_ecc_hardware();
return ret;
}
#endif /* SOC_ECC_SUPPORTED */

View File

@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include "soc/soc_caps.h"
#if SOC_ECC_SUPPORTED
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length);
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first);
#endif /* SOC_ECC_SUPPORTED */

View File

@ -1,4 +1,8 @@
/* aes_decrypt.c - TinyCrypt implementation of AES decryption procedure */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* aes_decrypt.c - TinyCrypt implementation of AES decryption procedure */
#include <tinycrypt/aes.h>
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* aes_encrypt.c - TinyCrypt implementation of AES encryption procedure */
/*

View File

@ -1,4 +1,8 @@
/* cbc_mode.c - TinyCrypt implementation of CBC mode encryption & decryption */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* ccm_mode.c - TinyCrypt implementation of CCM mode */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* ccm_mode.c - TinyCrypt implementation of CCM mode */
#include <tinycrypt/ccm_mode.h>
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>

View File

@ -1,4 +1,8 @@
/* cmac_mode.c - TinyCrypt CMAC mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ctr_mode.c - TinyCrypt CTR mode implementation */
/*

View File

@ -1,4 +1,8 @@
/* ctr_prng.c - TinyCrypt implementation of CTR-PRNG */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2016, Chris Morrison

View File

@ -1,4 +1,8 @@
/* ecc.c - TinyCrypt implementation of common ECC functions */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay
@ -55,6 +59,9 @@
#include <tinycrypt/ecc.h>
#include <tinycrypt/ecc_platform_specific.h>
#include <string.h>
#include <stdio.h>
#include "esp_tinycrypt_port.h"
/* IMPORTANT: Make sure a cryptographically-secure PRNG is set and the platform
* has access to enough entropy in order to feed the PRNG regularly. */
@ -635,6 +642,7 @@ void apply_z(uECC_word_t * X1, uECC_word_t * Y1, const uECC_word_t * const Z,
uECC_vli_modMult_fast(Y1, Y1, t1, curve); /* y1 * z^3 */
}
#if !SOC_ECC_SUPPORTED
/* P = (x1, y1) => 2P, (x2, y2) => P' */
static void XYcZ_initial_double(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
@ -658,31 +666,6 @@ static void XYcZ_initial_double(uECC_word_t * X1, uECC_word_t * Y1,
apply_z(X2, Y2, z, curve);
}
void XYcZ_add(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
uECC_Curve curve)
{
/* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */
uECC_word_t t5[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */
uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */
uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */
uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */
uECC_vli_modSquare_fast(t5, Y2, curve); /* t5 = (y2 - y1)^2 = D */
uECC_vli_modSub(t5, t5, X1, curve->p, num_words); /* t5 = D - B */
uECC_vli_modSub(t5, t5, X2, curve->p, num_words); /* t5 = D - B - C = x3 */
uECC_vli_modSub(X2, X2, X1, curve->p, num_words); /* t3 = C - B */
uECC_vli_modMult_fast(Y1, Y1, X2, curve); /* t2 = y1*(C - B) */
uECC_vli_modSub(X2, X1, t5, curve->p, num_words); /* t3 = B - x3 */
uECC_vli_modMult_fast(Y2, Y2, X2, curve); /* t4 = (y2 - y1)*(B - x3) */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y3 */
uECC_vli_set(X2, t5, num_words);
}
/* Input P = (x1, y1, Z), Q = (x2, y2, Z)
Output P + Q = (x3, y3, Z3), P - Q = (x3', y3', Z3)
@ -725,12 +708,49 @@ static void XYcZ_addC(uECC_word_t * X1, uECC_word_t * Y1,
uECC_vli_set(X1, t7, num_words);
}
#endif /* !SOC_ECC_SUPPORTED */
void XYcZ_add(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
uECC_Curve curve)
{
/* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */
uECC_word_t t5[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */
uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */
uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */
uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */
uECC_vli_modSquare_fast(t5, Y2, curve); /* t5 = (y2 - y1)^2 = D */
uECC_vli_modSub(t5, t5, X1, curve->p, num_words); /* t5 = D - B */
uECC_vli_modSub(t5, t5, X2, curve->p, num_words); /* t5 = D - B - C = x3 */
uECC_vli_modSub(X2, X2, X1, curve->p, num_words); /* t3 = C - B */
uECC_vli_modMult_fast(Y1, Y1, X2, curve); /* t2 = y1*(C - B) */
uECC_vli_modSub(X2, X1, t5, curve->p, num_words); /* t3 = B - x3 */
uECC_vli_modMult_fast(Y2, Y2, X2, curve); /* t4 = (y2 - y1)*(B - x3) */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y3 */
uECC_vli_set(X2, t5, num_words);
}
void EccPoint_mult(uECC_word_t * result, const uECC_word_t * point,
const uECC_word_t * scalar,
const uECC_word_t * initial_Z,
bitcount_t num_bits, uECC_Curve curve)
{
#if SOC_ECC_SUPPORTED
wordcount_t num_words = curve->num_words;
/* Only p256r1 is supported currently. */
assert (curve == uECC_secp256r1());
esp_tinycrypt_calc_ecc_mult((const uint8_t *)&point[0], (const uint8_t *)&point[num_words],
(uint8_t *)scalar, (uint8_t *)&result[0], (uint8_t *)&result[num_words],
num_words * uECC_WORD_SIZE, false);
#else
/* R0 and R1 */
uECC_word_t Rx[2][NUM_ECC_WORDS];
uECC_word_t Ry[2][NUM_ECC_WORDS];
@ -769,6 +789,7 @@ void EccPoint_mult(uECC_word_t * result, const uECC_word_t * point,
uECC_vli_set(result, Rx[0], num_words);
uECC_vli_set(result + num_words, Ry[0], num_words);
#endif /* SOC_ECC_SUPPORTED */
}
uECC_word_t regularize_k(const uECC_word_t * const k, uECC_word_t *k0,
@ -862,8 +883,6 @@ int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top,
int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
{
uECC_word_t tmp1[NUM_ECC_WORDS];
uECC_word_t tmp2[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
/* The point at infinity is invalid. */
@ -877,19 +896,34 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
return -2;
}
#if SOC_ECC_SUPPORTED
/* Only p256r1 is supported currently. */
if (curve != uECC_secp256r1()) {
return -5;
}
if (esp_tinycrypt_verify_ecc_point((const uint8_t *)&point[0],
(const uint8_t *)&point[num_words],
num_words * uECC_WORD_SIZE)) {
return -3;
}
#else
uECC_word_t tmp1[NUM_ECC_WORDS];
uECC_word_t tmp2[NUM_ECC_WORDS];
uECC_vli_modSquare_fast(tmp1, point + num_words, curve);
curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */
/* Make sure that y^2 == x^3 + ax + b */
if (uECC_vli_equal(tmp1, tmp2, num_words) != 0)
return -3;
#endif /* SOC_ECC_SUPPORTED */
return 0;
}
int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve)
{
uECC_word_t _public[NUM_ECC_WORDS * 2];
uECC_vli_bytesToNative(_public, public_key, curve->num_bytes);
@ -908,7 +942,6 @@ int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve)
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key,
uECC_Curve curve)
{
uECC_word_t _private[NUM_ECC_WORDS];
uECC_word_t _public[NUM_ECC_WORDS * 2];

View File

@ -1,4 +1,8 @@
/* ec_dh.c - TinyCrypt implementation of EC-DH */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay

View File

@ -1,4 +1,8 @@
/* ec_dsa.c - TinyCrypt implementation of EC-DSA */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Copyright (c) 2014, Kenneth MacKay
* All rights reserved.

View File

@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* uECC_platform_specific.c - Implementation of platform specific functions*/
/* Copyright (c) 2014, Kenneth MacKay

View File

@ -1,4 +1,8 @@
/* hmac.c - TinyCrypt implementation of the HMAC algorithm */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* hmac_prng.c - TinyCrypt implementation of HMAC-PRNG */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* hmac_prng.c - TinyCrypt implementation of HMAC-PRNG */
#include <tinycrypt/hmac_prng.h>
#include <tinycrypt/hmac.h>
#include <tinycrypt/constants.h>

View File

@ -1,4 +1,8 @@
/* sha256.c - TinyCrypt SHA-256 crypto hash algorithm implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@ -1,4 +1,8 @@
/* utils.c - TinyCrypt platform-dependent run-time operations */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* utils.c - TinyCrypt platform-dependent run-time operations */
#include <tinycrypt/utils.h>
#include <tinycrypt/constants.h>

View File

@ -228,6 +228,16 @@ config BT_LE_POWER_CONTROL_ENABLED
help
Set this option to enable the Power Control feature on controller
config BT_LE_CTE_FEATURE_ENABLED
bool "Enable Bluetooth LE Direction Finding (AoA/AoD)"
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_CTE_SUPPORTED
default n
help
Enable this option to activate Bluetooth LE Direction Finding (AoA/AoD) feature.
Note:
This feature allows devices to determine the direction of a Bluetooth CTE signal,
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
menu "Memory Settings"
depends on !BT_NIMBLE_ENABLED

View File

@ -228,6 +228,19 @@ config BT_LE_POWER_CONTROL_ENABLED
help
Set this option to enable the Power Control feature on controller
config BT_LE_CTE_FEATURE_ENABLED
bool "Enable Bluetooth LE Direction Finding (AoA/AoD)"
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_CTE_SUPPORTED && !(BT_LE_SECURITY_ENABLE)
default n
help
Enable this option to activate Bluetooth LE Direction Finding (AoA/AoD) feature.
Note:
This feature allows devices to determine the direction of a Bluetooth CTE signal,
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
In chip esp32h2, Direction Finding is not supported in encrypted
communication scenarios. If you are using chip esp32h2, ensure that encryption is
disabled when using this feature.
menu "Memory Settings"
depends on !BT_NIMBLE_ENABLED

View File

@ -569,6 +569,7 @@
// #define SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED (1) /*!< Support For BLE Periodic Adv Enhancements */
// #define SOC_BLUFI_SUPPORTED (1) /*!< Support BLUFI */
// #define SOC_BLE_MULTI_CONN_OPTIMIZATION (1) /*!< Support multiple connections optimization */
// #define SOC_BLE_CTE_SUPPORTED (1) /*!< Support Bluetooth LE Constant Tone Extension (CTE) */
// #define SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND (1)

View File

@ -1446,3 +1446,7 @@ config SOC_BLE_MULTI_CONN_OPTIMIZATION
config SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED
bool
default y
config SOC_BLE_CTE_SUPPORTED
bool
default y

View File

@ -587,3 +587,4 @@
#define SOC_BLE_POWER_CONTROL_SUPPORTED (1) /*!< Support Bluetooth Power Control */
#define SOC_BLE_MULTI_CONN_OPTIMIZATION (1) /*!< Support multiple connections optimization */
#define SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED (1) /*!< Support For BLE Periodic Adv Enhancements */
#define SOC_BLE_CTE_SUPPORTED (1) /*!< Support Bluetooth LE Constant Tone Extension (CTE) */

View File

@ -171,4 +171,14 @@ menu "Example Configuration"
help
Used for internal test ONLY.
Use this option to advertise in a specific random address.
config EXAMPLE_SLEEP_WAKEUP
bool "Enable Vendor-Specific Sleep Wake-Up Event"
depends on BT_NIMBLE_VS_SUPPORT
default n
help
When enabled, the Nimble Host allows setting a Vendor-Specific
Event Mask for processing sleep wake-up events from the controller.
The controller sends a wake-up event (HCI_LE_SLEEP_WAKE_UP 0xFF 0xC3)
when it resumes from sleep.
endmenu

View File

@ -56,6 +56,10 @@ static uint8_t own_addr_type;
void ble_store_config_init(void);
#if MYNEWT_VAL(BLE_HCI_VS)
static struct ble_gap_event_listener vs_event_listener;
#endif
#if MYNEWT_VAL(BLE_POWER_CONTROL)
static struct ble_gap_event_listener power_control_event_listener;
#endif
@ -144,6 +148,13 @@ ext_bleprph_advertise(void)
/* start advertising */
rc = ble_gap_ext_adv_start(instance, 0, 0);
assert (rc == 0);
#if CONFIG_EXAMPLE_SLEEP_WAKEUP
rc = ble_hs_send_vs_event_mask(ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT_MASK);
rc = ble_gap_event_listener_register(&vs_event_listener,
bleprph_gap_event,NULL);
#endif
}
#else
/**
@ -443,6 +454,20 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
}
return 0;
#if CONFIG_EXAMPLE_SLEEP_WAKEUP
case BLE_GAP_EVENT_VS_HCI:
const struct ble_hci_ev_vs *ev = event->vs_hci.ev;
switch(ev->id) {
case BLE_HCI_VS_SUBEV_LE_SLEEP_WAKE_UP:
MODLOG_DFLT(INFO, "Got Sleep wake up ");
break;
default:
break;
}
#endif
}
return 0;