Skip to content

Commit 2b8feed

Browse files
committed
workaround to get seed size before read from its
1 parent 17af4f1 commit 2b8feed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

features/mbedtls/platform/COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66
int mbed_default_seed_read(unsigned char *buf, size_t buf_len)
77
{
8-
psa_its_status_t rc = psa_its_get(MBED_RANDOM_SEED_ITS_UID, 0, buf_len, buf);
8+
struct psa_its_info_t info = {0, 0};
9+
size_t actual_size = buf_len;
10+
psa_its_get_info(MBED_RANDOM_SEED_ITS_UID, &info);
11+
if (info.size < buf_len)
12+
{
13+
actual_size = info.size;
14+
}
15+
psa_its_status_t rc = psa_its_get(MBED_RANDOM_SEED_ITS_UID, 0, actual_size, buf);
916
/* Make sure that in case of an error the value will be negative
1017
* Mbed TLS errors are negative values */
1118
rc = rc < 0 ? rc : (-1 * rc);

0 commit comments

Comments
 (0)