From: Jeff Sickel Date: Sat, 4 Jan 2014 18:53:22 +0000 (-0800) Subject: runtime: plan 9 does have /dev/random X-Git-Tag: go1.3beta1~1060 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c136197ca8a536b6fd93f0ee2a7de6c6541c0124;p=gostls13.git runtime: plan 9 does have /dev/random R=golang-codereviews, r, aram CC=0intro, golang-codereviews, rsc https://golang.org/cl/43420045 --- diff --git a/src/pkg/runtime/os_plan9.c b/src/pkg/runtime/os_plan9.c index 07db2c3055..dd2828b1d9 100644 --- a/src/pkg/runtime/os_plan9.c +++ b/src/pkg/runtime/os_plan9.c @@ -102,8 +102,18 @@ runtime·crash(void) void runtime·get_random_data(byte **rnd, int32 *rnd_len) { - *rnd = nil; - *rnd_len = 0; + static byte random_data[HashRandomBytes]; + int32 fd; + + fd = runtime·open("/dev/random", 0 /* O_RDONLY */, 0); + if(runtime·read(fd, random_data, HashRandomBytes) == HashRandomBytes) { + *rnd = random_data; + *rnd_len = HashRandomBytes; + } else { + *rnd = nil; + *rnd_len = 0; + } + runtime·close(fd); } void