crypto: shash - Add shash_attr_alg2 helper
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 8 Jul 2009 09:56:28 +0000 (17:56 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 8 Jul 2009 10:58:30 +0000 (18:58 +0800)
This patch adds the helper shash_attr_alg2 which locates a shash
algorithm based on the information in the given attribute.

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

index 97f6c8ba103abd73362c8ab5871a0782acdf508d..21bcff6be5b0155ea3d6371d50e82c4b75c77111 100644 (file)
@@ -518,5 +518,15 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
 }
 EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
 
+struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
+{
+       struct crypto_alg *alg;
+
+       alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask);
+       return IS_ERR(alg) ? ERR_CAST(alg) :
+              container_of(alg, struct shash_alg, base);
+}
+EXPORT_SYMBOL_GPL(shash_attr_alg);
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Synchronous cryptographic hash type");
index 6cc824b79331f8e4dc36a33d3d4cb6533f775fee..e2ab35a74c62aac4233dd185a5dfb5d4dce81fae 100644 (file)
@@ -60,6 +60,8 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
                            struct shash_alg *alg,
                            struct crypto_instance *inst);
 
+struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
+
 static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
 {
        return crypto_tfm_ctx(&tfm->base);