LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Random number generator inside kernel space (https://www.linuxquestions.org/questions/programming-9/random-number-generator-inside-kernel-space-396313/)

zirtik 12-24-2005 05:44 PM

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

paulsm4 12-24-2005 06:45 PM

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.

ta0kira 12-26-2005 04:02 PM

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 11:51 PM.