lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


That's not the best solution. Only a temporary palliative that
probably does not even solve any practical problem.

Really there should be a non-global seed that can be set on separate
generators. This global seed can only be used to instantiate a new
generator (and then in Lua you can provide a better generator scheme:
the current implementation is fast, but very poor, with insufficient
insufficient for security as its hashing function is very easily
attackable, too much predictable, and does not use enough bits for its
internal state).

And from which data will you use the lua_changeseed() ? You need
access to some other entropy source if you intend to use it for
security purposes; all that can be used with it is to build
reproductible test cases with common sequences of numbers from the
PRNG, from a known constant seed used for testing purpose only (e.g.
coverage test units).


Le mer. 25 mars 2020 à 11:38, 云风 Cloud Wu <cloudwu@gmail.com> a écrit :
>
> Coda Highland <chighland@gmail.com> 于2020年3月12日周四 下午11:58写道:
> >
> > If you're already patching the VM, it shouldn't be hard to just patch the seed assignment yourself.
> >
>
> I found that we don't even have to patch the VM  :)
>
> https://gist.github.com/cloudwu/a094583029f15bb74fa6df194159d008
>
> I wrote a small function `lua_changeseed(lua_State *L, unsigned int
> seed);`  to change the seed.
>
> --
> http://blog.codingnow.com
>