History

kern/posix: remove srandom()/random() code for entropy gathering, will always use /dev/[u]random

cinap_lenrek committed 10 years ago

Commit bc73cba1 parent 62ab8e71 file · +1 −13Browse files

Unified · Split

kern/posix.c+1−13
@@ -162,37 +162,25 @@ procwakeup(Proc *p) · 161 unmodified lines
162162 pthread_mutex_unlock(&op->mutex);
163163 }
164164
165−int randfd;
165+static int randfd;
166166 #undef open
167167 void
168168 randominit(void)
169169 {
170−#ifdef USE_RANDOM
171− srandom(getpid()+fastticks(nil)+ticks());
172−#else
173170 if((randfd = open("/dev/urandom", OREAD)) < 0)
174171 if((randfd = open("/dev/random", OREAD)) < 0)
175172 panic("open /dev/random: %r");
176−#endif
177173 }
178174
179175 #undef read
180176 ulong
181177 randomread(void *v, ulong n)
182178 {
183−#ifdef USE_RANDOM
184− int i;
185−
186− for(i=0; i<n; i++)
187− ((uchar*)v)[i] = random();
188− return n;
189−#else
190179 int m;
191180
192181 if((m = read(randfd, v, n)) != n)
193182 panic("short read from /dev/random: %d but %d", n, m);
194183 return m;
195−#endif
196184 }
197185
198186 #undef time

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t