Commit Graph

37 Commits

Author SHA1 Message Date
tls
3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
jmmv
9b52d4003a Revert my previous change. christos@ submitted a different fix pretty much
at the same time.  Did an update amd64 release build to ensure my change was
really not needed.
2011-05-14 16:46:55 +00:00
jmmv
d899efcf6e Declare for-loop control variable outside of the for statement to prevent
a warning and therefore fix the build.
2011-05-14 16:27:49 +00:00
christos
018b374686 - don't assume aligned buffers.
- little KNF
2011-05-14 01:59:19 +00:00
cbiere
f5b684cf56 Added missing const-qualifiers. 2007-01-22 01:38:33 +00:00
cbiere
6d8f729825 Added const-qualifiers. 2007-01-21 23:00:08 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
perry
477853c351 nuke trailing whitespace 2005-02-26 22:58:54 +00:00
itojun
467deb61ca rijndael-api-fst.h is not needed 2003-08-28 08:38:19 +00:00
itojun
725b73043b simplify rijndael.c API - always schedule encrypt/decrypt key.
reviewed by thorpej
2003-08-27 14:23:25 +00:00
itojun
000061139d typo 2003-08-27 03:35:35 +00:00
itojun
880bf51285 check and panic if key with wrong dir is passed 2003-08-27 02:44:19 +00:00
thorpej
793bc7ea32 Take a couple more opportunities to const poison. 2003-08-26 20:07:59 +00:00
thorpej
2d241878c0 Const poison. 2003-08-26 19:58:36 +00:00
thorpej
aa6632baa6 G/C opencrypto's local copy of rijndael. Adapt the extant rijndael
code for opencrypto's use by adding the simplified API that opencrypto
expects.
2003-08-26 14:24:05 +00:00
elric
73d81f8b40 Ensure that the IV is aligned for strict alignment machines. 2003-08-18 02:36:17 +00:00
itojun
a93a267072 make rijndael_cipherInit() to take binary IV, not hex IV, as before. 2003-07-24 14:51:34 +00:00
itojun
d931d5d70e "make regress" work under regress/sys/crypto/rijndael 2003-07-16 05:27:49 +00:00
itojun
4d4897d334 rijndael-api-fst.c is needed for cgd. pointed out by Love 2003-07-16 05:08:08 +00:00
itojun
281d9d13a5 simplify and update rijndael code. markus@openbsd 2003-07-15 11:00:36 +00:00
drochner
2d89c22fc7 sprinkle some #ifdef __LINT__ until C9X named union member
initialization is digested
2003-02-09 16:25:27 +00:00
itojun
f2187f5675 correct panic() condition - it was backwards.
From: Rafal Boni <rafal@attbi.com>
2002-11-18 23:38:46 +00:00
thorpej
0ab79d5327 * Move config defns for the crypto algorithms into their own files.
Define an attribute for each crypto algorithm, and use that attribute
  to select the files that implement the algorithm.
* Give the "wlan" attribute a dependency on the "arc4" attribute.
* Give the "cgd" pseudo-device the "des", "blowfish", "cast128", and
  "rijndael" attributes.
* Use the new attribute-as-option-dependencies feature of config(8) to
  give the IPSEC_ESP option dependencies on the "des", "blowfish", "cast128",
  and "rijndael" attributes.
2002-10-11 01:52:04 +00:00
itojun
971ec4d861 missing IV handling in CBC mode (does not affect ESP code as we have
CBC handling in sys/netinet6/esp_core.c).  sync w/kame
2002-05-24 06:28:06 +00:00
thorpej
9e94d2a9fe When compiling for userland, need <stdlib.h> for abort() prototype
(noticed by gcc 3.1).
2001-12-31 20:20:28 +00:00
lukem
2565646230 don't need <sys/types.h> when including <sys/param.h> 2001-11-15 09:47:59 +00:00
lukem
4f2ad95259 add RCSIDs 2001-11-13 00:56:55 +00:00
thorpej
05b5ee3074 bzero -> memset, bcopy -> memcpy 2001-07-18 16:50:27 +00:00
itojun
78458be84d correct binary key material handling. sync with kame 2001-05-27 01:40:16 +00:00
kleink
19f61e4df3 Need a memcpy() declaration. 2001-05-23 00:02:24 +00:00
kleink
5c9e69f795 Fix several alignment problems in this implementation due to its use of
word32 pointers to access data stored in word8 arrays:
* align transformation tables on 32-bit boundaries,
* align key schedule on 32-bit boundary,
* align temporaries on 32-bit boundaries,
* align plaintext and ciphertext used in round transformations on 32-bit
  boundaries.
2001-05-22 23:45:41 +00:00
itojun
dc3424f555 pass key to rijndael logic as binary, not hexadecimal string.
sync with kame
2001-03-02 15:42:39 +00:00
jdolecek
522f569810 make some more constant arrays 'const' 2001-02-21 21:39:52 +00:00
itojun
7236276c18 sync with kame.
- include string.h (instead of sys/systm.h) on userland compilation.
  make compilation under src/regress/sys/crypto happier.  from minoura
- (blowfish) KNF.
2000-11-06 14:11:40 +00:00
itojun
a09dcd7432 avoid assert, memcpy and memset (necessary to BSD code sharing).
sync with kame
2000-10-03 03:17:19 +00:00
itojun
b7a15a9d51 $NetBSD$ 2000-10-02 17:19:15 +00:00
itojun
e3eae405da rijndael logic, based on 2.4/from kame 2000-10-02 17:16:40 +00:00