Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: scatterwalk - Add scatterwalk_crypto_chain helper

A lot of crypto algorithms implement their own chaining function.
So add a generic one that can be used from all the algorithms that
need scatterlist chaining.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Steffen Klassert and committed by
Herbert Xu
079f2f74 bc97e57e

+15
+15
include/crypto/scatterwalk.h
··· 68 68 return (++sg)->length ? sg : (void *)sg_page(sg); 69 69 } 70 70 71 + static inline void scatterwalk_crypto_chain(struct scatterlist *head, 72 + struct scatterlist *sg, 73 + int chain, int num) 74 + { 75 + if (chain) { 76 + head->length += sg->length; 77 + sg = scatterwalk_sg_next(sg); 78 + } 79 + 80 + if (sg) 81 + scatterwalk_sg_chain(head, num, sg); 82 + else 83 + sg_mark_end(head); 84 + } 85 + 71 86 static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, 72 87 struct scatter_walk *walk_out) 73 88 {