random.c: fix need_secure flags

* random.c (fill_random_seed): do not need to be secure, to get
  rid of blocking at the start-up time.
  [ruby-core:87462] [Bug #14837]

* random.c (random_raw_seed): expected to be a cryptographically
  secure, as documented.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-06-10 06:33:15 +00:00
Родитель 744b0bdb7b
Коммит 8389f8c3c3
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -563,7 +563,7 @@ fill_random_seed(uint32_t *seed, size_t cnt)
memset(seed, 0, len);
fill_random_bytes(seed, len, TRUE);
fill_random_bytes(seed, len, FALSE);
gettimeofday(&tv, 0);
seed[0] ^= tv.tv_usec;
@ -635,7 +635,7 @@ random_raw_seed(VALUE self, VALUE size)
long n = NUM2ULONG(size);
VALUE buf = rb_str_new(0, n);
if (n == 0) return buf;
if (fill_random_bytes(RSTRING_PTR(buf), n, FALSE))
if (fill_random_bytes(RSTRING_PTR(buf), n, TRUE))
rb_raise(rb_eRuntimeError, "failed to get urandom");
return buf;
}