--- linux-2.6.18/drivers/char/random.c 2006-09-19 23:42:06.000000000 -0400 +++ linux-2.6.18_re/drivers/char/random.c 2008-11-23 13:45:47.000000000 -0500 @@ -437,6 +437,8 @@ static struct entropy_store nonblocking_ .pool = nonblocking_pool_data }; + + /* * This function adds a byte into the entropy "pool". It does not * update the entropy estimate. The caller should call @@ -855,6 +857,24 @@ static ssize_t extract_entropy_user(stru return ret; } +//Part of Random Escrow Project +//Print Hex representation of byte_count bytes in in_buf to outbuf. +//void print_bytes_in_hex(char *in_buf, char *out_buf,int byte_count) +void print_bytes_in_hex(char *in_buf,int byte_count) +{ + int i; + unsigned char c; + unsigned int temp; + for(i=0; i < byte_count; i++) + { + c = in_buf[i]; + temp = (int)c; + printk("%02X",temp); + } +} +//End of RE Mod + + /* * This function is the exported kernel interface. It returns some * number of good random numbers, suitable for seeding TCP sequence @@ -863,6 +883,13 @@ static ssize_t extract_entropy_user(stru void get_random_bytes(void *buf, int nbytes) { extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); +//Part of Random Escrow Project + printk("get_random_bytes: %d bytes, values:",nbytes); + print_bytes_in_hex(buf, nbytes); + printk("\n"); +// printk("get_random_bytes: %d\n", nbytes); +//End of RE mods + } EXPORT_SYMBOL(get_random_bytes); @@ -950,6 +977,7 @@ random_read(struct file * file, char __u n = extract_entropy_user(&blocking_pool, buf, n); + DEBUG_ENT("read got %d bits (%d still needed)\n", n*8, (nbytes-n)*8); @@ -992,6 +1020,19 @@ random_read(struct file * file, char __u if (count) file_accessed(file); +//Part of Random Escrow Project + if (count) + { + printk("random_read: %d bytes, values:",count); + print_bytes_in_hex(buf-count, count); + printk("\n"); + +// char values_in_hex[count*2+1]; +// print_bytes_in_hex(buf-count, values_in_hex, count); +// printk("random_read: %d bytes, values: %s\n",count, values_in_hex); + } +//End of RE mod + return (count ? count : retval); } @@ -999,7 +1040,23 @@ static ssize_t urandom_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) { - return extract_entropy_user(&nonblocking_pool, buf, nbytes); +//Part of Random Escrow Project + ssize_t return_value; + return_value = extract_entropy_user(&nonblocking_pool, buf, nbytes); + + printk("urandom_read: %d bytes, values:",return_value); + print_bytes_in_hex(buf, nbytes); + printk("\n"); +// char values_in_hex[nbytes*2+1]; +// print_bytes_in_hex(buf, values_in_hex, nbytes); +// printk("urandom_read: %d bytes, values: %s\n",nbytes, values_in_hex); +// printk("urandom_read: %d\n",nbytes); + + return return_value; + +//End of RE Mods + + } static unsigned int