-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/auto_init: cpuid as seed for random_init #5321
sys/auto_init: cpuid as seed for random_init #5321
Conversation
…ances of unique seeds
IMO it makes sense to have initialize the PRNG with something that is at least different on each board. |
Well, if a CPUID is available, this is the way to go. Simple, and for crypto safety we'd need sth else anyways. thoughts:
|
@kaspar030 why would xor be more random than add? Addition is only an xor with carry. @cgundogan I would suggest that you concatenate some bytes or integrate some bit shifts to get to the full width of the seed value, otherwise the upper 20-something bits will always be zero for a 32 bit seed value. Another option would be to use one of the functions provided by sys/hashes and sys/checksum. |
@cgundogan how about using #5153 instead to get a random value and add CPUID as a fallback random value? |
@cgundogan Could you factor out the code from auto_init somewhere into sys/prng, so auto_init.c gets less cluttered? Also maybe call it for every PRNG, not just tinymt. |
PRs about RNG should be postponed, since there are several addressing similar issues. |
Postponed due to feature freeze |
@cgundogan, what's up? |
|
Choose a sane seed number instead of defaulting to
0
. This PR utilizes thecpuid
, if present.Rationale: Trickle timers rely on random offsets to generate increasing intervals. This way, if a network protocol relies on trickle timers, packets of different nodes will not be sent at the same time, but with a little offset applied.
Currently, in case of RPL, many nodes send out DIO messages at the same time, because the "randomness" is the same for all nodes (same seed, and booted at same time).