aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-05 04:59:25 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:33 -0500
commitb2ab4a57b018aafbba35bff088218f5cc3d2142e (patch)
treea46c5bd42927c24c69f0786be2651ff3fba6c10e
parent42c271c6c538857cb13c5ead5184d264d745f675 (diff)
[CRYPTO] scatterwalk: Restore custom sg chaining for now
Unfortunately the generic chaining hasn't been ported to all architectures yet, and notably not s390. So this patch restores the chainging that we've been using previously which does work everywhere. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/digest.c2
-rw-r--r--crypto/gcm.c2
-rw-r--r--crypto/hmac.c3
-rw-r--r--crypto/scatterwalk.c4
-rw-r--r--include/crypto/scatterwalk.h11
5 files changed, 17 insertions, 5 deletions
diff --git a/crypto/digest.c b/crypto/digest.c
index 52845f53f8e1..6fd43bddd545 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -75,7 +75,7 @@ static int update2(struct hash_desc *desc,
75 75
76 if (!nbytes) 76 if (!nbytes)
77 break; 77 break;
78 sg = sg_next(sg); 78 sg = scatterwalk_sg_next(sg);
79 } 79 }
80 80
81 return 0; 81 return 0;
diff --git a/crypto/gcm.c b/crypto/gcm.c
index 27483f361e80..502da929a5fc 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -100,7 +100,7 @@ static void crypto_gcm_ghash_update_sg(struct crypto_gcm_ghash_ctx *ctx,
100 n = scatterwalk_clamp(&walk, len); 100 n = scatterwalk_clamp(&walk, len);
101 101
102 if (!n) { 102 if (!n) {
103 scatterwalk_start(&walk, sg_next(walk.sg)); 103 scatterwalk_start(&walk, scatterwalk_sg_next(walk.sg));
104 n = scatterwalk_clamp(&walk, len); 104 n = scatterwalk_clamp(&walk, len);
105 } 105 }
106 106
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 34c3706db85d..a1d016a50e7d 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <crypto/algapi.h> 19#include <crypto/algapi.h>
20#include <crypto/scatterwalk.h>
20#include <linux/err.h> 21#include <linux/err.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
@@ -160,7 +161,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,
160 161
161 sg_init_table(sg1, 2); 162 sg_init_table(sg1, 2);
162 sg_set_buf(sg1, ipad, bs); 163 sg_set_buf(sg1, ipad, bs);
163 sg_chain(sg1, 2, sg); 164 scatterwalk_sg_chain(sg1, 2, sg);
164 165
165 sg_init_table(sg2, 1); 166 sg_init_table(sg2, 1);
166 sg_set_buf(sg2, opad, bs + ds); 167 sg_set_buf(sg2, opad, bs + ds);
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
index 12d19019e178..297e19d13c4e 100644
--- a/crypto/scatterwalk.c
+++ b/crypto/scatterwalk.c
@@ -61,7 +61,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
61 walk->offset += PAGE_SIZE - 1; 61 walk->offset += PAGE_SIZE - 1;
62 walk->offset &= PAGE_MASK; 62 walk->offset &= PAGE_MASK;
63 if (walk->offset >= walk->sg->offset + walk->sg->length) 63 if (walk->offset >= walk->sg->offset + walk->sg->length)
64 scatterwalk_start(walk, sg_next(walk->sg)); 64 scatterwalk_start(walk, scatterwalk_sg_next(walk->sg));
65 } 65 }
66} 66}
67 67
@@ -112,7 +112,7 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
112 break; 112 break;
113 113
114 offset += sg->length; 114 offset += sg->length;
115 sg = sg_next(sg); 115 sg = scatterwalk_sg_next(sg);
116 } 116 }
117 117
118 scatterwalk_advance(&walk, start - offset); 118 scatterwalk_advance(&walk, start - offset);
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 07b6f17122d2..bd62431c33bd 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -52,6 +52,17 @@ static inline void crypto_yield(u32 flags)
52 cond_resched(); 52 cond_resched();
53} 53}
54 54
55static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
56 struct scatterlist *sg2)
57{
58 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
59}
60
61static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
62{
63 return (++sg)->length ? sg : (void *)sg_page(sg);
64}
65
55static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, 66static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in,
56 struct scatter_walk *walk_out) 67 struct scatter_walk *walk_out)
57{ 68{