Lines Matching refs:skreq
51 static void free_src_sglist(struct skcipher_request *skreq)
53 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
58 static void free_dst_sglist(struct skcipher_request *skreq)
60 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
67 struct skcipher_request *skreq = arg;
69 free_src_sglist(skreq);
70 free_dst_sglist(skreq);
76 skcipher_request_complete(skreq, err);
81 struct skcipher_request *skreq = arg;
82 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
83 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(skreq);
85 unsigned int start = skreq->cryptlen - ivsize;
93 scatterwalk_map_and_copy(skreq->iv, skreq->dst, start, ivsize,
96 if (skreq->src != skreq->dst) {
97 scatterwalk_map_and_copy(skreq->iv, skreq->src, start,
100 memcpy(skreq->iv, nkreq->iv_out, ivsize);
208 static int alloc_src_sglist(struct skcipher_request *skreq, int ivsize)
210 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
211 int nents = sg_nents(skreq->src) + 1;
219 nitrox_creq_copy_iv(nkreq->src, skreq->iv, ivsize);
220 nitrox_creq_set_src_sg(nkreq, nents, ivsize, skreq->src,
221 skreq->cryptlen);
226 static int alloc_dst_sglist(struct skcipher_request *skreq, int ivsize)
228 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
229 int nents = sg_nents(skreq->dst) + 3;
241 nitrox_creq_set_dst_sg(nkreq, nents, ivsize, skreq->dst,
242 skreq->cryptlen);
247 static int nitrox_skcipher_crypt(struct skcipher_request *skreq, bool enc)
249 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(skreq);
251 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
257 creq->flags = skreq->base.flags;
258 creq->gfp = (skreq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
266 creq->gph.param0 = cpu_to_be16(skreq->cryptlen);
275 ret = alloc_src_sglist(skreq, ivsize);
279 ret = alloc_dst_sglist(skreq, ivsize);
281 free_src_sglist(skreq);
287 skreq);
290 static int nitrox_cbc_decrypt(struct skcipher_request *skreq)
292 struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
293 struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(skreq);
295 gfp_t flags = (skreq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
297 unsigned int start = skreq->cryptlen - ivsize;
299 if (skreq->src != skreq->dst)
300 return nitrox_skcipher_crypt(skreq, false);
306 scatterwalk_map_and_copy(nkreq->iv_out, skreq->src, start, ivsize, 0);
307 return nitrox_skcipher_crypt(skreq, false);
310 static int nitrox_aes_encrypt(struct skcipher_request *skreq)
312 return nitrox_skcipher_crypt(skreq, true);
315 static int nitrox_aes_decrypt(struct skcipher_request *skreq)
317 return nitrox_skcipher_crypt(skreq, false);
327 static int nitrox_3des_encrypt(struct skcipher_request *skreq)
329 return nitrox_skcipher_crypt(skreq, true);
332 static int nitrox_3des_decrypt(struct skcipher_request *skreq)
334 return nitrox_skcipher_crypt(skreq, false);