[klibc] [PATCH] add mkstemp(3) using entropy from ELF aux vector AT_RANDOM

Thorsten Glaser tg at mirbsd.de
Wed Feb 1 12:55:11 PST 2012


H. Peter Anvin dixit:

>> +/* for use with jrand48() and friends */
>> +unsigned short __klibc_rand48[3];

>I suspect this kind of automatic seeding violates the POSIX definitions
>of these functions.  Not 100% sure though.

It's not touching the POSIX-mandated stuff (and anyway,
r(0)=0x1234abcd330e isn’t given in klibc, it has r(0)=0
unless the application calls srand48()) but rather is a
second state that can be passed to jrand48() by “stuff”
(klibc code and, in theory, user code). Not 100% secure
either, but very minimalistic. This is really a we want
something sorta random, and not time-or-PID based to be
not _too_ predictable, but not bulletproof either as it
will mostly¹ be used during early userspace, PRNG in as
few bytes (of .text .rodata .data .bss and .stack) as I
could get it.

My offer of hacking a minimal but state-of-the-art aRC4
based stretching-RNG still stands, it’ll probably eat a
few dozen bytes of code and at least 252 bytes more RAM
(more to avoid a startup time penalty for every binary,
even those that don’t use it) though.

① long-term plan of /bin/mksh-static on Debian notwith‐
  standing of course; that would be usable during a sy‐
  stem’s entire lifetime

bye,
//mirabilos
-- 
> Hi, does anyone sell openbsd stickers by themselves and not packaged
> with other products?
No, the only way I've seen them sold is for $40 with a free OpenBSD CD.
	-- Haroon Khalid and Steve Shockley in gmane.os.openbsd.misc



More information about the klibc mailing list