aboutsummaryrefslogtreecommitdiff
path: root/3rdparty
diff options
context:
space:
mode:
authorAditya Deshpande <aditya.deshpande@arm.com>2023-02-21 18:07:13 +0000
committerAditya Deshpande <aditya.deshpande@arm.com>2023-04-28 17:54:15 +0100
commitbe55bb2d5db56d2f54c4d78ed698c6d585ad593e (patch)
tree1b1317cdd3d7e6eab66c3d72b555b9b1dfb504dd /3rdparty
parent8d99f2590c74baf07b8066be9d83655aecd08120 (diff)
downloadmbedtls-be55bb2d5db56d2f54c4d78ed698c6d585ad593e.zip
mbedtls-be55bb2d5db56d2f54c4d78ed698c6d585ad593e.tar.gz
mbedtls-be55bb2d5db56d2f54c4d78ed698c6d585ad593e.tar.bz2
Use psa_generate_random() instead of mbedtls_ctr_dbrg
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Diffstat (limited to '3rdparty')
-rw-r--r--3rdparty/p256-m/p256-m/p256-m.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/3rdparty/p256-m/p256-m/p256-m.c b/3rdparty/p256-m/p256-m/p256-m.c
index 9e23a2d..0360ea2 100644
--- a/3rdparty/p256-m/p256-m/p256-m.c
+++ b/3rdparty/p256-m/p256-m/p256-m.c
@@ -6,8 +6,7 @@
*/
#include "p256-m.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
+#include "psa/crypto.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1158,31 +1157,13 @@ static int scalar_from_bytes(uint32_t s[8], const uint8_t p[32])
*/
int p256_generate_random(uint8_t *output, unsigned output_size)
{
-#if defined(MBEDTLS_CTR_DRBG_C)
- mbedtls_entropy_context entropy;
- mbedtls_ctr_drbg_context ctr_drbg;
- char *personalization = "p256m";
- mbedtls_entropy_init(&entropy);
- mbedtls_ctr_drbg_init(&ctr_drbg);
int ret;
+ ret = psa_generate_random(output, output_size);
- ret = mbedtls_ctr_drbg_seed(&ctr_drbg , mbedtls_entropy_func, &entropy,
- (const unsigned char *) personalization,
- strlen(personalization));
- if (ret != 0) {
- goto exit;
- }
-
- ret = mbedtls_ctr_drbg_random(&ctr_drbg, output, output_size);
- if (ret != 0) {
- goto exit;
+ if (ret != 0){
+ return P256_RANDOM_FAILED;
}
-
return P256_SUCCESS;
-#endif
-
-exit:
- return P256_RANDOM_FAILED;
}
/*