summaryrefslogtreecommitdiff
path: root/include/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-04-20 13:39:03 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2015-04-21 10:19:57 +0800
commitd0e83059a6c9b04f00264a74b8f6439948de4613 (patch)
tree18cce1bc75fad593b10995e50197f41d2a9ca267 /include/crypto
parentf7c9bebe8bc79ddb8a50db441a53b59b61ae3ba8 (diff)
crypto: rng - Convert crypto_rng to new style crypto_type
This patch converts the top-level crypto_rng to the "new" style. It was the last algorithm type added before we switched over to the new way of doing things exemplified by shash. All users will automatically switch over to the new interface. Note that this patch does not touch the low-level interface to rng implementations. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/rng.h32
1 files changed, 10 insertions, 22 deletions
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index 6e28ea5be9f1..f13f3faca4d7 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -15,6 +15,12 @@
#include <linux/crypto.h>
+struct crypto_rng {
+ int (*generate)(struct crypto_rng *tfm, u8 *rdata, unsigned int dlen);
+ int (*seed)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
+ struct crypto_tfm base;
+};
+
extern struct crypto_rng *crypto_default_rng;
int crypto_get_default_rng(void);
@@ -27,11 +33,6 @@ void crypto_put_default_rng(void);
* CRYPTO_ALG_TYPE_RNG (listed as type "rng" in /proc/crypto)
*/
-static inline struct crypto_rng *__crypto_rng_cast(struct crypto_tfm *tfm)
-{
- return (struct crypto_rng *)tfm;
-}
-
/**
* crypto_alloc_rng() -- allocate RNG handle
* @alg_name: is the cra_name / name or cra_driver_name / driver name of the
@@ -52,15 +53,7 @@ static inline struct crypto_rng *__crypto_rng_cast(struct crypto_tfm *tfm)
* Return: allocated cipher handle in case of success; IS_ERR() is true in case
* of an error, PTR_ERR() returns the error code.
*/
-static inline struct crypto_rng *crypto_alloc_rng(const char *alg_name,
- u32 type, u32 mask)
-{
- type &= ~CRYPTO_ALG_TYPE_MASK;
- type |= CRYPTO_ALG_TYPE_RNG;
- mask |= CRYPTO_ALG_TYPE_MASK;
-
- return __crypto_rng_cast(crypto_alloc_base(alg_name, type, mask));
-}
+struct crypto_rng *crypto_alloc_rng(const char *alg_name, u32 type, u32 mask);
static inline struct crypto_tfm *crypto_rng_tfm(struct crypto_rng *tfm)
{
@@ -80,18 +73,13 @@ static inline struct rng_alg *crypto_rng_alg(struct crypto_rng *tfm)
return &crypto_rng_tfm(tfm)->__crt_alg->cra_rng;
}
-static inline struct rng_tfm *crypto_rng_crt(struct crypto_rng *tfm)
-{
- return &crypto_rng_tfm(tfm)->crt_rng;
-}
-
/**
* crypto_free_rng() - zeroize and free RNG handle
* @tfm: cipher handle to be freed
*/
static inline void crypto_free_rng(struct crypto_rng *tfm)
{
- crypto_free_tfm(crypto_rng_tfm(tfm));
+ crypto_destroy_tfm(tfm, crypto_rng_tfm(tfm));
}
/**
@@ -108,7 +96,7 @@ static inline void crypto_free_rng(struct crypto_rng *tfm)
static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
u8 *rdata, unsigned int dlen)
{
- return crypto_rng_crt(tfm)->rng_gen_random(tfm, rdata, dlen);
+ return tfm->generate(tfm, rdata, dlen);
}
/**
@@ -131,7 +119,7 @@ static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
static inline int crypto_rng_reset(struct crypto_rng *tfm,
u8 *seed, unsigned int slen)
{
- return crypto_rng_crt(tfm)->rng_reset(tfm, seed, slen);
+ return tfm->seed(tfm, seed, slen);
}
/**