Đang chuẩn bị liên kết để tải về tài liệu:
cryptography for developers PHẦN 4
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Ultimate CD dòng sản phẩm của chúng tôi cung cấp ngân sách độc giả của chúng tôi có ý thức sưu tập một số chức danh backlist bán chạy nhất của chúng tôi ở dạng Adobe PDF. Các CD này là cách hoàn hảo để mở rộng thư viện tham khảo về các chủ đề quan trọng liên quan đến lĩnh vực chuyên môn của bạn | Random Number Generation Chapter 3 113 Keyboard and Mouse The keyboard is fairly easy to trap. We simply want the keyboard scan codes and will feed them to the RNG as a whole. For most platforms we can assume that scan codes are at most 16 bits long. Adjust accordingly to suit your platform. In the PC world the keyboard controller sends one byte if the key pressed was one of the typical alphanumeric characters. When a less frequent key is pressed such as the function keys arrow keys or keys on the number pad the keyboard controller will send two bytes. At the very least we can assume the least significant byte of the scan code will contain something and upper may not. In English text the average character has about 1.3 bits of entropy taking into account key repeats and other common sequences the lower eight bits of the scan code will likely contain at least 0.5 bits of entropy.The upper eight bits is likely to be zero so its entropy is estimated at a mere 1 16 bits. Similarly the interrupt code and high-resolution timer source are given 1 16 bits each as well. rng_src.c 004 KEYBOARD 005 void rng_keyboard int INT unsigned scancode unsigned hrt 006 007 rng_add_byte INT 1 1 16 bits 008 rng_add_byte scancode 0xFF 8 1 2 bits 009 rng_add_byte scancode 8 0xFF 1 1 16 bits 010 rng_add_byte hrt 1 timer 011 This code is callable from a keyboard which should pass the interrupt number or device ID scancode and the least significant byte of a high resolution timer. Obviously where PC AT scan codes are not being used the logic should be changed appropriately. A rough guide is to take the average entropy per character in the host language and divide it by at least two. For the mouse we basically use the same principle except instead of a scan code we use the mouse position and status. rng_src.c 013 MOUSE 014 void rng_mouse int INT int x int y int z 015 int buttons unsigned hrt 016 017 rng_add_byte INT 1 1 16 bits 018 rng_add_byte x 255 2 1 8 bits 019 rng_add_byte y 255 2 1 8 bits