mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Remove manual seeding of openssl RAND generator
This commit is contained in:
parent
88c8e28e6b
commit
3ed2abf918
1 changed files with 6 additions and 10 deletions
16
common.c
16
common.c
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue