Hi @yvelumani,
I modified your code snippet and tested it on a desktop system which uses the /dev/random for an entropy source and in 100 rounds I do not see a repeating password. Here is your modified code with correct header includes:
#include <stdio.h>
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/random.h>
int getRandomBytes(unsigned char* buffer, int count);
int GetRandomCharacters(char* buffer, int count);
int 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 1;
}
return 0;
}
int getRandomBytes(unsigned char* buffer, int count)
{
return SSL_SUCCESS == wolfSSL_RAND_bytes(buffer, count);
}
#define PASSWORD_LEN 26
int main(void)
{
int i;
int count = PASSWORD_LEN;
char buffer[PASSWORD_LEN] = {0};
GetRandomCharacters(buffer, count);
printf("Password = ");
for (i = 0; i < count; i++)
printf("%c", buffer[i]);
printf("\n");
return 0;
}
Can you tell us which system you are testing on and if you have any settings like
or
#define USE_GENSEED_FORTEST
set as those WOULD be poor entropy sources for seeding the DRBG.
Here are my results with 100-rounds:
Password = g29LzioeSfMmsczF3iKhOnxfPb
Password = FtvKPRo9E9yrnpP6HSQ59YoHw2
Password = kLHQCU6CEOrXFNeTT4mMTY9B3q
Password = rr2TUEpQ3LOK7gkQdxyP4ERZxR
Password = Zjf43YrTeUh92iKe8FtNBeZQWL
Password = htL7NPFWvBkoPNL5e4KUEFXQoC
Password = CafYWojacfqPRckPrVfAAnVfNw
Password = 2FTuNcL3WWhEqMHQWtjBFq6LXx
Password = ZznFH2W9M2vgMdkoTE9maGJQrh
Password = EPgjivLv76mYaRQNnEH9kHn9qv
Password = Xyw5eMQbWYvX9jcGL69LeUM2Qj
Password = XW6TMzJPvTLFSrXP9dmBi9Sk9Q
Password = HOrF6pOJVBhjtUW7JOb4HEvYh3
Password = NCqoFVFgzQ8OApFHsOJpx8sR6C
Password = vQtzCH9cg6ZYjTWd3Kv9T9U8zC
Password = dCxQMMo2Abz9BPAYktejVQ8K6K
Password = r9GndBmVp6XHUaaHrJMmpRYRjs
Password = REYgMOQdEQ97EBPK8UPhmcPbE9
Password = J7R9ztrsg9AmLSKTRZY8bsPiC2
Password = o59ssa96vJdLr397nQ6GX2SMgJ
Password = MJk9ko8XfuS9OdXF6zG2sq2Kcv
Password = QoTeM9UEwBLA4PgQwmLWmysTQO
Password = pwCvN4R5hLqZbTtKyuwQt6fN9V
Password = xrcYyknt2ZcrP3ZaMJWTq8GSqB
Password = nuLaTjoV55VdcqfsHAmktHTukK
Password = 59dX64UPmWMhQmJnqtoBGbFwdL
Password = xBWYt7u6Qycn9HHX9vOMhVNUPj
Password = HqpvKsGqmFyr8QiNOc2mZNCtNK
Password = dpzeoPuC3LyVLK2v8uMax7Hw7i
Password = TN5WQwzM5PHOY9OVVbGOYcV4gF
Password = oUNgxWAeNt79NTdWbFftQhQeKs
Password = HKwnQQwbN9M5SaPKAUQYGF9uR4
Password = WZxefQUCKGCQMSQR2qOcxaN8Cs
Password = UfVRWRRR8zLnaSckfwkncoRLTi
Password = xNOyTXy96EvHQSXQQuacXU4k38
Password = 8zP9kp8JULxWwUg9bNFLgVyJyw
Password = EC6G4kiYEPV4vHURajhwUXE34n
Password = nLoiGPzsqCjjQg99FM7VQiT2zb
Password = pojgKJTFj3O4mL9T3eQ3czCGVz
Password = 7sq7YGxfnCAoSZgdvs8bE5EPRP
Password = VQV29UTFMLKjjcms9paSCCBFgd
Password = PcQ4QmHfxeHKJNXOqczej3jXve
Password = y4nhTf2MVPLwEQtraqi7AHxidM
Password = 8R79RFOpzsnXsQNTCPu5X9MhVE
Password = xT7iLOQyaFmwPVmCvSeNKB9fUN
Password = KbO7vWCcBsWQwkyRaxYiN2cfps
Password = XhjaL3JMwb3PosUoSGdP64gJW3
Password = sGOekTNTVf99fOA7wSBpTWEwAU
Password = Ub8eFQxE79ZWGQ9kkFJKRW9SUX
Password = 63meb9K2mArYZdgPeuxsN28KQe
Password = RjRjLM8HPPNyqQSxoQJ58CkqJF
Password = ck8XtFeON3Z6OATCRLOf3dZ56s
Password = eSx2NRqrRjGyzoUpOEoh2M9Jta
Password = RHcAGRhMMuHKeH7L5tp4JrH8pK
Password = NLjeoYxjP7YX8ELLzT4F7Aqn2x
Password = JrFbKFBpNNOmLwqMCrHTf7aCOT
Password = iZnYwpSVZwB6npS6KFsYRqTBRs
Password = S8LE3uKmLCrqnUPN7iWtZF3Y2t
Password = cRAHfJGmUh9JASKqVuahbdS2m9
Password = QTjcavaK6sRXRLCLaXwKvAOQyk
Password = Qq5AtB9RNeyn8GQqh65WWBf6A9
Password = eoO2KYhRcTQAMyBLmYOUAOfcVp
Password = 8ttOPzydHbPEiWBReMSB7XEvgP
Password = v3WzGjHaBLQVT9kKavMrse9Cvg
Password = SHNb3MQgNm4BufHW6OqXMRiwfc
Password = OMtNQ6dbFYp8ByJcqXpiyNmU9v
Password = ZoyswkUp2GqHGCMH5mnfdrMw4E
Password = gahu6MfKwtQQbGdQxerLOtQMXO
Password = QqQEP9RXQyOAkKNhjQbuo5phRy
Password = JGFEFW6fEFupEMJojS99j3PoWC
Password = YSAd6kuFeTQRfPQFdxeg6H6yU9
Password = 3QCiFEgpZ4cKtsotKtVQ2SAB34
Password = uHqoRA6Yea4nWqAhVQ9gRHHuho
Password = ETTKQ87vPta6A2Y9XbQLVbgjyw
Password = 8AQNwVSJRCL3Qgc2jUQKQUSwtW
Password = ydSg5azw4T4o6dz5FyBQh6BecP
Password = w9yKLOk9uWer93nKLCQUsscyPt
Password = 8QJd29Qg9MAuOx7B85SZLPNvvJ
Password = ON9eQKQGbRMCOnEK3MQAuajSW4
Password = gc9L33cXcveQ4gH7nQHaMggT92
Password = aYTORdPMNbAmORPJRnL9FK5wNp
Password = AzQa6Qz4mpKSNcR78SbEPAQnmn
Password = Qdy5AbBKVAnnXwqhCfTgLLTON9
Password = O336fGRh6EaNyr9GxQLTSASQ6R
Password = KLbbycMC3vQOP8s4krNQ2NHqcA
Password = Kfih2625PFBYhB5NPRi6WBTTeL
Password = Eitn9xceNwZSCFCPOFFn9NYAPq
Password = WfVpAEqhYMw2NkCpsO97VyemcQ
Password = tdg23sQbsquSOKC9u2gZUo9K3K
Password = V9L4sQYkN3rXKsaYRLRfUnRctm
Password = bGXeMJaSfCZ77sMY5HQ4yTqgjJ
Password = AmqAAzBnvhOiPwoRoW3bOpoEiL
Password = gQPPCJfQriby5FdgiqMExxzc3H
Password = YPF4R9zb7Ab6FA3kOTfMBvan2j
Password = k4aZAAiQPj5KassSiBAnxy9tBu
Password = WB2yq4objBtSCM9R8WO7UbAYn9
Password = EnBzPyQnrcQhbs5Mfsotox4qsb
Password = asUOkuQhacNYOMTYYfzHm83uye
Password = y8BcSBVOy929mF7tiL5K8fMhPu
Password = kU4Y8bXJ562EJPPGryEUkx2v4N
Warm Regards,
- K