Skip to content

Commit

Permalink
[CRYPTO] scatterwalk: Restore custom sg chaining for now
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
herbertx committed Jan 10, 2008
1 parent 42c271c commit b2ab4a5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crypto/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int update2(struct hash_desc *desc,

if (!nbytes)
break;
sg = sg_next(sg);
sg = scatterwalk_sg_next(sg);
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion crypto/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void crypto_gcm_ghash_update_sg(struct crypto_gcm_ghash_ctx *ctx,
n = scatterwalk_clamp(&walk, len);

if (!n) {
scatterwalk_start(&walk, sg_next(walk.sg));
scatterwalk_start(&walk, scatterwalk_sg_next(walk.sg));
n = scatterwalk_clamp(&walk, len);
}

Expand Down
3 changes: 2 additions & 1 deletion crypto/hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include <crypto/algapi.h>
#include <crypto/scatterwalk.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -160,7 +161,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,

sg_init_table(sg1, 2);
sg_set_buf(sg1, ipad, bs);
sg_chain(sg1, 2, sg);
scatterwalk_sg_chain(sg1, 2, sg);

sg_init_table(sg2, 1);
sg_set_buf(sg2, opad, bs + ds);
Expand Down
4 changes: 2 additions & 2 deletions crypto/scatterwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
walk->offset += PAGE_SIZE - 1;
walk->offset &= PAGE_MASK;
if (walk->offset >= walk->sg->offset + walk->sg->length)
scatterwalk_start(walk, sg_next(walk->sg));
scatterwalk_start(walk, scatterwalk_sg_next(walk->sg));
}
}

Expand Down Expand Up @@ -112,7 +112,7 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
break;

offset += sg->length;
sg = sg_next(sg);
sg = scatterwalk_sg_next(sg);
}

scatterwalk_advance(&walk, start - offset);
Expand Down
11 changes: 11 additions & 0 deletions include/crypto/scatterwalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ static inline void crypto_yield(u32 flags)
cond_resched();
}

static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
struct scatterlist *sg2)
{
sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
}

static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
{
return (++sg)->length ? sg : (void *)sg_page(sg);
}

static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in,
struct scatter_walk *walk_out)
{
Expand Down

0 comments on commit b2ab4a5

Please sign in to comment.