On Mon, Jul 16, 2018 at 5:39 AM, Kees Cook <keescook@xxxxxxxxxxxx> wrote: > On Sun, Jul 15, 2018 at 5:01 PM, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote: >> On Sat, Jul 14, 2018 at 07:59:09PM -0700, Kees Cook wrote: >>> On Sat, Jul 14, 2018 at 7:44 PM, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote: >>> > On Fri, Jul 13, 2018 at 08:07:10PM -0700, Kees Cook wrote: >>> >> >>> >> On a plane today I started converting all these to shash. IIUC, it >>> >> just looks like this (apologies for whitespace damage): >>> > >>> > Yes if it doesn't actually make use of SGs then shash would be >>> > the way to go. However, for SG users ahash is the best interface. >>> >>> Nearly all of them artificially build an sg explicitly to use the >>> ahash interface. :P >>> >>> So, I'll take that as a "yes, do these conversions." :) Thanks! >> >> Yeah anything that's doing a single-element SG list should just >> be converted. > > There are a few that are multiple element SG list, but it's a locally > allocated array of SGs, and filled with data. All easily replaced with > just calls to ..._update() instead of sg helpers. For example > net/wireless/lib80211_crypt_tkip.c: > > - sg_init_table(sg, 2); > - sg_set_buf(&sg[0], hdr, 16); > - sg_set_buf(&sg[1], data, data_len); > ... > - ahash_request_set_tfm(req, tfm_michael); > - ahash_request_set_callback(req, 0, NULL, NULL); > - ahash_request_set_crypt(req, sg, mic, data_len + 16); > - err = crypto_ahash_digest(req); > - ahash_request_zero(req); > + err = crypto_shash_init(desc); > + if (err) > + goto out; > + err = crypto_shash_update(desc, hdr, 16); > + if (err) > + goto out; > + err = crypto_shash_update(desc, data, data_len); > + if (err) > + goto out; > + err = crypto_shash_final(desc, mic); > + > +out: > + shash_desc_zero(desc); > return err; There may be a little overhead in calling crypto_shash_update()/ crypto_shash_final() repeatedly compared to calling crypto_ahash_digest() once. It's probably no worse (or maybe better) in this case, since we call only three times and there is less indirection, but if there are any cases with a long sglist, it would be good to measure the performance difference. Arnd -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel