發表文章

目前顯示的是 5月, 2009的文章

/dev/random v.s. /dev/urandom

之前在 Openswan Porting 的時候,遇到一個問題: 為甚麼無法順利產生 RSA 所需要的 Key ? 整個程式看起來毫無反應?? 其實理由很簡單,因為在產生金鑰的過程,Linux 是透過 /dev/random 去產生所需要的亂數。但是當系統覺得「無法產生夠亂的數」時,應用程式就會被 /dev/random 鎖在那個地方,直到能提供亂數為止。 下面是關於 /dev/random 的介紹: In Unix-like operating systems, /dev/random is a special file that serves as a true random number generator or as a pseudorandom number generator. Random number generator from kernel space was first time implemented for Linux[1] in 1994 by Theodore Ts'o. The implementation uses secure hashes rather than ciphers. The implementation was also designed with the assumption that any given hash or cipher might eventually be found to be weak, and so the design is durable in the face of any such weaknesses. Fast recovery from pool compromise is not considered a requirement , because the requirements for pool compromise are sufficient for much easier and more direct attacks on unrelated parts of the operating system. In this implementation, the generator keeps an estimate of the number of bi...

Linux Library Inroduction

節錄自 http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/ What is the static library ? Static libraries are simply a collection of ordinary object files; conventionally, static libraries end with the .a suffix. This collection is created using the ar (archiver) program, like: ar rcs my_library.a file1.o file2.o In theory, code in static ELF libraries that is linked into an executable should run slightly faster (by 1-5%) than a shared library or a dynamically loaded library, but in practice this rarely seems to be the case due to other confounding factors. Once you've created a static library, you'll want to use it. You can use a static library by invoking it as part of the compilation and linking process when creating a program executable. If you're using gcc(1) to generate your executable, you can use the -l option to specify the library. Be careful about the order of the parameters when using gcc; the -l option is a linker option, and thus needs to be placed AFT...