Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: - add multibuffer infrastructure (single_task_running scheduler helper, OKed by Peter on lkml. - add SHA1 multibuffer implementation for AVX2. - reenable "by8" AVX CTR optimisation after fixing counter overflow. - add APM X-Gene SoC RNG support. - SHA256/SHA512 now handles unaligned input correctly. - set lz4 decompressed length correctly. - fix algif socket buffer allocation failure for 64K page machines. - misc fixes * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (47 commits) crypto: sha - Handle unaligned input data in generic sha256 and sha512. Revert "crypto: aesni - disable "by8" AVX CTR optimization" crypto: aesni - remove unused defines in "by8" variant crypto: aesni - fix counter overflow handling in "by8" variant hwrng: printk replacement crypto: qat - Removed unneeded partial state crypto: qat - Fix typo in name of tasklet_struct crypto: caam - Dynamic allocation of addresses for various memory blocks in CAAM. crypto: mcryptd - Fix typos in CRYPTO_MCRYPTD description crypto: algif - avoid excessive use of socket buffer in skcipher arm64: dts: add random number generator dts node to APM X-Gene platform. Documentation: rng: Add X-Gene SoC RNG driver documentation hwrng: xgene - add support for APM X-Gene SoC RNG support crypto: mv_cesa - Add missing #define crypto: testmgr - add test for lz4 and lz4hc crypto: lz4,lz4hc - fix decompression crypto: qat - Use pci_enable_msix_exact() instead of pci_enable_msix() crypto: drbg - fix maximum value checks on 32 bit systems crypto: drbg - fix sparse warning for cpu_to_be[32|64] crypto: sha-mb - sha1_mb_alg_state can be static ...
This commit is contained in:
+6
-13
@@ -82,15 +82,6 @@ typedef uint32_t drbg_flag_t;
|
||||
struct drbg_core {
|
||||
drbg_flag_t flags; /* flags for the cipher */
|
||||
__u8 statelen; /* maximum state length */
|
||||
/*
|
||||
* maximum length of personalization string or additional input
|
||||
* string -- exponent for base 2
|
||||
*/
|
||||
__u8 max_addtllen;
|
||||
/* maximum bits per RNG request -- exponent for base 2*/
|
||||
__u8 max_bits;
|
||||
/* maximum number of requests -- exponent for base 2 */
|
||||
__u8 max_req;
|
||||
__u8 blocklen_bytes; /* block size of output in bytes */
|
||||
char cra_name[CRYPTO_MAX_ALG_NAME]; /* mapping to kernel crypto API */
|
||||
/* kernel crypto API backend cipher name */
|
||||
@@ -156,12 +147,13 @@ static inline __u8 drbg_keylen(struct drbg_state *drbg)
|
||||
|
||||
static inline size_t drbg_max_request_bytes(struct drbg_state *drbg)
|
||||
{
|
||||
/* max_bits is in bits, but buflen is in bytes */
|
||||
return (1 << (drbg->core->max_bits - 3));
|
||||
/* SP800-90A requires the limit 2**19 bits, but we return bytes */
|
||||
return (1 << 16);
|
||||
}
|
||||
|
||||
static inline size_t drbg_max_addtl(struct drbg_state *drbg)
|
||||
{
|
||||
/* SP800-90A requires 2**35 bytes additional info str / pers str */
|
||||
#if (__BITS_PER_LONG == 32)
|
||||
/*
|
||||
* SP800-90A allows smaller maximum numbers to be returned -- we
|
||||
@@ -170,16 +162,17 @@ static inline size_t drbg_max_addtl(struct drbg_state *drbg)
|
||||
*/
|
||||
return (SIZE_MAX - 1);
|
||||
#else
|
||||
return (1UL<<(drbg->core->max_addtllen));
|
||||
return (1UL<<35);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline size_t drbg_max_requests(struct drbg_state *drbg)
|
||||
{
|
||||
/* SP800-90A requires 2**48 maximum requests before reseeding */
|
||||
#if (__BITS_PER_LONG == 32)
|
||||
return SIZE_MAX;
|
||||
#else
|
||||
return (1UL<<(drbg->core->max_req));
|
||||
return (1UL<<48);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,15 @@ int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
|
||||
int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc);
|
||||
int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
|
||||
|
||||
int shash_ahash_mcryptd_update(struct ahash_request *req,
|
||||
struct shash_desc *desc);
|
||||
int shash_ahash_mcryptd_final(struct ahash_request *req,
|
||||
struct shash_desc *desc);
|
||||
int shash_ahash_mcryptd_finup(struct ahash_request *req,
|
||||
struct shash_desc *desc);
|
||||
int shash_ahash_mcryptd_digest(struct ahash_request *req,
|
||||
struct shash_desc *desc);
|
||||
|
||||
int crypto_init_shash_ops_async(struct crypto_tfm *tfm);
|
||||
|
||||
static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Software async multibuffer crypto daemon headers
|
||||
*
|
||||
* Author:
|
||||
* Tim Chen <tim.c.chen@linux.intel.com>
|
||||
*
|
||||
* Copyright (c) 2014, Intel Corporation.
|
||||
*/
|
||||
|
||||
#ifndef _CRYPTO_MCRYPT_H
|
||||
#define _CRYPTO_MCRYPT_H
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <crypto/hash.h>
|
||||
|
||||
struct mcryptd_ahash {
|
||||
struct crypto_ahash base;
|
||||
};
|
||||
|
||||
static inline struct mcryptd_ahash *__mcryptd_ahash_cast(
|
||||
struct crypto_ahash *tfm)
|
||||
{
|
||||
return (struct mcryptd_ahash *)tfm;
|
||||
}
|
||||
|
||||
struct mcryptd_cpu_queue {
|
||||
struct crypto_queue queue;
|
||||
struct work_struct work;
|
||||
};
|
||||
|
||||
struct mcryptd_queue {
|
||||
struct mcryptd_cpu_queue __percpu *cpu_queue;
|
||||
};
|
||||
|
||||
struct mcryptd_instance_ctx {
|
||||
struct crypto_spawn spawn;
|
||||
struct mcryptd_queue *queue;
|
||||
};
|
||||
|
||||
struct mcryptd_hash_ctx {
|
||||
struct crypto_shash *child;
|
||||
struct mcryptd_alg_state *alg_state;
|
||||
};
|
||||
|
||||
struct mcryptd_tag {
|
||||
/* seq number of request */
|
||||
unsigned seq_num;
|
||||
/* arrival time of request */
|
||||
unsigned long arrival;
|
||||
unsigned long expire;
|
||||
int cpu;
|
||||
};
|
||||
|
||||
struct mcryptd_hash_request_ctx {
|
||||
struct list_head waiter;
|
||||
crypto_completion_t complete;
|
||||
struct mcryptd_tag tag;
|
||||
struct crypto_hash_walk walk;
|
||||
u8 *out;
|
||||
int flag;
|
||||
struct shash_desc desc;
|
||||
};
|
||||
|
||||
struct mcryptd_ahash *mcryptd_alloc_ahash(const char *alg_name,
|
||||
u32 type, u32 mask);
|
||||
struct crypto_shash *mcryptd_ahash_child(struct mcryptd_ahash *tfm);
|
||||
struct shash_desc *mcryptd_shash_desc(struct ahash_request *req);
|
||||
void mcryptd_free_ahash(struct mcryptd_ahash *tfm);
|
||||
void mcryptd_flusher(struct work_struct *work);
|
||||
|
||||
enum mcryptd_req_type {
|
||||
MCRYPTD_NONE,
|
||||
MCRYPTD_UPDATE,
|
||||
MCRYPTD_FINUP,
|
||||
MCRYPTD_DIGEST,
|
||||
MCRYPTD_FINAL
|
||||
};
|
||||
|
||||
struct mcryptd_alg_cstate {
|
||||
unsigned long next_flush;
|
||||
unsigned next_seq_num;
|
||||
bool flusher_engaged;
|
||||
struct delayed_work flush;
|
||||
int cpu;
|
||||
struct mcryptd_alg_state *alg_state;
|
||||
void *mgr;
|
||||
spinlock_t work_lock;
|
||||
struct list_head work_list;
|
||||
struct list_head flush_list;
|
||||
};
|
||||
|
||||
struct mcryptd_alg_state {
|
||||
struct mcryptd_alg_cstate __percpu *alg_cstate;
|
||||
unsigned long (*flusher)(struct mcryptd_alg_cstate *cstate);
|
||||
};
|
||||
|
||||
/* return delay in jiffies from current time */
|
||||
static inline unsigned long get_delay(unsigned long t)
|
||||
{
|
||||
long delay;
|
||||
|
||||
delay = (long) t - (long) jiffies;
|
||||
if (delay <= 0)
|
||||
return 0;
|
||||
else
|
||||
return (unsigned long) delay;
|
||||
}
|
||||
|
||||
void mcryptd_arm_flusher(struct mcryptd_alg_cstate *cstate, unsigned long delay);
|
||||
|
||||
#endif
|
||||
@@ -167,6 +167,7 @@ extern int nr_threads;
|
||||
DECLARE_PER_CPU(unsigned long, process_counts);
|
||||
extern int nr_processes(void);
|
||||
extern unsigned long nr_running(void);
|
||||
extern bool single_task_running(void);
|
||||
extern unsigned long nr_iowait(void);
|
||||
extern unsigned long nr_iowait_cpu(int cpu);
|
||||
extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
|
||||
|
||||
Reference in New Issue
Block a user