Lines Matching refs:req

60 	int (*complete)(struct aead_request *req, u32 flags);
82 static int crypto_rfc4543_copy_src_to_dst(struct aead_request *req, bool enc);
85 struct aead_request *req)
87 unsigned long align = crypto_aead_alignmask(crypto_aead_reqtfm(req));
89 return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1);
105 struct skcipher_request req;
123 skcipher_request_set_tfm(&data->req, ctr);
124 skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP |
128 skcipher_request_set_crypt(&data->req, data->sg, data->sg,
131 err = crypto_wait_req(crypto_skcipher_encrypt(&data->req),
152 static void crypto_gcm_init_common(struct aead_request *req)
154 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
159 memcpy(pctx->iv, req->iv, GCM_AES_IV_SIZE);
164 sg = scatterwalk_ffwd(pctx->src + 1, req->src, req->assoclen);
168 if (req->src != req->dst) {
171 sg = scatterwalk_ffwd(pctx->dst + 1, req->dst, req->assoclen);
177 static void crypto_gcm_init_crypt(struct aead_request *req,
180 struct crypto_aead *aead = crypto_aead_reqtfm(req);
182 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
186 dst = req->src == req->dst ? pctx->src : pctx->dst;
202 static int gcm_hash_update(struct aead_request *req,
207 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
210 ahash_request_set_callback(ahreq, flags, compl, req);
216 static int gcm_hash_remain(struct aead_request *req,
220 return gcm_hash_update(req, compl, &gcm_zeroes->sg, remain, flags);
223 static int gcm_hash_len(struct aead_request *req, u32 flags)
225 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
230 lengths.a = cpu_to_be64(req->assoclen * 8);
234 ahash_request_set_callback(ahreq, flags, gcm_hash_len_done, req);
241 static int gcm_hash_len_continue(struct aead_request *req, u32 flags)
243 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
246 return gctx->complete(req, flags);
251 struct aead_request *req = data;
256 err = gcm_hash_len_continue(req, 0);
261 aead_request_complete(req, err);
264 static int gcm_hash_crypt_remain_continue(struct aead_request *req, u32 flags)
266 return gcm_hash_len(req, flags) ?:
267 gcm_hash_len_continue(req, flags);
272 struct aead_request *req = data;
277 err = gcm_hash_crypt_remain_continue(req, 0);
282 aead_request_complete(req, err);
285 static int gcm_hash_crypt_continue(struct aead_request *req, u32 flags)
287 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
293 return gcm_hash_remain(req, remain,
295 gcm_hash_crypt_remain_continue(req, flags);
297 return gcm_hash_crypt_remain_continue(req, flags);
302 struct aead_request *req = data;
307 err = gcm_hash_crypt_continue(req, 0);
312 aead_request_complete(req, err);
315 static int gcm_hash_assoc_remain_continue(struct aead_request *req, u32 flags)
317 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
321 return gcm_hash_update(req, gcm_hash_crypt_done,
323 gcm_hash_crypt_continue(req, flags);
325 return gcm_hash_crypt_remain_continue(req, flags);
330 struct aead_request *req = data;
335 err = gcm_hash_assoc_remain_continue(req, 0);
340 aead_request_complete(req, err);
343 static int gcm_hash_assoc_continue(struct aead_request *req, u32 flags)
347 remain = gcm_remain(req->assoclen);
349 return gcm_hash_remain(req, remain,
351 gcm_hash_assoc_remain_continue(req, flags);
353 return gcm_hash_assoc_remain_continue(req, flags);
358 struct aead_request *req = data;
363 err = gcm_hash_assoc_continue(req, 0);
368 aead_request_complete(req, err);
371 static int gcm_hash_init_continue(struct aead_request *req, u32 flags)
373 if (req->assoclen)
374 return gcm_hash_update(req, gcm_hash_assoc_done,
375 req->src, req->assoclen, flags) ?:
376 gcm_hash_assoc_continue(req, flags);
378 return gcm_hash_assoc_remain_continue(req, flags);
383 struct aead_request *req = data;
388 err = gcm_hash_init_continue(req, 0);
393 aead_request_complete(req, err);
396 static int gcm_hash(struct aead_request *req, u32 flags)
398 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
400 struct crypto_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
404 ahash_request_set_callback(ahreq, flags, gcm_hash_init_done, req);
406 gcm_hash_init_continue(req, flags);
409 static int gcm_enc_copy_hash(struct aead_request *req, u32 flags)
411 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
412 struct crypto_aead *aead = crypto_aead_reqtfm(req);
416 scatterwalk_map_and_copy(auth_tag, req->dst,
417 req->assoclen + req->cryptlen,
422 static int gcm_encrypt_continue(struct aead_request *req, u32 flags)
424 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
427 gctx->src = sg_next(req->src == req->dst ? pctx->src : pctx->dst);
428 gctx->cryptlen = req->cryptlen;
431 return gcm_hash(req, flags);
436 struct aead_request *req = data;
441 err = gcm_encrypt_continue(req, 0);
446 aead_request_complete(req, err);
449 static int crypto_gcm_encrypt(struct aead_request *req)
451 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
453 u32 flags = aead_request_flags(req);
455 crypto_gcm_init_common(req);
456 crypto_gcm_init_crypt(req, req->cryptlen);
457 skcipher_request_set_callback(skreq, flags, gcm_encrypt_done, req);
460 gcm_encrypt_continue(req, flags);
463 static int crypto_gcm_verify(struct aead_request *req)
465 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
466 struct crypto_aead *aead = crypto_aead_reqtfm(req);
470 unsigned int cryptlen = req->cryptlen - authsize;
473 scatterwalk_map_and_copy(iauth_tag, req->src,
474 req->assoclen + cryptlen, authsize, 0);
480 struct aead_request *req = data;
483 err = crypto_gcm_verify(req);
485 aead_request_complete(req, err);
488 static int gcm_dec_hash_continue(struct aead_request *req, u32 flags)
490 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
494 crypto_gcm_init_crypt(req, gctx->cryptlen);
495 skcipher_request_set_callback(skreq, flags, gcm_decrypt_done, req);
496 return crypto_skcipher_decrypt(skreq) ?: crypto_gcm_verify(req);
499 static int crypto_gcm_decrypt(struct aead_request *req)
501 struct crypto_aead *aead = crypto_aead_reqtfm(req);
502 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
505 unsigned int cryptlen = req->cryptlen;
506 u32 flags = aead_request_flags(req);
510 crypto_gcm_init_common(req);
516 return gcm_hash(req, flags);
720 static struct aead_request *crypto_rfc4106_crypt(struct aead_request *req)
722 struct crypto_rfc4106_req_ctx *rctx = aead_request_ctx(req);
723 struct crypto_aead *aead = crypto_aead_reqtfm(req);
731 scatterwalk_map_and_copy(iv + GCM_AES_IV_SIZE, req->src, 0, req->assoclen - 8, 0);
734 memcpy(iv + 4, req->iv, 8);
737 sg_set_buf(rctx->src, iv + GCM_AES_IV_SIZE, req->assoclen - 8);
738 sg = scatterwalk_ffwd(rctx->src + 1, req->src, req->assoclen);
742 if (req->src != req->dst) {
744 sg_set_buf(rctx->dst, iv + GCM_AES_IV_SIZE, req->assoclen - 8);
745 sg = scatterwalk_ffwd(rctx->dst + 1, req->dst, req->assoclen);
751 aead_request_set_callback(subreq, req->base.flags, req->base.complete,
752 req->base.data);
754 req->src == req->dst ? rctx->src : rctx->dst,
755 req->cryptlen, iv);
756 aead_request_set_ad(subreq, req->assoclen - 8);
761 static int crypto_rfc4106_encrypt(struct aead_request *req)
765 err = crypto_ipsec_check_assoclen(req->assoclen);
769 req = crypto_rfc4106_crypt(req);
771 return crypto_aead_encrypt(req);
774 static int crypto_rfc4106_decrypt(struct aead_request *req)
778 err = crypto_ipsec_check_assoclen(req->assoclen);
782 req = crypto_rfc4106_crypt(req);
784 return crypto_aead_decrypt(req);
926 static int crypto_rfc4543_crypt(struct aead_request *req, bool enc)
928 struct crypto_aead *aead = crypto_aead_reqtfm(req);
930 struct crypto_rfc4543_req_ctx *rctx = aead_request_ctx(req);
937 if (req->src != req->dst) {
938 err = crypto_rfc4543_copy_src_to_dst(req, enc);
944 memcpy(iv + 4, req->iv, 8);
947 aead_request_set_callback(subreq, req->base.flags,
948 req->base.complete, req->base.data);
949 aead_request_set_crypt(subreq, req->src, req->dst,
951 aead_request_set_ad(subreq, req->assoclen + req->cryptlen -
957 static int crypto_rfc4543_copy_src_to_dst(struct aead_request *req, bool enc)
959 struct crypto_aead *aead = crypto_aead_reqtfm(req);
962 unsigned int nbytes = req->assoclen + req->cryptlen -
967 skcipher_request_set_callback(nreq, req->base.flags, NULL, NULL);
968 skcipher_request_set_crypt(nreq, req->src, req->dst, nbytes, NULL);
973 static int crypto_rfc4543_encrypt(struct aead_request *req)
975 return crypto_ipsec_check_assoclen(req->assoclen) ?:
976 crypto_rfc4543_crypt(req, true);
979 static int crypto_rfc4543_decrypt(struct aead_request *req)
981 return crypto_ipsec_check_assoclen(req->assoclen) ?:
982 crypto_rfc4543_crypt(req, false);