I'm using the function wolfSSL_RAND_bytes to create an Random WiFi password. But on some instance I get the same password. Below is my code snippet.
#include <wolfssl/ssl.h>
bool GetRandomCharacters(char* buffer, int count){
unsigned char* t_buffer = (unsigned char*)buffer;
char convert[] = "ABCEFGHQJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz923456"
"789ABCEFGHQJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz923456789ABCE"
"FGHQJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz923456789ABCEFGHQJKL"
"MNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz923456789ABCEFGHHJKLMNOPQRSTU";
assert(257 == sizeof(convert));
if (getRandomBytes(t_buffer, count)) {
for (int i = 0; i < count; ++i) { buffer[i] = convert[t_buffer[i]]; }
return true;
}
return false;
}
inline bool getRandomBytes(unsigned char* buffer, int count) {
return SSL_SUCCESS == wolfSSL_RAND_bytes(buffer, count);
}
So I need to understand the algorithm used in wolfSSL_RAND_bytes function. From the open source github code, I came to know that there are two different implementations inside function
wc_InitRng() and wc_RNG_GenerateBlock().
I appreciate your help.