diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2019-05-13 17:18:59 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2019-05-13 17:19:06 +0900 |
commit | ca673fc935cb19c6aa901b4feb03bc39a3c5e6d0 (patch) | |
tree | b540dfd0a195bb8ad7baaccae033db5e53a3f746 /sources | |
parent | 056504456659d30029525b611e4bc5bdb2b1a100 (diff) | |
download | wifi-ca673fc935cb19c6aa901b4feb03bc39a3c5e6d0.tar.gz wifi-ca673fc935cb19c6aa901b4feb03bc39a3c5e6d0.tar.bz2 wifi-ca673fc935cb19c6aa901b4feb03bc39a3c5e6d0.zip |
[WGID-253912] Do not use weak pseudo-random generatorsubmit/tizen/20190513.083717accepted/tizen/unified/20190515.084931
Change-Id: I30b90744be56241501bd757d9783f0697ff3392a
Diffstat (limited to 'sources')
-rw-r--r-- | sources/wearable/src/net/wifi_generate_pin.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/sources/wearable/src/net/wifi_generate_pin.c b/sources/wearable/src/net/wifi_generate_pin.c index e9cb90f..e310192 100644 --- a/sources/wearable/src/net/wifi_generate_pin.c +++ b/sources/wearable/src/net/wifi_generate_pin.c @@ -303,11 +303,6 @@ static int os_get_time(struct os_time *t) return res; } -static unsigned long os_random(void) -{ - return random(); -} - static int os_get_random(unsigned char *buf, size_t len) { FILE *f; @@ -441,11 +436,9 @@ unsigned int wifi_generate_pin(void) unsigned int val; /* Generate seven random digits for the PIN */ - if (random_get_bytes((unsigned char *) &val, sizeof(val)) < 0) { - struct os_time now; - os_get_time(&now); - val = os_random() ^ now.sec ^ now.usec; - } + if (random_get_bytes((unsigned char *) &val, sizeof(val)) < 0) + return 0; + val %= 10000000; /* Append checksum digit */ |