Lines Matching refs:req

58 	int (*complete)(struct aead_request *req, u32 flags);
81 struct aead_request *req) in crypto_gcm_reqctx() argument
83 unsigned long align = crypto_aead_alignmask(crypto_aead_reqtfm(req)); in crypto_gcm_reqctx()
85 return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1); in crypto_gcm_reqctx()
101 struct skcipher_request req; in crypto_gcm_setkey() member
119 skcipher_request_set_tfm(&data->req, ctr); in crypto_gcm_setkey()
120 skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | in crypto_gcm_setkey()
124 skcipher_request_set_crypt(&data->req, data->sg, data->sg, in crypto_gcm_setkey()
127 err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), in crypto_gcm_setkey()
148 static void crypto_gcm_init_common(struct aead_request *req) in crypto_gcm_init_common() argument
150 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_init_common()
155 memcpy(pctx->iv, req->iv, GCM_AES_IV_SIZE); in crypto_gcm_init_common()
160 sg = scatterwalk_ffwd(pctx->src + 1, req->src, req->assoclen); in crypto_gcm_init_common()
164 if (req->src != req->dst) { in crypto_gcm_init_common()
167 sg = scatterwalk_ffwd(pctx->dst + 1, req->dst, req->assoclen); in crypto_gcm_init_common()
173 static void crypto_gcm_init_crypt(struct aead_request *req, in crypto_gcm_init_crypt() argument
176 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_init_crypt()
178 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_init_crypt()
182 dst = req->src == req->dst ? pctx->src : pctx->dst; in crypto_gcm_init_crypt()
198 static int gcm_hash_update(struct aead_request *req, in gcm_hash_update() argument
203 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_update()
206 ahash_request_set_callback(ahreq, flags, compl, req); in gcm_hash_update()
212 static int gcm_hash_remain(struct aead_request *req, in gcm_hash_remain() argument
216 return gcm_hash_update(req, compl, &gcm_zeroes->sg, remain, flags); in gcm_hash_remain()
219 static int gcm_hash_len(struct aead_request *req, u32 flags) in gcm_hash_len() argument
221 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_len()
226 lengths.a = cpu_to_be64(req->assoclen * 8); in gcm_hash_len()
230 ahash_request_set_callback(ahreq, flags, gcm_hash_len_done, req); in gcm_hash_len()
237 static int gcm_hash_len_continue(struct aead_request *req, u32 flags) in gcm_hash_len_continue() argument
239 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_len_continue()
242 return gctx->complete(req, flags); in gcm_hash_len_continue()
247 struct aead_request *req = data; in gcm_hash_len_done() local
252 err = gcm_hash_len_continue(req, 0); in gcm_hash_len_done()
257 aead_request_complete(req, err); in gcm_hash_len_done()
260 static int gcm_hash_crypt_remain_continue(struct aead_request *req, u32 flags) in gcm_hash_crypt_remain_continue() argument
262 return gcm_hash_len(req, flags) ?: in gcm_hash_crypt_remain_continue()
263 gcm_hash_len_continue(req, flags); in gcm_hash_crypt_remain_continue()
268 struct aead_request *req = data; in gcm_hash_crypt_remain_done() local
273 err = gcm_hash_crypt_remain_continue(req, 0); in gcm_hash_crypt_remain_done()
278 aead_request_complete(req, err); in gcm_hash_crypt_remain_done()
281 static int gcm_hash_crypt_continue(struct aead_request *req, u32 flags) in gcm_hash_crypt_continue() argument
283 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_crypt_continue()
289 return gcm_hash_remain(req, remain, in gcm_hash_crypt_continue()
291 gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_crypt_continue()
293 return gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_crypt_continue()
298 struct aead_request *req = data; in gcm_hash_crypt_done() local
303 err = gcm_hash_crypt_continue(req, 0); in gcm_hash_crypt_done()
308 aead_request_complete(req, err); in gcm_hash_crypt_done()
311 static int gcm_hash_assoc_remain_continue(struct aead_request *req, u32 flags) in gcm_hash_assoc_remain_continue() argument
313 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_assoc_remain_continue()
317 return gcm_hash_update(req, gcm_hash_crypt_done, in gcm_hash_assoc_remain_continue()
319 gcm_hash_crypt_continue(req, flags); in gcm_hash_assoc_remain_continue()
321 return gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_assoc_remain_continue()
326 struct aead_request *req = data; in gcm_hash_assoc_remain_done() local
331 err = gcm_hash_assoc_remain_continue(req, 0); in gcm_hash_assoc_remain_done()
336 aead_request_complete(req, err); in gcm_hash_assoc_remain_done()
339 static int gcm_hash_assoc_continue(struct aead_request *req, u32 flags) in gcm_hash_assoc_continue() argument
343 remain = gcm_remain(req->assoclen); in gcm_hash_assoc_continue()
345 return gcm_hash_remain(req, remain, in gcm_hash_assoc_continue()
347 gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_assoc_continue()
349 return gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_assoc_continue()
354 struct aead_request *req = data; in gcm_hash_assoc_done() local
359 err = gcm_hash_assoc_continue(req, 0); in gcm_hash_assoc_done()
364 aead_request_complete(req, err); in gcm_hash_assoc_done()
367 static int gcm_hash_init_continue(struct aead_request *req, u32 flags) in gcm_hash_init_continue() argument
369 if (req->assoclen) in gcm_hash_init_continue()
370 return gcm_hash_update(req, gcm_hash_assoc_done, in gcm_hash_init_continue()
371 req->src, req->assoclen, flags) ?: in gcm_hash_init_continue()
372 gcm_hash_assoc_continue(req, flags); in gcm_hash_init_continue()
374 return gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_init_continue()
379 struct aead_request *req = data; in gcm_hash_init_done() local
384 err = gcm_hash_init_continue(req, 0); in gcm_hash_init_done()
389 aead_request_complete(req, err); in gcm_hash_init_done()
392 static int gcm_hash(struct aead_request *req, u32 flags) in gcm_hash() argument
394 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash()
396 struct crypto_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in gcm_hash()
400 ahash_request_set_callback(ahreq, flags, gcm_hash_init_done, req); in gcm_hash()
402 gcm_hash_init_continue(req, flags); in gcm_hash()
405 static int gcm_enc_copy_hash(struct aead_request *req, u32 flags) in gcm_enc_copy_hash() argument
407 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_enc_copy_hash()
408 struct crypto_aead *aead = crypto_aead_reqtfm(req); in gcm_enc_copy_hash()
412 scatterwalk_map_and_copy(auth_tag, req->dst, in gcm_enc_copy_hash()
413 req->assoclen + req->cryptlen, in gcm_enc_copy_hash()
418 static int gcm_encrypt_continue(struct aead_request *req, u32 flags) in gcm_encrypt_continue() argument
420 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_encrypt_continue()
423 gctx->src = sg_next(req->src == req->dst ? pctx->src : pctx->dst); in gcm_encrypt_continue()
424 gctx->cryptlen = req->cryptlen; in gcm_encrypt_continue()
427 return gcm_hash(req, flags); in gcm_encrypt_continue()
432 struct aead_request *req = data; in gcm_encrypt_done() local
437 err = gcm_encrypt_continue(req, 0); in gcm_encrypt_done()
442 aead_request_complete(req, err); in gcm_encrypt_done()
445 static int crypto_gcm_encrypt(struct aead_request *req) in crypto_gcm_encrypt() argument
447 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_encrypt()
449 u32 flags = aead_request_flags(req); in crypto_gcm_encrypt()
451 crypto_gcm_init_common(req); in crypto_gcm_encrypt()
452 crypto_gcm_init_crypt(req, req->cryptlen); in crypto_gcm_encrypt()
453 skcipher_request_set_callback(skreq, flags, gcm_encrypt_done, req); in crypto_gcm_encrypt()
456 gcm_encrypt_continue(req, flags); in crypto_gcm_encrypt()
459 static int crypto_gcm_verify(struct aead_request *req) in crypto_gcm_verify() argument
461 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_verify()
462 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_verify()
466 unsigned int cryptlen = req->cryptlen - authsize; in crypto_gcm_verify()
469 scatterwalk_map_and_copy(iauth_tag, req->src, in crypto_gcm_verify()
470 req->assoclen + cryptlen, authsize, 0); in crypto_gcm_verify()
476 struct aead_request *req = data; in gcm_decrypt_done() local
479 err = crypto_gcm_verify(req); in gcm_decrypt_done()
481 aead_request_complete(req, err); in gcm_decrypt_done()
484 static int gcm_dec_hash_continue(struct aead_request *req, u32 flags) in gcm_dec_hash_continue() argument
486 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_dec_hash_continue()
490 crypto_gcm_init_crypt(req, gctx->cryptlen); in gcm_dec_hash_continue()
491 skcipher_request_set_callback(skreq, flags, gcm_decrypt_done, req); in gcm_dec_hash_continue()
492 return crypto_skcipher_decrypt(skreq) ?: crypto_gcm_verify(req); in gcm_dec_hash_continue()
495 static int crypto_gcm_decrypt(struct aead_request *req) in crypto_gcm_decrypt() argument
497 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_decrypt()
498 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_decrypt()
501 unsigned int cryptlen = req->cryptlen; in crypto_gcm_decrypt()
502 u32 flags = aead_request_flags(req); in crypto_gcm_decrypt()
506 crypto_gcm_init_common(req); in crypto_gcm_decrypt()
512 return gcm_hash(req, flags); in crypto_gcm_decrypt()
714 static struct aead_request *crypto_rfc4106_crypt(struct aead_request *req) in crypto_rfc4106_crypt() argument
716 struct crypto_rfc4106_req_ctx *rctx = aead_request_ctx(req); in crypto_rfc4106_crypt()
717 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_rfc4106_crypt()
725 scatterwalk_map_and_copy(iv + GCM_AES_IV_SIZE, req->src, 0, req->assoclen - 8, 0); in crypto_rfc4106_crypt()
728 memcpy(iv + 4, req->iv, 8); in crypto_rfc4106_crypt()
731 sg_set_buf(rctx->src, iv + GCM_AES_IV_SIZE, req->assoclen - 8); in crypto_rfc4106_crypt()
732 sg = scatterwalk_ffwd(rctx->src + 1, req->src, req->assoclen); in crypto_rfc4106_crypt()
736 if (req->src != req->dst) { in crypto_rfc4106_crypt()
738 sg_set_buf(rctx->dst, iv + GCM_AES_IV_SIZE, req->assoclen - 8); in crypto_rfc4106_crypt()
739 sg = scatterwalk_ffwd(rctx->dst + 1, req->dst, req->assoclen); in crypto_rfc4106_crypt()
745 aead_request_set_callback(subreq, req->base.flags, req->base.complete, in crypto_rfc4106_crypt()
746 req->base.data); in crypto_rfc4106_crypt()
748 req->src == req->dst ? rctx->src : rctx->dst, in crypto_rfc4106_crypt()
749 req->cryptlen, iv); in crypto_rfc4106_crypt()
750 aead_request_set_ad(subreq, req->assoclen - 8); in crypto_rfc4106_crypt()
755 static int crypto_rfc4106_encrypt(struct aead_request *req) in crypto_rfc4106_encrypt() argument
759 err = crypto_ipsec_check_assoclen(req->assoclen); in crypto_rfc4106_encrypt()
763 req = crypto_rfc4106_crypt(req); in crypto_rfc4106_encrypt()
765 return crypto_aead_encrypt(req); in crypto_rfc4106_encrypt()
768 static int crypto_rfc4106_decrypt(struct aead_request *req) in crypto_rfc4106_decrypt() argument
772 err = crypto_ipsec_check_assoclen(req->assoclen); in crypto_rfc4106_decrypt()
776 req = crypto_rfc4106_crypt(req); in crypto_rfc4106_decrypt()
778 return crypto_aead_decrypt(req); in crypto_rfc4106_decrypt()
920 static int crypto_rfc4543_crypt(struct aead_request *req, bool enc) in crypto_rfc4543_crypt() argument
922 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_rfc4543_crypt()
924 struct crypto_rfc4543_req_ctx *rctx = aead_request_ctx(req); in crypto_rfc4543_crypt()
930 if (req->src != req->dst) { in crypto_rfc4543_crypt()
931 unsigned int nbytes = req->assoclen + req->cryptlen - in crypto_rfc4543_crypt()
934 memcpy_sglist(req->dst, req->src, nbytes); in crypto_rfc4543_crypt()
938 memcpy(iv + 4, req->iv, 8); in crypto_rfc4543_crypt()
941 aead_request_set_callback(subreq, req->base.flags, in crypto_rfc4543_crypt()
942 req->base.complete, req->base.data); in crypto_rfc4543_crypt()
943 aead_request_set_crypt(subreq, req->src, req->dst, in crypto_rfc4543_crypt()
945 aead_request_set_ad(subreq, req->assoclen + req->cryptlen - in crypto_rfc4543_crypt()
951 static int crypto_rfc4543_encrypt(struct aead_request *req) in crypto_rfc4543_encrypt() argument
953 return crypto_ipsec_check_assoclen(req->assoclen) ?: in crypto_rfc4543_encrypt()
954 crypto_rfc4543_crypt(req, true); in crypto_rfc4543_encrypt()
957 static int crypto_rfc4543_decrypt(struct aead_request *req) in crypto_rfc4543_decrypt() argument
959 return crypto_ipsec_check_assoclen(req->assoclen) ?: in crypto_rfc4543_decrypt()
960 crypto_rfc4543_crypt(req, false); in crypto_rfc4543_decrypt()