crypto: aead - Add crypto_has_aead
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 14 Sep 2023 08:28:21 +0000 (16:28 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 20 Sep 2023 05:15:29 +0000 (13:15 +0800)
Add the helper crypto_has_aead.  This is meant to replace the
existing use of crypto_has_alg to locate AEAD algorithms.

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

index d5ba204ebdbfa6c5bf90ff87d9f3d55e637c741d..54906633566a2357789d619916ec3a099c935064 100644 (file)
@@ -269,6 +269,12 @@ struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask)
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_aead);
 
+int crypto_has_aead(const char *alg_name, u32 type, u32 mask)
+{
+       return crypto_type_has_alg(alg_name, &crypto_aead_type, type, mask);
+}
+EXPORT_SYMBOL_GPL(crypto_has_aead);
+
 static int aead_prepare_alg(struct aead_alg *alg)
 {
        struct crypto_istat_aead *istat = aead_get_stat(alg);
index 35e45b854a6fa4940f099eadde9228c1b3a1105d..51382befbe37abcd73cbce1d5f6d0ca53b7af841 100644 (file)
@@ -217,6 +217,18 @@ static inline void crypto_free_aead(struct crypto_aead *tfm)
        crypto_destroy_tfm(tfm, crypto_aead_tfm(tfm));
 }
 
+/**
+ * crypto_has_aead() - Search for the availability of an aead.
+ * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
+ *           aead
+ * @type: specifies the type of the aead
+ * @mask: specifies the mask for the aead
+ *
+ * Return: true when the aead is known to the kernel crypto API; false
+ *        otherwise
+ */
+int crypto_has_aead(const char *alg_name, u32 type, u32 mask);
+
 static inline const char *crypto_aead_driver_name(struct crypto_aead *tfm)
 {
        return crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));