linux/crypto
Stephan Mueller 5afdfd22e6 crypto: algif_rng - add random number generator support
This patch adds the random number generator support for AF_ALG.

A random number generator's purpose is to generate data without
requiring the caller to provide any data. Therefore, the AF_ALG
interface handler for RNGs only implements a callback handler for
recvmsg.

The following parameters provided with a recvmsg are processed by the
RNG callback handler:

	* sock - to resolve the RNG context data structure accessing the
	  RNG instance private to the socket

	* len - this parameter allows userspace callers to specify how
	  many random bytes the RNG shall produce and return. As the
	  kernel context for the RNG allocates a buffer of 128 bytes to
	  store random numbers before copying them to userspace, the len
	  parameter is checked that it is not larger than 128. If a
	  caller wants more random numbers, a new request for recvmsg
	  shall be made.

The size of 128 bytes is chose because of the following considerations:

	* to increase the memory footprint of the kernel too much (note,
	  that would be 128 bytes per open socket)

	* 128 is divisible by any typical cryptographic block size an
	  RNG may have

	* A request for random numbers typically only shall supply small
	  amount of data like for keys or IVs that should only require
	  one invocation of the recvmsg function.

Note, during instantiation of the RNG, the code checks whether the RNG
implementation requires seeding. If so, the RNG is seeded with output
from get_random_bytes.

A fully working example using all aspects of the RNG interface is
provided at http://www.chronox.de/libkcapi.html

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2014-12-29 21:37:59 +11:00
..
asymmetric_keys Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2014-10-12 10:13:55 -04:00
async_tx dmaengine: fix xor sources continuation 2014-08-21 10:20:52 -07:00
842.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
ablk_helper.c
ablkcipher.c crypto: ablkcipher - fixed style errors in ablkcipher.c 2014-12-22 23:02:35 +11:00
aead.c crypto: aead - fixed style error in aead.c 2014-12-22 23:02:35 +11:00
aes_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
af_alg.c crypto: af_alg - zeroize key data 2014-12-26 08:33:36 +11:00
ahash.c crypto: ahash - fixed style error in ahash.c 2014-12-22 23:02:36 +11:00
algapi.c crypto: api - fixed style erro in algapi.c 2014-12-22 23:02:37 +11:00
algboss.c
algif_hash.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2014-12-13 13:33:26 -08:00
algif_rng.c crypto: algif_rng - add random number generator support 2014-12-29 21:37:59 +11:00
algif_skcipher.c crypto: algif - Mark sgl end at the end of data 2014-12-22 23:02:41 +11:00
ansi_cprng.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
anubis.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
api.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
arc4.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
authenc.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
authencesn.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
blkcipher.c crypto: allow blkcipher walks over AEAD data 2014-03-10 20:17:11 +08:00
blowfish_common.c
blowfish_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
camellia_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
cast5_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
cast6_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
cast_common.c
cbc.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
ccm.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
chainiv.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
cipher.c
cmac.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
compress.c
crc32.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
crc32c_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
crct10dif_common.c
crct10dif_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
cryptd.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
crypto_null.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
crypto_user.c crypto: user - add MODULE_ALIAS 2014-11-26 20:06:29 +08:00
crypto_wq.c crypto: crypto_wq - Fix late crypto work queue initialization 2014-03-21 21:54:28 +08:00
ctr.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
cts.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
deflate.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
des_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
drbg.c crypto: drbg - panic on continuous self test error 2014-12-22 23:02:37 +11:00
ecb.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
eseqiv.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
fcrypt.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
fips.c
gcm.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
gf128mul.c
ghash-generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
hash_info.c
hmac.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
internal.h
Kconfig crypto: octeon - enable OCTEON MD5 module selection 2014-12-24 08:14:24 +11:00
khazad.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
krng.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
lrw.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
lz4.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
lz4hc.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
lzo.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
Makefile crypto: sha-mb - multibuffer crypto infrastructure 2014-08-25 20:32:25 +08:00
mcryptd.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
md4.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
md5.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
memneq.c crypto: memneq - fix for archs without efficient unaligned access 2013-12-09 20:09:12 +08:00
michael_mic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
pcbc.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
pcompress.c
pcrypt.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
proc.c
ripemd.h
rmd128.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
rmd160.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
rmd256.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
rmd320.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
rng.c
salsa20_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
scatterwalk.c
seed.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
seqiv.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
serpent_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
sha1_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
sha256_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
sha512_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
shash.c crypto: LLVMLinux: aligned-attribute.patch 2014-06-07 11:44:39 -07:00
tcrypt.c crypto: tcrypt - Allow speed testing of arbitrary hash functions 2014-12-05 23:57:47 +08:00
tcrypt.h crypto: tcrypt - Added speed tests for AEAD crypto alogrithms in tcrypt test suite 2013-12-20 20:06:25 +08:00
tea.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
testmgr.c crypto: testmgr - Remove unnecessary KERN_INFO from testmgr.c 2014-10-24 22:49:36 +08:00
testmgr.h crypto: testmgr - add test for lz4 and lz4hc 2014-08-29 21:46:36 +08:00
tgr192.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
twofish_common.c
twofish_generic.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
vmac.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
wp512.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
xcbc.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
xor.c
xts.c crypto: include crypto- module prefix in template 2014-11-26 20:06:30 +08:00
zlib.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00