Random number generator inside kernel space
Hello all, I'm trying to implement a kernel module and I need a random number generator. Since this is a kernel module, standard functions like rand() will not work, so anybody knows what I should do in order to obtain random or pseudo random number generators? Thanks in advance
|
Actually, the kernel happens to implement a random number generator, accessible from /dev/random or /dev/urandom, or get_random_bytes().
See "Linux Kernel Development, 2nd Ed", Robert Love, Appendix B for more details. |
AFAIK, the .ko modules in 2.6 are linked from .o files (unlike 2.4 modules.) To compile those you generally feed off of the kernel makefile, but I'm sure you could find a way to link in standard libs (statically if nothing else.) I agree with paulsm4, though; /dev/urandom is the best way to go for random.
ta0kira |
All times are GMT -5. The time now is 10:41 AM. |