]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[CRYPTO] users: Use crypto_comp and crypto_has_*
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 26 Aug 2006 08:12:40 +0000 (18:12 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 21 Sep 2006 01:46:22 +0000 (11:46 +1000)
This patch converts all users to use the new crypto_comp type and the
crypto_has_* functions.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/tcrypt.c
drivers/crypto/padlock.c
drivers/net/ppp_mppe.c
include/linux/crypto.h
include/net/ipcomp.h
net/ipv4/ipcomp.c
net/ipv6/ipcomp6.c
net/xfrm/xfrm_algo.c

index 840ab8be0b96788bf8deafcae38054f64d82e7fb..83307420d31c873398006cbd85286ebcf50e2965 100644 (file)
@@ -749,7 +749,7 @@ static void test_deflate(void)
 {
        unsigned int i;
        char result[COMP_BUF_SIZE];
-       struct crypto_tfm *tfm;
+       struct crypto_comp *tfm;
        struct comp_testvec *tv;
        unsigned int tsize;
 
@@ -821,7 +821,7 @@ static void test_deflate(void)
                       ilen, dlen);
        }
 out:
-       crypto_free_tfm(tfm);
+       crypto_free_comp(tfm);
 }
 
 static void test_available(void)
@@ -830,8 +830,8 @@ static void test_available(void)
 
        while (*name) {
                printk("alg %s ", *name);
-               printk((crypto_alg_available(*name, 0)) ?
-                       "found\n" : "not found\n");
+               printk(crypto_has_alg(*name, 0, CRYPTO_ALG_ASYNC) ?
+                      "found\n" : "not found\n");
                name++;
        }
 }
index ce581684f4b4aa2a469b4c4bce63e5b771056ea6..d6d7dd5bb98c1abfa12dcff5c3f80e3a4a206903 100644 (file)
@@ -26,13 +26,13 @@ static int __init padlock_init(void)
 {
        int success = 0;
 
-       if (crypto_alg_available("aes-padlock", 0))
+       if (crypto_has_cipher("aes-padlock", 0, 0))
                success++;
 
-       if (crypto_alg_available("sha1-padlock", 0))
+       if (crypto_has_hash("sha1-padlock", 0, 0))
                success++;
 
-       if (crypto_alg_available("sha256-padlock", 0))
+       if (crypto_has_hash("sha256-padlock", 0, 0))
                success++;
 
        if (!success) {
index e7a0eb4fca6031bdffd8e279935cadee395f9183..f3655fd772f5b765c7f0e33fb693480a255135ae 100644 (file)
@@ -710,8 +710,8 @@ static struct compressor ppp_mppe = {
 static int __init ppp_mppe_init(void)
 {
        int answer;
-       if (!(crypto_alg_available("ecb(arc4)", 0) &&
-             crypto_alg_available("sha1", 0)))
+       if (!(crypto_has_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC) &&
+             crypto_has_hash("sha1", 0, CRYPTO_ALG_ASYNC)))
                return -ENODEV;
 
        sha_pad = kmalloc(sizeof(struct sha_pad), GFP_KERNEL);
index cf91c4c0638bb757c190bd3b72ddcc2da2dff1ca..d4f9948b64b1161620b2d65e97fa1f18a78b2761 100644 (file)
@@ -928,6 +928,11 @@ static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
        return crypto_has_alg(alg_name, type, mask);
 }
 
+static inline const char *crypto_comp_name(struct crypto_comp *tfm)
+{
+       return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
+}
+
 static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm)
 {
        return &crypto_comp_tfm(tfm)->crt_compress;
index b94e3047b4d9b39f2ba5782675a2037815545883..87c1af3e5e8243be480e0cec57860242c722a914 100644 (file)
@@ -1,15 +1,14 @@
 #ifndef _NET_IPCOMP_H
 #define _NET_IPCOMP_H
 
+#include <linux/crypto.h>
 #include <linux/types.h>
 
 #define IPCOMP_SCRATCH_SIZE     65400
 
-struct crypto_tfm;
-
 struct ipcomp_data {
        u16 threshold;
-       struct crypto_tfm **tfms;
+       struct crypto_comp **tfms;
 };
 
 #endif
index a0c28b2b756e0c1e8dab144eba3440f3c67d60fe..5bb9c9f03fb6dbf23c7831129e86016255f12830 100644 (file)
@@ -32,7 +32,7 @@
 
 struct ipcomp_tfms {
        struct list_head list;
-       struct crypto_tfm **tfms;
+       struct crypto_comp **tfms;
        int users;
 };
 
@@ -46,7 +46,7 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
        int err, plen, dlen;
        struct ipcomp_data *ipcd = x->data;
        u8 *start, *scratch;
-       struct crypto_tfm *tfm;
+       struct crypto_comp *tfm;
        int cpu;
        
        plen = skb->len;
@@ -107,7 +107,7 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
        struct iphdr *iph = skb->nh.iph;
        struct ipcomp_data *ipcd = x->data;
        u8 *start, *scratch;
-       struct crypto_tfm *tfm;
+       struct crypto_comp *tfm;
        int cpu;
        
        ihlen = iph->ihl * 4;
@@ -302,7 +302,7 @@ static void **ipcomp_alloc_scratches(void)
        return scratches;
 }
 
-static void ipcomp_free_tfms(struct crypto_tfm **tfms)
+static void ipcomp_free_tfms(struct crypto_comp **tfms)
 {
        struct ipcomp_tfms *pos;
        int cpu;
@@ -324,28 +324,28 @@ static void ipcomp_free_tfms(struct crypto_tfm **tfms)
                return;
 
        for_each_possible_cpu(cpu) {
-               struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
-               crypto_free_tfm(tfm);
+               struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu);
+               crypto_free_comp(tfm);
        }
        free_percpu(tfms);
 }
 
-static struct crypto_tfm **ipcomp_alloc_tfms(const char *alg_name)
+static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
 {
        struct ipcomp_tfms *pos;
-       struct crypto_tfm **tfms;
+       struct crypto_comp **tfms;
        int cpu;
 
        /* This can be any valid CPU ID so we don't need locking. */
        cpu = raw_smp_processor_id();
 
        list_for_each_entry(pos, &ipcomp_tfms_list, list) {
-               struct crypto_tfm *tfm;
+               struct crypto_comp *tfm;
 
                tfms = pos->tfms;
                tfm = *per_cpu_ptr(tfms, cpu);
 
-               if (!strcmp(crypto_tfm_alg_name(tfm), alg_name)) {
+               if (!strcmp(crypto_comp_name(tfm), alg_name)) {
                        pos->users++;
                        return tfms;
                }
@@ -359,12 +359,13 @@ static struct crypto_tfm **ipcomp_alloc_tfms(const char *alg_name)
        INIT_LIST_HEAD(&pos->list);
        list_add(&pos->list, &ipcomp_tfms_list);
 
-       pos->tfms = tfms = alloc_percpu(struct crypto_tfm *);
+       pos->tfms = tfms = alloc_percpu(struct crypto_comp *);
        if (!tfms)
                goto error;
 
        for_each_possible_cpu(cpu) {
-               struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0);
+               struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
+                                                           CRYPTO_ALG_ASYNC);
                if (!tfm)
                        goto error;
                *per_cpu_ptr(tfms, cpu) = tfm;
index 7e4d1c17bfbc1295e00805b0808c6ec770bf4f8c..a81e9e9d93bd25f85d6f7b45e7f001ae7e1a31c8 100644 (file)
@@ -53,7 +53,7 @@
 
 struct ipcomp6_tfms {
        struct list_head list;
-       struct crypto_tfm **tfms;
+       struct crypto_comp **tfms;
        int users;
 };
 
@@ -70,7 +70,7 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
        int plen, dlen;
        struct ipcomp_data *ipcd = x->data;
        u8 *start, *scratch;
-       struct crypto_tfm *tfm;
+       struct crypto_comp *tfm;
        int cpu;
 
        if (skb_linearize_cow(skb))
@@ -129,7 +129,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
        struct ipcomp_data *ipcd = x->data;
        int plen, dlen;
        u8 *start, *scratch;
-       struct crypto_tfm *tfm;
+       struct crypto_comp *tfm;
        int cpu;
 
        hdr_len = skb->h.raw - skb->data;
@@ -301,7 +301,7 @@ static void **ipcomp6_alloc_scratches(void)
        return scratches;
 }
 
-static void ipcomp6_free_tfms(struct crypto_tfm **tfms)
+static void ipcomp6_free_tfms(struct crypto_comp **tfms)
 {
        struct ipcomp6_tfms *pos;
        int cpu;
@@ -323,28 +323,28 @@ static void ipcomp6_free_tfms(struct crypto_tfm **tfms)
                return;
 
        for_each_possible_cpu(cpu) {
-               struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
-               crypto_free_tfm(tfm);
+               struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu);
+               crypto_free_comp(tfm);
        }
        free_percpu(tfms);
 }
 
-static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name)
+static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name)
 {
        struct ipcomp6_tfms *pos;
-       struct crypto_tfm **tfms;
+       struct crypto_comp **tfms;
        int cpu;
 
        /* This can be any valid CPU ID so we don't need locking. */
        cpu = raw_smp_processor_id();
 
        list_for_each_entry(pos, &ipcomp6_tfms_list, list) {
-               struct crypto_tfm *tfm;
+               struct crypto_comp *tfm;
 
                tfms = pos->tfms;
                tfm = *per_cpu_ptr(tfms, cpu);
 
-               if (!strcmp(crypto_tfm_alg_name(tfm), alg_name)) {
+               if (!strcmp(crypto_comp_name(tfm), alg_name)) {
                        pos->users++;
                        return tfms;
                }
@@ -358,12 +358,13 @@ static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name)
        INIT_LIST_HEAD(&pos->list);
        list_add(&pos->list, &ipcomp6_tfms_list);
 
-       pos->tfms = tfms = alloc_percpu(struct crypto_tfm *);
+       pos->tfms = tfms = alloc_percpu(struct crypto_comp *);
        if (!tfms)
                goto error;
 
        for_each_possible_cpu(cpu) {
-               struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0);
+               struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
+                                                           CRYPTO_ALG_ASYNC);
                if (!tfm)
                        goto error;
                *per_cpu_ptr(tfms, cpu) = tfm;
index 87918f281bb436b1dcab4aa4a0a6f98b87a9958f..5a0dbeb6bbe817f02c7750ea75e5f3e6713680cf 100644 (file)
@@ -363,8 +363,8 @@ struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
 EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
 
 static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list,
-                                             int entries, char *name,
-                                             int probe)
+                                             int entries, u32 type, u32 mask,
+                                             char *name, int probe)
 {
        int i, status;
 
@@ -382,7 +382,7 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list,
                if (!probe)
                        break;
 
-               status = crypto_alg_available(name, 0);
+               status = crypto_has_alg(name, type, mask | CRYPTO_ALG_ASYNC);
                if (!status)
                        break;
 
@@ -394,19 +394,25 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list,
 
 struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe)
 {
-       return xfrm_get_byname(aalg_list, aalg_entries(), name, probe);
+       return xfrm_get_byname(aalg_list, aalg_entries(),
+                              CRYPTO_ALG_TYPE_HASH, CRYPTO_ALG_TYPE_HASH_MASK,
+                              name, probe);
 }
 EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname);
 
 struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe)
 {
-       return xfrm_get_byname(ealg_list, ealg_entries(), name, probe);
+       return xfrm_get_byname(ealg_list, ealg_entries(),
+                              CRYPTO_ALG_TYPE_BLKCIPHER, CRYPTO_ALG_TYPE_MASK,
+                              name, probe);
 }
 EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname);
 
 struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe)
 {
-       return xfrm_get_byname(calg_list, calg_entries(), name, probe);
+       return xfrm_get_byname(calg_list, calg_entries(),
+                              CRYPTO_ALG_TYPE_COMPRESS, CRYPTO_ALG_TYPE_MASK,
+                              name, probe);
 }
 EXPORT_SYMBOL_GPL(xfrm_calg_get_byname);
 
@@ -441,19 +447,22 @@ void xfrm_probe_algs(void)
        BUG_ON(in_softirq());
 
        for (i = 0; i < aalg_entries(); i++) {
-               status = crypto_alg_available(aalg_list[i].name, 0);
+               status = crypto_has_hash(aalg_list[i].name, 0,
+                                        CRYPTO_ALG_ASYNC);
                if (aalg_list[i].available != status)
                        aalg_list[i].available = status;
        }
        
        for (i = 0; i < ealg_entries(); i++) {
-               status = crypto_alg_available(ealg_list[i].name, 0);
+               status = crypto_has_blkcipher(ealg_list[i].name, 0,
+                                             CRYPTO_ALG_ASYNC);
                if (ealg_list[i].available != status)
                        ealg_list[i].available = status;
        }
        
        for (i = 0; i < calg_entries(); i++) {
-               status = crypto_alg_available(calg_list[i].name, 0);
+               status = crypto_has_comp(calg_list[i].name, 0,
+                                        CRYPTO_ALG_ASYNC);
                if (calg_list[i].available != status)
                        calg_list[i].available = status;
        }