]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: hash - Add crypto_has_ahash helper
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 23 Jan 2016 05:52:40 +0000 (13:52 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Jan 2016 14:42:13 +0000 (22:42 +0800)
This patch adds the helper crypto_has_ahash which should replace
crypto_has_hash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ahash.c
include/crypto/hash.h

index d19b52324cf520ee777743ee895efb2f537f5e62..8b08a59221a62977630ff970b3dac7203908429b 100644 (file)
@@ -542,6 +542,12 @@ struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, u32 type,
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_ahash);
 
+int crypto_has_ahash(const char *alg_name, u32 type, u32 mask)
+{
+       return crypto_type_has_alg(alg_name, &crypto_ahash_type, type, mask);
+}
+EXPORT_SYMBOL_GPL(crypto_has_ahash);
+
 static int ahash_prepare_alg(struct ahash_alg *alg)
 {
        struct crypto_alg *base = &alg->halg.base;
index aef819247fe83521c0bb4688061dc827d16d729d..f855efaa2f8cf50a45c3fc6c630b9626688d1304 100644 (file)
@@ -260,6 +260,18 @@ static inline void crypto_free_ahash(struct crypto_ahash *tfm)
        crypto_destroy_tfm(tfm, crypto_ahash_tfm(tfm));
 }
 
+/**
+ * crypto_has_ahash() - Search for the availability of an ahash.
+ * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
+ *           ahash
+ * @type: specifies the type of the ahash
+ * @mask: specifies the mask for the ahash
+ *
+ * Return: true when the ahash is known to the kernel crypto API; false
+ *        otherwise
+ */
+int crypto_has_ahash(const char *alg_name, u32 type, u32 mask);
+
 static inline unsigned int crypto_ahash_alignmask(
        struct crypto_ahash *tfm)
 {