- scatterwalk_map_and_copy(hash, dst, cryptlen,
+static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
+ unsigned int flags)
+{
+ struct crypto_aead *authenc = crypto_aead_reqtfm(req);
+ struct scatterlist *dst = req->dst;
+ struct scatterlist cipher[2];
+ struct page *dstp;
+ unsigned int ivsize = crypto_aead_ivsize(authenc);
+ unsigned int cryptlen;
+ u8 *vdst;
+ u8 *hash;
+
+ dstp = sg_page(dst);
+ vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset;
+
+ sg_init_table(cipher, 2);
+ sg_set_buf(cipher, iv, ivsize);
+ authenc_chain(cipher, dst, vdst == iv + ivsize);
+
+ cryptlen = req->cryptlen + ivsize;
+ hash = crypto_authenc_hash(req, flags, cipher, cryptlen);
+ if (IS_ERR(hash))
+ return PTR_ERR(hash);
+
+ scatterwalk_map_and_copy(hash, cipher, cryptlen,