Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 01 Oct 1995 11:04:53 +0200
From:      Mark Murray <mark@grondar.za>
To:        hackers@freebsd.org
Subject:   How to get to the hardware?
Message-ID:  <199510010904.LAA00617@grumble.grondar.za>

next in thread | raw e-mail | index | archive | help
Hi Kernel Boffin!

This is my first foray into the High Temple of Kernel Hacking (tm), and
I am desparately in deed of some guidance, please.

I am working on a device (/dev/random) to give truly nasty random numbers
for crypto/security use, and it is mostly going OK. I have some code
written by Theodore Ts'o, and it is good stuff, but it is for the Linux
kernel. Could someone please suggest to me the best way of doing the
following in the FreeBSD kernel: (I am not sure I like the concept of just
messing with the timer directly, and yes, I have had a look at microtime.s)
The bits I do not line are the outb_p() and inb_p(). There _has_ to be a
better way...

#if defined (__i386__) && 0
	/*
	 * On a 386, read the high resolution timer.  We assume that
	 * this gives us 2 bits of randomness.  XXX This needs
	 * investigation.
	 */ 
	outb_p(0x00, 0x43);	/* latch the count ASAP */
	add_entropy_byte(r, inb_p(0x40), 1);
	add_entropy_byte(r, inb(0x40), 1);
	r->entropy_count += 2;
	if (r->entropy_count > r->bit_length)
		r->entropy_count = r->bit_length;
#endif

Thanks!

M

-- 
Mark Murray
46 Harvey Rd, Claremont, Cape Town 7700, South Africa
+27 21 61-3768 GMT+0200
Finger mark@grumble.grondar.za for PGP key



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510010904.LAA00617>