History log of /openbsd-current/lib/libc/net/res_random.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.26 27-Dec-2022 jmc

spelling fixes; from paul tagliamonte
any changes not taken noted on tech, but chiefly here i did not take the
cancelation - cancellation changes;


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.25 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.24 05-Apr-2016 guenther

Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary.

ok mpi@, ok&tweak natano@


Revision tags: OPENBSD_5_9_BASE
# 1.23 05-Oct-2015 guenther

Wrap <resolv.h> so that internal calls go direct

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.22 04-Jun-2015 eric

force reseeding if pid has changed.

ok deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 20-Jul-2014 guenther

From ISO/IEC 9899:1999 and 9899:201x,
6.11.5 - Storage-class specifiers:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is
an obsolescent feature.

Diff from Jean-Philippe Ouellet (jean-philippe (at) ouellet.biz)


Revision tags: OPENBSD_5_5_BASE
# 1.20 12-Nov-2013 deraadt

permute15() should be static. Not cranking libc now, because it is
not urgent.


Revision tags: OPENBSD_5_4_BASE
# 1.19 17-Apr-2013 deraadt

use CLOCK_MONOTONIC, and repair future time_t overflow
ok millert guenther


# 1.18 26-Mar-2013 eric

protect the PRG state with a mutex in res_randomid().

ok deraadt@ guenther@ djm@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.17 13-Apr-2008 djm

Improve the libc DNS resolver ID generation algorithm to be more
resistant to prediction atacks by wrapping the existing LCG in a
random permutation generator based on a Luby-Rackoff block cipher.

lots of discussion and final ok deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 25-Mar-2005 otto

ansify. ok deraadt@ moritz@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.15 12-Dec-2003 itojun

niels kindly dropped clause 3/4 from the license. tnx!


# 1.14 12-Dec-2003 itojun

we can skip arc4random() call here. markus


# 1.13 10-Dec-2003 itojun

correct non-repetitive ID code, based on comments from niels provos.
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
the repetition period to 30000)


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.12 27-Jun-2002 itojun

%d -> %u. mostly in #ifdef DEBUG.


Revision tags: OPENBSD_3_1_BASE
# 1.11 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.10 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.9 04-Jan-2001 todd

grammer/spelling


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 26-Aug-1999 provos

add an inner xor to make prediction attacks against the ids harder, due
to an attack pointed out by David Wagner.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


Revision tags: OPENBSD_2_1_BASE
# 1.6 30-Apr-1997 tholo

Be more careful about possible type promotion


# 1.5 25-Apr-1997 provos

skipped too many ids


# 1.4 23-Apr-1997 provos

pmod to u_int16_t, Angelos kindly reminded me


# 1.3 19-Apr-1997 provos

change time() to gettimeofday()


# 1.2 19-Apr-1997 provos

make things more complicated.


# 1.1 13-Apr-1997 provos

the before mentioned random number generator.


# 1.25 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.24 05-Apr-2016 guenther

Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary.

ok mpi@, ok&tweak natano@


Revision tags: OPENBSD_5_9_BASE
# 1.23 05-Oct-2015 guenther

Wrap <resolv.h> so that internal calls go direct

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.22 04-Jun-2015 eric

force reseeding if pid has changed.

ok deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 20-Jul-2014 guenther

From ISO/IEC 9899:1999 and 9899:201x,
6.11.5 - Storage-class specifiers:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is
an obsolescent feature.

Diff from Jean-Philippe Ouellet (jean-philippe (at) ouellet.biz)


Revision tags: OPENBSD_5_5_BASE
# 1.20 12-Nov-2013 deraadt

permute15() should be static. Not cranking libc now, because it is
not urgent.


Revision tags: OPENBSD_5_4_BASE
# 1.19 17-Apr-2013 deraadt

use CLOCK_MONOTONIC, and repair future time_t overflow
ok millert guenther


# 1.18 26-Mar-2013 eric

protect the PRG state with a mutex in res_randomid().

ok deraadt@ guenther@ djm@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.17 13-Apr-2008 djm

Improve the libc DNS resolver ID generation algorithm to be more
resistant to prediction atacks by wrapping the existing LCG in a
random permutation generator based on a Luby-Rackoff block cipher.

lots of discussion and final ok deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 25-Mar-2005 otto

ansify. ok deraadt@ moritz@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.15 12-Dec-2003 itojun

niels kindly dropped clause 3/4 from the license. tnx!


# 1.14 12-Dec-2003 itojun

we can skip arc4random() call here. markus


# 1.13 10-Dec-2003 itojun

correct non-repetitive ID code, based on comments from niels provos.
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
the repetition period to 30000)


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.12 27-Jun-2002 itojun

%d -> %u. mostly in #ifdef DEBUG.


Revision tags: OPENBSD_3_1_BASE
# 1.11 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.10 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.9 04-Jan-2001 todd

grammer/spelling


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 26-Aug-1999 provos

add an inner xor to make prediction attacks against the ids harder, due
to an attack pointed out by David Wagner.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


Revision tags: OPENBSD_2_1_BASE
# 1.6 30-Apr-1997 tholo

Be more careful about possible type promotion


# 1.5 25-Apr-1997 provos

skipped too many ids


# 1.4 23-Apr-1997 provos

pmod to u_int16_t, Angelos kindly reminded me


# 1.3 19-Apr-1997 provos

change time() to gettimeofday()


# 1.2 19-Apr-1997 provos

make things more complicated.


# 1.1 13-Apr-1997 provos

the before mentioned random number generator.


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.24 05-Apr-2016 guenther

Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary.

ok mpi@, ok&tweak natano@


Revision tags: OPENBSD_5_9_BASE
# 1.23 05-Oct-2015 guenther

Wrap <resolv.h> so that internal calls go direct

ok millert@


Revision tags: OPENBSD_5_8_BASE
# 1.22 04-Jun-2015 eric

force reseeding if pid has changed.

ok deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.21 20-Jul-2014 guenther

From ISO/IEC 9899:1999 and 9899:201x,
6.11.5 - Storage-class specifiers:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is
an obsolescent feature.

Diff from Jean-Philippe Ouellet (jean-philippe (at) ouellet.biz)


Revision tags: OPENBSD_5_5_BASE
# 1.20 12-Nov-2013 deraadt

permute15() should be static. Not cranking libc now, because it is
not urgent.


Revision tags: OPENBSD_5_4_BASE
# 1.19 17-Apr-2013 deraadt

use CLOCK_MONOTONIC, and repair future time_t overflow
ok millert guenther


# 1.18 26-Mar-2013 eric

protect the PRG state with a mutex in res_randomid().

ok deraadt@ guenther@ djm@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.17 13-Apr-2008 djm

Improve the libc DNS resolver ID generation algorithm to be more
resistant to prediction atacks by wrapping the existing LCG in a
random permutation generator based on a Luby-Rackoff block cipher.

lots of discussion and final ok deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 25-Mar-2005 otto

ansify. ok deraadt@ moritz@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.15 12-Dec-2003 itojun

niels kindly dropped clause 3/4 from the license. tnx!


# 1.14 12-Dec-2003 itojun

we can skip arc4random() call here. markus


# 1.13 10-Dec-2003 itojun

correct non-repetitive ID code, based on comments from niels provos.
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
the repetition period to 30000)


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.12 27-Jun-2002 itojun

%d -> %u. mostly in #ifdef DEBUG.


Revision tags: OPENBSD_3_1_BASE
# 1.11 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


# 1.10 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.9 04-Jan-2001 todd

grammer/spelling


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 26-Aug-1999 provos

add an inner xor to make prediction attacks against the ids harder, due
to an attack pointed out by David Wagner.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


Revision tags: OPENBSD_2_1_BASE
# 1.6 30-Apr-1997 tholo

Be more careful about possible type promotion


# 1.5 25-Apr-1997 provos

skipped too many ids


# 1.4 23-Apr-1997 provos

pmod to u_int16_t, Angelos kindly reminded me


# 1.3 19-Apr-1997 provos

change time() to gettimeofday()


# 1.2 19-Apr-1997 provos

make things more complicated.


# 1.1 13-Apr-1997 provos

the before mentioned random number generator.