mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Use psa_generate_random() instead of mbedtls_ctr_dbrg
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
This commit is contained in:
27
3rdparty/p256-m/p256-m/p256-m.c
vendored
27
3rdparty/p256-m/p256-m/p256-m.c
vendored
@ -6,8 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "p256-m.h"
|
#include "p256-m.h"
|
||||||
#include "mbedtls/entropy.h"
|
#include "psa/crypto.h"
|
||||||
#include "mbedtls/ctr_drbg.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.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)
|
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;
|
int ret;
|
||||||
|
ret = psa_generate_random(output, output_size);
|
||||||
|
|
||||||
ret = mbedtls_ctr_drbg_seed(&ctr_drbg , mbedtls_entropy_func, &entropy,
|
if (ret != 0){
|
||||||
(const unsigned char *) personalization,
|
return P256_RANDOM_FAILED;
|
||||||
strlen(personalization));
|
|
||||||
if (ret != 0) {
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mbedtls_ctr_drbg_random(&ctr_drbg, output, output_size);
|
|
||||||
if (ret != 0) {
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return P256_SUCCESS;
|
return P256_SUCCESS;
|
||||||
#endif
|
|
||||||
|
|
||||||
exit:
|
|
||||||
return P256_RANDOM_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user