Lines Matching defs:req

107 static int sm4_ecb_do_crypt(struct skcipher_request *req, const u32 *rkey)
113 err = skcipher_walk_virt(&walk, req, false);
136 static int sm4_ecb_encrypt(struct skcipher_request *req)
138 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
141 return sm4_ecb_do_crypt(req, ctx->rkey_enc);
144 static int sm4_ecb_decrypt(struct skcipher_request *req)
146 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
149 return sm4_ecb_do_crypt(req, ctx->rkey_dec);
152 static int sm4_cbc_crypt(struct skcipher_request *req,
159 err = skcipher_walk_virt(&walk, req, false);
188 static int sm4_cbc_encrypt(struct skcipher_request *req)
190 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
193 return sm4_cbc_crypt(req, ctx, true);
196 static int sm4_cbc_decrypt(struct skcipher_request *req)
198 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
201 return sm4_cbc_crypt(req, ctx, false);
204 static int sm4_cbc_cts_crypt(struct skcipher_request *req, bool encrypt)
206 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
208 struct scatterlist *src = req->src;
209 struct scatterlist *dst = req->dst;
216 if (req->cryptlen < SM4_BLOCK_SIZE)
219 if (req->cryptlen == SM4_BLOCK_SIZE)
220 return sm4_cbc_crypt(req, ctx, encrypt);
223 skcipher_request_set_callback(&subreq, skcipher_request_flags(req),
227 cbc_blocks = DIV_ROUND_UP(req->cryptlen, SM4_BLOCK_SIZE) - 2;
231 req->iv);
238 if (req->dst != req->src)
239 dst = scatterwalk_ffwd(sg_dst, req->dst,
245 req->cryptlen - cbc_blocks * SM4_BLOCK_SIZE,
246 req->iv);
266 static int sm4_cbc_cts_encrypt(struct skcipher_request *req)
268 return sm4_cbc_cts_crypt(req, true);
271 static int sm4_cbc_cts_decrypt(struct skcipher_request *req)
273 return sm4_cbc_cts_crypt(req, false);
276 static int sm4_ctr_crypt(struct skcipher_request *req)
278 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
284 err = skcipher_walk_virt(&walk, req, false);
319 static int sm4_xts_crypt(struct skcipher_request *req, bool encrypt)
321 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
323 int tail = req->cryptlen % SM4_BLOCK_SIZE;
332 if (req->cryptlen < SM4_BLOCK_SIZE)
335 err = skcipher_walk_virt(&walk, req, false);
340 int nblocks = DIV_ROUND_UP(req->cryptlen, SM4_BLOCK_SIZE) - 2;
346 skcipher_request_flags(req),
348 skcipher_request_set_crypt(&subreq, req->src, req->dst,
349 nblocks * SM4_BLOCK_SIZE, req->iv);
387 dst = src = scatterwalk_ffwd(sg_src, req->src, subreq.cryptlen);
388 if (req->dst != req->src)
389 dst = scatterwalk_ffwd(sg_dst, req->dst, subreq.cryptlen);
392 req->iv);
414 static int sm4_xts_encrypt(struct skcipher_request *req)
416 return sm4_xts_crypt(req, true);
419 static int sm4_xts_decrypt(struct skcipher_request *req)
421 return sm4_xts_crypt(req, false);