On Mon, Jun 27, 2016 at 8:41 PM, Herbert Xu <herb...@gondor.apana.org.au> wrote: > On Mon, Jun 27, 2016 at 10:58:42AM -0700, Andy Lutomirski wrote: >> >> I wonder if it's worth switching from ahash to shash, though. It >> would probably be simpler and faster. > > No shash is not appropriate here because it needs to hash skb > frags which are SG lists. >
Do you mean this code: for (i = 0; i < shi->nr_frags; ++i) { const struct skb_frag_struct *f = &shi->frags[i]; unsigned int offset = f->page_offset; struct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT); sg_set_page(&sg, page, skb_frag_size(f), offset_in_page(offset)); ahash_request_set_crypt(req, &sg, NULL, skb_frag_size(f)); if (crypto_ahash_update(req)) return 1; } I'm wondering why support for scatterlists is all-or-nothing. Why can't we initialize a hash object and then alternate between passing it scatterlists and pointers? I'm guessing that ahash enables async operation and shash is synchronous only. If I'm right, I understand why ahash requires a scatterlist. What I don't understand is why shash can't also accept a scatterlist. It appears that most of the ahash users in the tree actually want synchronous crypto and are presumably using ahash for some other reason such as ahash's ability to hash via scatterlist (in this case, struct page *). --Andy