Remove manual seeding of openssl RAND generator

This commit is contained in:
vdutta 2021-12-07 17:09:48 +05:30
parent 88c8e28e6b
commit 3ed2abf918

View file

@ -667,25 +667,21 @@ char *string_to_hex(const unsigned char *str, size_t size)
char *generate_random_string(size_t size)
{
unsigned char *buf = NULL;
char *hex = NULL;
buf = (unsigned char *)calloc(size + 1, sizeof(unsigned char));
if (buf == NULL) {
CWMP_LOG(ERROR, "Unable to allocate memory for buf string\n");
goto end;
}
int written = RAND_bytes(buf, size);
if (written != 1) {
printf("Failed to get random bytes");
goto end;
}
RAND_seed(buf, written);
if (written != 1) {
printf("Failed to get random bytes");
goto end;
}
char * hex = string_to_hex(buf, size);
hex = string_to_hex(buf, size);
if (hex == NULL)
goto end;