Skip to content

Commit 88d71da

Browse files
committed
fix(mbedtls): Addressed comments on PR15679
1 parent f933e51 commit 88d71da

File tree

8 files changed

+39
-35
lines changed

8 files changed

+39
-35
lines changed

components/mbedtls/port/esp_hardware.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <stdlib.h>
1010
#include <stdio.h>
1111
#include "esp_random.h"
12-
#include "mbedtls/esp_random.h"
12+
#include "mbedtls/esp_mbedtls_random.h"
1313

1414
#include <entropy_poll.h>
1515

@@ -27,6 +27,7 @@ int mbedtls_hardware_poll( void *data,
2727

2828
int mbedtls_esp_random(void *ctx, unsigned char *buf, size_t len)
2929
{
30+
(void) ctx; // unused
3031
esp_fill_random(buf, len);
3132
return 0;
3233
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
8+
#include <stddef.h>
9+
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
/**
15+
* @brief MbedTLS-compatible RNG function
16+
*
17+
* @note Suitable for passing as f_rng to various MbedTLS APIs that require it.
18+
* It uses esp_fill_random internally, and the caller must ensure that the
19+
* entropy sources of the RNG peripheral are enabled correctly. See the RNG
20+
* chapter in the TRM for more details.
21+
*
22+
* @param ctx User-supplied context
23+
* @param buf Pointer to a buffer to fill with random numbers
24+
* @param len Length of the buffer in bytes
25+
*
26+
* @return 0 on success
27+
*/
28+
int mbedtls_esp_random(void *ctx, unsigned char *buf, size_t len);
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif

components/mbedtls/port/include/mbedtls/esp_random.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

components/mbedtls/test_apps/main/test_ds_sign_and_decrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static heap_trace_record_t trace_record[NUM_RECORDS]; // This buffer must be in
2121
#include "esp_ds.h"
2222
#include "esp_ds/esp_ds_rsa.h"
2323

24-
int mbedtls_esp_random(void *ctx, unsigned char *output, size_t len)
24+
static int mbedtls_esp_random(void *ctx, unsigned char *output, size_t len)
2525
{
2626
if (len == 0 || output == NULL) {
2727
return -1;

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-bignum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifdef ESP_PLATFORM
88
#include "esp_system.h"
99
#include "mbedtls/bignum.h"
10-
#include "mbedtls/esp_random.h"
10+
#include "mbedtls/esp_mbedtls_random.h"
1111
#endif
1212

1313
#include "utils/includes.h"

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifdef ESP_PLATFORM
88
#include "esp_system.h"
99
#include "mbedtls/bignum.h"
10-
#include "mbedtls/esp_random.h"
10+
#include "mbedtls/esp_mbedtls_random.h"
1111
#endif
1212

1313
#include "utils/includes.h"

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-rsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#ifdef ESP_PLATFORM
88
#include "mbedtls/bignum.h"
9-
#include "mbedtls/esp_random.h"
9+
#include "mbedtls/esp_mbedtls_random.h"
1010
#endif
1111

1212
#include "utils/includes.h"

components/wpa_supplicant/esp_supplicant/src/crypto/tls_mbedtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "crypto/sha256.h"
1414
#include "crypto/sha384.h"
1515

16-
#include "mbedtls/esp_random.h"
16+
#include "mbedtls/esp_mbedtls_random.h"
1717

1818
/* TODO: Remove this once the appropriate solution is found
1919
*

0 commit comments

Comments
 (0)