Merge 84c7d76b5a ("Merge tag 'v6.10-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6") into android-mainline
Steps on the way to 6.10-rc1 Change-Id: I2acff066e36eaca376e30adab40057e029cc7de8 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -56,31 +56,7 @@ struct crypto_acomp {
|
||||
struct crypto_tfm base;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct crypto_istat_compress - statistics for compress algorithm
|
||||
* @compress_cnt: number of compress requests
|
||||
* @compress_tlen: total data size handled by compress requests
|
||||
* @decompress_cnt: number of decompress requests
|
||||
* @decompress_tlen: total data size handled by decompress requests
|
||||
* @err_cnt: number of error for compress requests
|
||||
*/
|
||||
struct crypto_istat_compress {
|
||||
atomic64_t compress_cnt;
|
||||
atomic64_t compress_tlen;
|
||||
atomic64_t decompress_cnt;
|
||||
atomic64_t decompress_tlen;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
#define COMP_ALG_COMMON_STATS struct crypto_istat_compress stat;
|
||||
#else
|
||||
#define COMP_ALG_COMMON_STATS
|
||||
#endif
|
||||
|
||||
#define COMP_ALG_COMMON { \
|
||||
COMP_ALG_COMMON_STATS \
|
||||
\
|
||||
struct crypto_alg base; \
|
||||
}
|
||||
struct comp_alg_common COMP_ALG_COMMON;
|
||||
@@ -261,27 +237,6 @@ static inline void acomp_request_set_params(struct acomp_req *req,
|
||||
req->flags |= CRYPTO_ACOMP_ALLOC_OUTPUT;
|
||||
}
|
||||
|
||||
static inline struct crypto_istat_compress *comp_get_stat(
|
||||
struct comp_alg_common *alg)
|
||||
{
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
return &alg->stat;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int crypto_comp_errstat(struct comp_alg_common *alg, int err)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
return err;
|
||||
|
||||
if (err && err != -EINPROGRESS && err != -EBUSY)
|
||||
atomic64_inc(&comp_get_stat(alg)->err_cnt);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_acomp_compress() -- Invoke asynchronous compress operation
|
||||
*
|
||||
@@ -293,19 +248,7 @@ static inline int crypto_comp_errstat(struct comp_alg_common *alg, int err)
|
||||
*/
|
||||
static inline int crypto_acomp_compress(struct acomp_req *req)
|
||||
{
|
||||
struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
|
||||
struct comp_alg_common *alg;
|
||||
|
||||
alg = crypto_comp_alg_common(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS)) {
|
||||
struct crypto_istat_compress *istat = comp_get_stat(alg);
|
||||
|
||||
atomic64_inc(&istat->compress_cnt);
|
||||
atomic64_add(req->slen, &istat->compress_tlen);
|
||||
}
|
||||
|
||||
return crypto_comp_errstat(alg, tfm->compress(req));
|
||||
return crypto_acomp_reqtfm(req)->compress(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,19 +262,7 @@ static inline int crypto_acomp_compress(struct acomp_req *req)
|
||||
*/
|
||||
static inline int crypto_acomp_decompress(struct acomp_req *req)
|
||||
{
|
||||
struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
|
||||
struct comp_alg_common *alg;
|
||||
|
||||
alg = crypto_comp_alg_common(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS)) {
|
||||
struct crypto_istat_compress *istat = comp_get_stat(alg);
|
||||
|
||||
atomic64_inc(&istat->decompress_cnt);
|
||||
atomic64_add(req->slen, &istat->decompress_tlen);
|
||||
}
|
||||
|
||||
return crypto_comp_errstat(alg, tfm->decompress(req));
|
||||
return crypto_acomp_reqtfm(req)->decompress(req);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -101,22 +101,6 @@ struct aead_request {
|
||||
void *__ctx[] CRYPTO_MINALIGN_ATTR;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct crypto_istat_aead - statistics for AEAD algorithm
|
||||
* @encrypt_cnt: number of encrypt requests
|
||||
* @encrypt_tlen: total data size handled by encrypt requests
|
||||
* @decrypt_cnt: number of decrypt requests
|
||||
* @decrypt_tlen: total data size handled by decrypt requests
|
||||
* @err_cnt: number of error for AEAD requests
|
||||
*/
|
||||
struct crypto_istat_aead {
|
||||
atomic64_t encrypt_cnt;
|
||||
atomic64_t encrypt_tlen;
|
||||
atomic64_t decrypt_cnt;
|
||||
atomic64_t decrypt_tlen;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct aead_alg - AEAD cipher definition
|
||||
* @maxauthsize: Set the maximum authentication tag size supported by the
|
||||
@@ -135,7 +119,6 @@ struct crypto_istat_aead {
|
||||
* @setkey: see struct skcipher_alg
|
||||
* @encrypt: see struct skcipher_alg
|
||||
* @decrypt: see struct skcipher_alg
|
||||
* @stat: statistics for AEAD algorithm
|
||||
* @ivsize: see struct skcipher_alg
|
||||
* @chunksize: see struct skcipher_alg
|
||||
* @init: Initialize the cryptographic transformation object. This function
|
||||
@@ -162,10 +145,6 @@ struct aead_alg {
|
||||
int (*init)(struct crypto_aead *tfm);
|
||||
void (*exit)(struct crypto_aead *tfm);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
struct crypto_istat_aead stat;
|
||||
#endif
|
||||
|
||||
unsigned int ivsize;
|
||||
unsigned int maxauthsize;
|
||||
unsigned int chunksize;
|
||||
|
||||
@@ -54,26 +54,6 @@ struct crypto_akcipher {
|
||||
struct crypto_tfm base;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct crypto_istat_akcipher - statistics for akcipher algorithm
|
||||
* @encrypt_cnt: number of encrypt requests
|
||||
* @encrypt_tlen: total data size handled by encrypt requests
|
||||
* @decrypt_cnt: number of decrypt requests
|
||||
* @decrypt_tlen: total data size handled by decrypt requests
|
||||
* @verify_cnt: number of verify operation
|
||||
* @sign_cnt: number of sign requests
|
||||
* @err_cnt: number of error for akcipher requests
|
||||
*/
|
||||
struct crypto_istat_akcipher {
|
||||
atomic64_t encrypt_cnt;
|
||||
atomic64_t encrypt_tlen;
|
||||
atomic64_t decrypt_cnt;
|
||||
atomic64_t decrypt_tlen;
|
||||
atomic64_t verify_cnt;
|
||||
atomic64_t sign_cnt;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct akcipher_alg - generic public key algorithm
|
||||
*
|
||||
@@ -110,7 +90,6 @@ struct crypto_istat_akcipher {
|
||||
* @exit: Deinitialize the cryptographic transformation object. This is a
|
||||
* counterpart to @init, used to remove various changes set in
|
||||
* @init.
|
||||
* @stat: Statistics for akcipher algorithm
|
||||
*
|
||||
* @base: Common crypto API algorithm data structure
|
||||
*/
|
||||
@@ -127,10 +106,6 @@ struct akcipher_alg {
|
||||
int (*init)(struct crypto_akcipher *tfm);
|
||||
void (*exit)(struct crypto_akcipher *tfm);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
struct crypto_istat_akcipher stat;
|
||||
#endif
|
||||
|
||||
struct crypto_alg base;
|
||||
};
|
||||
|
||||
@@ -302,27 +277,6 @@ static inline unsigned int crypto_akcipher_maxsize(struct crypto_akcipher *tfm)
|
||||
return alg->max_size(tfm);
|
||||
}
|
||||
|
||||
static inline struct crypto_istat_akcipher *akcipher_get_stat(
|
||||
struct akcipher_alg *alg)
|
||||
{
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
return &alg->stat;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int crypto_akcipher_errstat(struct akcipher_alg *alg, int err)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
return err;
|
||||
|
||||
if (err && err != -EINPROGRESS && err != -EBUSY)
|
||||
atomic64_inc(&akcipher_get_stat(alg)->err_cnt);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_akcipher_encrypt() - Invoke public key encrypt operation
|
||||
*
|
||||
@@ -336,16 +290,8 @@ static inline int crypto_akcipher_errstat(struct akcipher_alg *alg, int err)
|
||||
static inline int crypto_akcipher_encrypt(struct akcipher_request *req)
|
||||
{
|
||||
struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
|
||||
struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS)) {
|
||||
struct crypto_istat_akcipher *istat = akcipher_get_stat(alg);
|
||||
|
||||
atomic64_inc(&istat->encrypt_cnt);
|
||||
atomic64_add(req->src_len, &istat->encrypt_tlen);
|
||||
}
|
||||
|
||||
return crypto_akcipher_errstat(alg, alg->encrypt(req));
|
||||
return crypto_akcipher_alg(tfm)->encrypt(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,16 +307,8 @@ static inline int crypto_akcipher_encrypt(struct akcipher_request *req)
|
||||
static inline int crypto_akcipher_decrypt(struct akcipher_request *req)
|
||||
{
|
||||
struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
|
||||
struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS)) {
|
||||
struct crypto_istat_akcipher *istat = akcipher_get_stat(alg);
|
||||
|
||||
atomic64_inc(&istat->decrypt_cnt);
|
||||
atomic64_add(req->src_len, &istat->decrypt_tlen);
|
||||
}
|
||||
|
||||
return crypto_akcipher_errstat(alg, alg->decrypt(req));
|
||||
return crypto_akcipher_alg(tfm)->decrypt(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,12 +360,8 @@ int crypto_akcipher_sync_decrypt(struct crypto_akcipher *tfm,
|
||||
static inline int crypto_akcipher_sign(struct akcipher_request *req)
|
||||
{
|
||||
struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
|
||||
struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
atomic64_inc(&akcipher_get_stat(alg)->sign_cnt);
|
||||
|
||||
return crypto_akcipher_errstat(alg, alg->sign(req));
|
||||
return crypto_akcipher_alg(tfm)->sign(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,12 +381,8 @@ static inline int crypto_akcipher_sign(struct akcipher_request *req)
|
||||
static inline int crypto_akcipher_verify(struct akcipher_request *req)
|
||||
{
|
||||
struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
|
||||
struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
atomic64_inc(&akcipher_get_stat(alg)->verify_cnt);
|
||||
|
||||
return crypto_akcipher_errstat(alg, alg->verify(req));
|
||||
return crypto_akcipher_alg(tfm)->verify(req);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,9 +61,6 @@ struct crypto_type {
|
||||
void (*show)(struct seq_file *m, struct crypto_alg *alg);
|
||||
int (*report)(struct sk_buff *skb, struct crypto_alg *alg);
|
||||
void (*free)(struct crypto_instance *inst);
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
int (*report_stat)(struct sk_buff *skb, struct crypto_alg *alg);
|
||||
#endif
|
||||
|
||||
unsigned int type;
|
||||
unsigned int maskclear;
|
||||
|
||||
@@ -23,6 +23,7 @@ struct ecc_point {
|
||||
* struct ecc_curve - definition of elliptic curve
|
||||
*
|
||||
* @name: Short name of the curve.
|
||||
* @nbits: The number of bits of a curve.
|
||||
* @g: Generator point of the curve.
|
||||
* @p: Prime number, if Barrett's reduction is used for this curve
|
||||
* pre-calculated value 'mu' is appended to the @p after ndigits.
|
||||
@@ -34,6 +35,7 @@ struct ecc_point {
|
||||
*/
|
||||
struct ecc_curve {
|
||||
char *name;
|
||||
u32 nbits;
|
||||
struct ecc_point g;
|
||||
u64 *p;
|
||||
u64 *n;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define ECC_CURVE_NIST_P192 0x0001
|
||||
#define ECC_CURVE_NIST_P256 0x0002
|
||||
#define ECC_CURVE_NIST_P384 0x0003
|
||||
#define ECC_CURVE_NIST_P521 0x0004
|
||||
|
||||
/**
|
||||
* struct ecdh - define an ECDH private key
|
||||
|
||||
@@ -23,27 +23,8 @@ struct crypto_ahash;
|
||||
* crypto_unregister_shash().
|
||||
*/
|
||||
|
||||
/*
|
||||
* struct crypto_istat_hash - statistics for has algorithm
|
||||
* @hash_cnt: number of hash requests
|
||||
* @hash_tlen: total data size hashed
|
||||
* @err_cnt: number of error for hash requests
|
||||
*/
|
||||
struct crypto_istat_hash {
|
||||
atomic64_t hash_cnt;
|
||||
atomic64_t hash_tlen;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
#define HASH_ALG_COMMON_STAT struct crypto_istat_hash stat;
|
||||
#else
|
||||
#define HASH_ALG_COMMON_STAT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* struct hash_alg_common - define properties of message digest
|
||||
* @stat: Statistics for hash algorithm.
|
||||
* @digestsize: Size of the result of the transformation. A buffer of this size
|
||||
* must be available to the @final and @finup calls, so they can
|
||||
* store the resulting hash into it. For various predefined sizes,
|
||||
@@ -60,8 +41,6 @@ struct crypto_istat_hash {
|
||||
* information.
|
||||
*/
|
||||
#define HASH_ALG_COMMON { \
|
||||
HASH_ALG_COMMON_STAT \
|
||||
\
|
||||
unsigned int digestsize; \
|
||||
unsigned int statesize; \
|
||||
\
|
||||
@@ -243,7 +222,6 @@ struct shash_alg {
|
||||
};
|
||||
};
|
||||
#undef HASH_ALG_COMMON
|
||||
#undef HASH_ALG_COMMON_STAT
|
||||
|
||||
struct crypto_ahash {
|
||||
bool using_shash; /* Underlying algorithm is shash, not ahash */
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
* @init.
|
||||
*
|
||||
* @reqsize: Context size for (de)compression requests
|
||||
* @stat: Statistics for compress algorithm
|
||||
* @base: Common crypto API algorithm data structure
|
||||
* @calg: Cmonn algorithm data structure shared with scomp
|
||||
*/
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <linux/cryptouser.h>
|
||||
#include <net/netlink.h>
|
||||
|
||||
struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs);
|
||||
#else
|
||||
static inline int crypto_reportstat(struct sk_buff *in_skb,
|
||||
struct nlmsghdr *in_nlh,
|
||||
struct nlattr **attrs)
|
||||
{
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
#endif
|
||||
@@ -33,7 +33,8 @@
|
||||
#define ECC_CURVE_NIST_P192_DIGITS 3
|
||||
#define ECC_CURVE_NIST_P256_DIGITS 4
|
||||
#define ECC_CURVE_NIST_P384_DIGITS 6
|
||||
#define ECC_MAX_DIGITS (512 / 64) /* due to ecrdsa */
|
||||
#define ECC_CURVE_NIST_P521_DIGITS 9
|
||||
#define ECC_MAX_DIGITS DIV_ROUND_UP(521, 64) /* NIST P521 */
|
||||
|
||||
#define ECC_DIGITS_TO_BYTES_SHIFT 3
|
||||
|
||||
@@ -56,6 +57,27 @@ static inline void ecc_swap_digits(const void *in, u64 *out, unsigned int ndigit
|
||||
out[i] = get_unaligned_be64(&src[ndigits - 1 - i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* ecc_digits_from_bytes() - Create ndigits-sized digits array from byte array
|
||||
* @in: Input byte array
|
||||
* @nbytes Size of input byte array
|
||||
* @out Output digits array
|
||||
* @ndigits: Number of digits to create from byte array
|
||||
*/
|
||||
static inline void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
|
||||
u64 *out, unsigned int ndigits)
|
||||
{
|
||||
unsigned int o = nbytes & 7;
|
||||
__be64 msd = 0;
|
||||
|
||||
if (o) {
|
||||
memcpy((u8 *)&msd + sizeof(msd) - o, in, o);
|
||||
out[--ndigits] = be64_to_cpu(msd);
|
||||
in += o;
|
||||
}
|
||||
ecc_swap_digits(in, out, ndigits);
|
||||
}
|
||||
|
||||
/**
|
||||
* ecc_is_key_valid() - Validate a given ECDH private key
|
||||
*
|
||||
@@ -81,7 +103,8 @@ int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
|
||||
* Returns 0 if the private key was generated successfully, a negative value
|
||||
* if an error occurred.
|
||||
*/
|
||||
int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits, u64 *privkey);
|
||||
int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits,
|
||||
u64 *private_key);
|
||||
|
||||
/**
|
||||
* ecc_make_pub_key() - Compute an ECC public key
|
||||
|
||||
@@ -27,7 +27,6 @@ struct crypto_scomp {
|
||||
* @free_ctx: Function frees context allocated with alloc_ctx
|
||||
* @compress: Function performs a compress operation
|
||||
* @decompress: Function performs a de-compress operation
|
||||
* @stat: Statistics for compress algorithm
|
||||
* @base: Common crypto API algorithm data structure
|
||||
* @calg: Cmonn algorithm data structure shared with acomp
|
||||
*/
|
||||
|
||||
+3
-55
@@ -51,20 +51,6 @@ struct crypto_kpp {
|
||||
struct crypto_tfm base;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct crypto_istat_kpp - statistics for KPP algorithm
|
||||
* @setsecret_cnt: number of setsecrey operation
|
||||
* @generate_public_key_cnt: number of generate_public_key operation
|
||||
* @compute_shared_secret_cnt: number of compute_shared_secret operation
|
||||
* @err_cnt: number of error for KPP requests
|
||||
*/
|
||||
struct crypto_istat_kpp {
|
||||
atomic64_t setsecret_cnt;
|
||||
atomic64_t generate_public_key_cnt;
|
||||
atomic64_t compute_shared_secret_cnt;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct kpp_alg - generic key-agreement protocol primitives
|
||||
*
|
||||
@@ -87,7 +73,6 @@ struct crypto_istat_kpp {
|
||||
* @exit: Undo everything @init did.
|
||||
*
|
||||
* @base: Common crypto API algorithm data structure
|
||||
* @stat: Statistics for KPP algorithm
|
||||
*/
|
||||
struct kpp_alg {
|
||||
int (*set_secret)(struct crypto_kpp *tfm, const void *buffer,
|
||||
@@ -100,10 +85,6 @@ struct kpp_alg {
|
||||
int (*init)(struct crypto_kpp *tfm);
|
||||
void (*exit)(struct crypto_kpp *tfm);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
struct crypto_istat_kpp stat;
|
||||
#endif
|
||||
|
||||
struct crypto_alg base;
|
||||
};
|
||||
|
||||
@@ -291,26 +272,6 @@ struct kpp_secret {
|
||||
unsigned short len;
|
||||
};
|
||||
|
||||
static inline struct crypto_istat_kpp *kpp_get_stat(struct kpp_alg *alg)
|
||||
{
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
return &alg->stat;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int crypto_kpp_errstat(struct kpp_alg *alg, int err)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
return err;
|
||||
|
||||
if (err && err != -EINPROGRESS && err != -EBUSY)
|
||||
atomic64_inc(&kpp_get_stat(alg)->err_cnt);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_kpp_set_secret() - Invoke kpp operation
|
||||
*
|
||||
@@ -329,12 +290,7 @@ static inline int crypto_kpp_errstat(struct kpp_alg *alg, int err)
|
||||
static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm,
|
||||
const void *buffer, unsigned int len)
|
||||
{
|
||||
struct kpp_alg *alg = crypto_kpp_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
atomic64_inc(&kpp_get_stat(alg)->setsecret_cnt);
|
||||
|
||||
return crypto_kpp_errstat(alg, alg->set_secret(tfm, buffer, len));
|
||||
return crypto_kpp_alg(tfm)->set_secret(tfm, buffer, len);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,12 +309,8 @@ static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm,
|
||||
static inline int crypto_kpp_generate_public_key(struct kpp_request *req)
|
||||
{
|
||||
struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
|
||||
struct kpp_alg *alg = crypto_kpp_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
atomic64_inc(&kpp_get_stat(alg)->generate_public_key_cnt);
|
||||
|
||||
return crypto_kpp_errstat(alg, alg->generate_public_key(req));
|
||||
return crypto_kpp_alg(tfm)->generate_public_key(req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,12 +326,8 @@ static inline int crypto_kpp_generate_public_key(struct kpp_request *req)
|
||||
static inline int crypto_kpp_compute_shared_secret(struct kpp_request *req)
|
||||
{
|
||||
struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
|
||||
struct kpp_alg *alg = crypto_kpp_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
atomic64_inc(&kpp_get_stat(alg)->compute_shared_secret_cnt);
|
||||
|
||||
return crypto_kpp_errstat(alg, alg->compute_shared_secret(req));
|
||||
return crypto_kpp_alg(tfm)->compute_shared_secret(req);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-50
@@ -15,20 +15,6 @@
|
||||
|
||||
struct crypto_rng;
|
||||
|
||||
/*
|
||||
* struct crypto_istat_rng: statistics for RNG algorithm
|
||||
* @generate_cnt: number of RNG generate requests
|
||||
* @generate_tlen: total data size of generated data by the RNG
|
||||
* @seed_cnt: number of times the RNG was seeded
|
||||
* @err_cnt: number of error for RNG requests
|
||||
*/
|
||||
struct crypto_istat_rng {
|
||||
atomic64_t generate_cnt;
|
||||
atomic64_t generate_tlen;
|
||||
atomic64_t seed_cnt;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct rng_alg - random number generator definition
|
||||
*
|
||||
@@ -46,7 +32,6 @@ struct crypto_istat_rng {
|
||||
* size of the seed is defined with @seedsize .
|
||||
* @set_ent: Set entropy that would otherwise be obtained from
|
||||
* entropy source. Internal use only.
|
||||
* @stat: Statistics for rng algorithm
|
||||
* @seedsize: The seed size required for a random number generator
|
||||
* initialization defined with this variable. Some
|
||||
* random number generators does not require a seed
|
||||
@@ -63,10 +48,6 @@ struct rng_alg {
|
||||
void (*set_ent)(struct crypto_rng *tfm, const u8 *data,
|
||||
unsigned int len);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
struct crypto_istat_rng stat;
|
||||
#endif
|
||||
|
||||
unsigned int seedsize;
|
||||
|
||||
struct crypto_alg base;
|
||||
@@ -144,26 +125,6 @@ static inline void crypto_free_rng(struct crypto_rng *tfm)
|
||||
crypto_destroy_tfm(tfm, crypto_rng_tfm(tfm));
|
||||
}
|
||||
|
||||
static inline struct crypto_istat_rng *rng_get_stat(struct rng_alg *alg)
|
||||
{
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
return &alg->stat;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int crypto_rng_errstat(struct rng_alg *alg, int err)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
|
||||
return err;
|
||||
|
||||
if (err && err != -EINPROGRESS && err != -EBUSY)
|
||||
atomic64_inc(&rng_get_stat(alg)->err_cnt);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_rng_generate() - get random number
|
||||
* @tfm: cipher handle
|
||||
@@ -182,17 +143,7 @@ static inline int crypto_rng_generate(struct crypto_rng *tfm,
|
||||
const u8 *src, unsigned int slen,
|
||||
u8 *dst, unsigned int dlen)
|
||||
{
|
||||
struct rng_alg *alg = crypto_rng_alg(tfm);
|
||||
|
||||
if (IS_ENABLED(CONFIG_CRYPTO_STATS)) {
|
||||
struct crypto_istat_rng *istat = rng_get_stat(alg);
|
||||
|
||||
atomic64_inc(&istat->generate_cnt);
|
||||
atomic64_add(dlen, &istat->generate_tlen);
|
||||
}
|
||||
|
||||
return crypto_rng_errstat(alg,
|
||||
alg->generate(tfm, src, slen, dst, dlen));
|
||||
return crypto_rng_alg(tfm)->generate(tfm, src, slen, dst, dlen);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,28 +64,6 @@ struct crypto_lskcipher {
|
||||
struct crypto_tfm base;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct crypto_istat_cipher - statistics for cipher algorithm
|
||||
* @encrypt_cnt: number of encrypt requests
|
||||
* @encrypt_tlen: total data size handled by encrypt requests
|
||||
* @decrypt_cnt: number of decrypt requests
|
||||
* @decrypt_tlen: total data size handled by decrypt requests
|
||||
* @err_cnt: number of error for cipher requests
|
||||
*/
|
||||
struct crypto_istat_cipher {
|
||||
atomic64_t encrypt_cnt;
|
||||
atomic64_t encrypt_tlen;
|
||||
atomic64_t decrypt_cnt;
|
||||
atomic64_t decrypt_tlen;
|
||||
atomic64_t err_cnt;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
#define SKCIPHER_ALG_COMMON_STAT struct crypto_istat_cipher stat;
|
||||
#else
|
||||
#define SKCIPHER_ALG_COMMON_STAT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* struct skcipher_alg_common - common properties of skcipher_alg
|
||||
* @min_keysize: Minimum key size supported by the transformation. This is the
|
||||
@@ -103,7 +81,6 @@ struct crypto_istat_cipher {
|
||||
* @chunksize: Equal to the block size except for stream ciphers such as
|
||||
* CTR where it is set to the underlying block size.
|
||||
* @statesize: Size of the internal state for the algorithm.
|
||||
* @stat: Statistics for cipher algorithm
|
||||
* @base: Definition of a generic crypto algorithm.
|
||||
*/
|
||||
#define SKCIPHER_ALG_COMMON { \
|
||||
@@ -113,8 +90,6 @@ struct crypto_istat_cipher {
|
||||
unsigned int chunksize; \
|
||||
unsigned int statesize; \
|
||||
\
|
||||
SKCIPHER_ALG_COMMON_STAT \
|
||||
\
|
||||
struct crypto_alg base; \
|
||||
}
|
||||
struct skcipher_alg_common SKCIPHER_ALG_COMMON;
|
||||
|
||||
Reference in New Issue
Block a user