Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "Here is the crypto update for 4.2: API: - Convert RNG interface to new style. - New AEAD interface with one SG list for AD and plain/cipher text. All external AEAD users have been converted. - New asymmetric key interface (akcipher). Algorithms: - Chacha20, Poly1305 and RFC7539 support. - New RSA implementation. - Jitter RNG. - DRBG is now seeded with both /dev/random and Jitter RNG. If kernel pool isn't ready then DRBG will be reseeded when it is. - DRBG is now the default crypto API RNG, replacing krng. - 842 compression (previously part of powerpc nx driver). Drivers: - Accelerated SHA-512 for arm64. - New Marvell CESA driver that supports DMA and more algorithms. - Updated powerpc nx 842 support. - Added support for SEC1 hardware to talitos" * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (292 commits) crypto: marvell/cesa - remove COMPILE_TEST dependency crypto: algif_aead - Temporarily disable all AEAD algorithms crypto: af_alg - Forbid the use internal algorithms crypto: echainiv - Only hold RNG during initialisation crypto: seqiv - Add compatibility support without RNG crypto: eseqiv - Offer normal cipher functionality without RNG crypto: chainiv - Offer normal cipher functionality without RNG crypto: user - Add CRYPTO_MSG_DELRNG crypto: user - Move cryptouser.h to uapi crypto: rng - Do not free default RNG when it becomes unused crypto: skcipher - Allow givencrypt to be NULL crypto: sahara - propagate the error on clk_disable_unprepare() failure crypto: rsa - fix invalid select for AKCIPHER crypto: picoxcell - Update to the current clk API crypto: nx - Check for bogus firmware properties crypto: marvell/cesa - add DT bindings documentation crypto: marvell/cesa - add support for Kirkwood and Dove SoCs crypto: marvell/cesa - add support for Orion SoCs crypto: marvell/cesa - add allhwsupport module parameter crypto: marvell/cesa - add support for all armada SoCs ...
This commit is contained in:
@@ -409,6 +409,9 @@ static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
|
||||
static DECLARE_WAIT_QUEUE_HEAD(urandom_init_wait);
|
||||
static struct fasync_struct *fasync;
|
||||
|
||||
static DEFINE_SPINLOCK(random_ready_list_lock);
|
||||
static LIST_HEAD(random_ready_list);
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* OS independent entropy store. Here are the functions which handle
|
||||
@@ -589,6 +592,22 @@ static void fast_mix(struct fast_pool *f)
|
||||
f->count++;
|
||||
}
|
||||
|
||||
static void process_random_ready_list(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct random_ready_callback *rdy, *tmp;
|
||||
|
||||
spin_lock_irqsave(&random_ready_list_lock, flags);
|
||||
list_for_each_entry_safe(rdy, tmp, &random_ready_list, list) {
|
||||
struct module *owner = rdy->owner;
|
||||
|
||||
list_del_init(&rdy->list);
|
||||
rdy->func(rdy);
|
||||
module_put(owner);
|
||||
}
|
||||
spin_unlock_irqrestore(&random_ready_list_lock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Credit (or debit) the entropy store with n bits of entropy.
|
||||
* Use credit_entropy_bits_safe() if the value comes from userspace
|
||||
@@ -660,7 +679,8 @@ retry:
|
||||
r->entropy_total = 0;
|
||||
if (r == &nonblocking_pool) {
|
||||
prandom_reseed_late();
|
||||
wake_up_interruptible(&urandom_init_wait);
|
||||
process_random_ready_list();
|
||||
wake_up_all(&urandom_init_wait);
|
||||
pr_notice("random: %s pool is initialized\n", r->name);
|
||||
}
|
||||
}
|
||||
@@ -1244,6 +1264,64 @@ void get_random_bytes(void *buf, int nbytes)
|
||||
}
|
||||
EXPORT_SYMBOL(get_random_bytes);
|
||||
|
||||
/*
|
||||
* Add a callback function that will be invoked when the nonblocking
|
||||
* pool is initialised.
|
||||
*
|
||||
* returns: 0 if callback is successfully added
|
||||
* -EALREADY if pool is already initialised (callback not called)
|
||||
* -ENOENT if module for callback is not alive
|
||||
*/
|
||||
int add_random_ready_callback(struct random_ready_callback *rdy)
|
||||
{
|
||||
struct module *owner;
|
||||
unsigned long flags;
|
||||
int err = -EALREADY;
|
||||
|
||||
if (likely(nonblocking_pool.initialized))
|
||||
return err;
|
||||
|
||||
owner = rdy->owner;
|
||||
if (!try_module_get(owner))
|
||||
return -ENOENT;
|
||||
|
||||
spin_lock_irqsave(&random_ready_list_lock, flags);
|
||||
if (nonblocking_pool.initialized)
|
||||
goto out;
|
||||
|
||||
owner = NULL;
|
||||
|
||||
list_add(&rdy->list, &random_ready_list);
|
||||
err = 0;
|
||||
|
||||
out:
|
||||
spin_unlock_irqrestore(&random_ready_list_lock, flags);
|
||||
|
||||
module_put(owner);
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(add_random_ready_callback);
|
||||
|
||||
/*
|
||||
* Delete a previously registered readiness callback function.
|
||||
*/
|
||||
void del_random_ready_callback(struct random_ready_callback *rdy)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct module *owner = NULL;
|
||||
|
||||
spin_lock_irqsave(&random_ready_list_lock, flags);
|
||||
if (!list_empty(&rdy->list)) {
|
||||
list_del_init(&rdy->list);
|
||||
owner = rdy->owner;
|
||||
}
|
||||
spin_unlock_irqrestore(&random_ready_list_lock, flags);
|
||||
|
||||
module_put(owner);
|
||||
}
|
||||
EXPORT_SYMBOL(del_random_ready_callback);
|
||||
|
||||
/*
|
||||
* This function will use the architecture-specific hardware random
|
||||
* number generator if it is available. The arch-specific hw RNG will
|
||||
|
Reference in New Issue
Block a user