• Home
  • Raw
  • Download

Lines Matching full: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) in crypto_gcm_reqctx() argument
87 unsigned long align = crypto_aead_alignmask(crypto_aead_reqtfm(req)); in crypto_gcm_reqctx()
89 return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1); in crypto_gcm_reqctx()
105 struct skcipher_request req; in crypto_gcm_setkey() member
123 skcipher_request_set_tfm(&data->req, ctr); in crypto_gcm_setkey()
124 skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | in crypto_gcm_setkey()
128 skcipher_request_set_crypt(&data->req, data->sg, data->sg, in crypto_gcm_setkey()
131 err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), in crypto_gcm_setkey()
152 static void crypto_gcm_init_common(struct aead_request *req) in crypto_gcm_init_common() argument
154 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_init_common()
159 memcpy(pctx->iv, req->iv, GCM_AES_IV_SIZE); in crypto_gcm_init_common()
164 sg = scatterwalk_ffwd(pctx->src + 1, req->src, req->assoclen); in crypto_gcm_init_common()
168 if (req->src != req->dst) { in crypto_gcm_init_common()
171 sg = scatterwalk_ffwd(pctx->dst + 1, req->dst, req->assoclen); in crypto_gcm_init_common()
177 static void crypto_gcm_init_crypt(struct aead_request *req, in crypto_gcm_init_crypt() argument
180 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_init_crypt()
182 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_init_crypt()
186 dst = req->src == req->dst ? pctx->src : pctx->dst; in crypto_gcm_init_crypt()
202 static int gcm_hash_update(struct aead_request *req, in gcm_hash_update() argument
207 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_update()
210 ahash_request_set_callback(ahreq, flags, compl, req); in gcm_hash_update()
216 static int gcm_hash_remain(struct aead_request *req, in gcm_hash_remain() argument
220 return gcm_hash_update(req, compl, &gcm_zeroes->sg, remain, flags); in gcm_hash_remain()
223 static int gcm_hash_len(struct aead_request *req, u32 flags) in gcm_hash_len() argument
225 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_len()
230 lengths.a = cpu_to_be64(req->assoclen * 8); in gcm_hash_len()
234 ahash_request_set_callback(ahreq, flags, gcm_hash_len_done, req); in gcm_hash_len()
241 static int gcm_hash_len_continue(struct aead_request *req, u32 flags) in gcm_hash_len_continue() argument
243 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_len_continue()
246 return gctx->complete(req, flags); in gcm_hash_len_continue()
251 struct aead_request *req = areq->data; in gcm_hash_len_done() local
256 err = gcm_hash_len_continue(req, 0); in gcm_hash_len_done()
261 aead_request_complete(req, err); in gcm_hash_len_done()
264 static int gcm_hash_crypt_remain_continue(struct aead_request *req, u32 flags) in gcm_hash_crypt_remain_continue() argument
266 return gcm_hash_len(req, flags) ?: in gcm_hash_crypt_remain_continue()
267 gcm_hash_len_continue(req, flags); in gcm_hash_crypt_remain_continue()
273 struct aead_request *req = areq->data; in gcm_hash_crypt_remain_done() local
278 err = gcm_hash_crypt_remain_continue(req, 0); in gcm_hash_crypt_remain_done()
283 aead_request_complete(req, err); in gcm_hash_crypt_remain_done()
286 static int gcm_hash_crypt_continue(struct aead_request *req, u32 flags) in gcm_hash_crypt_continue() argument
288 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_crypt_continue()
294 return gcm_hash_remain(req, remain, in gcm_hash_crypt_continue()
296 gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_crypt_continue()
298 return gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_crypt_continue()
303 struct aead_request *req = areq->data; in gcm_hash_crypt_done() local
308 err = gcm_hash_crypt_continue(req, 0); in gcm_hash_crypt_done()
313 aead_request_complete(req, err); in gcm_hash_crypt_done()
316 static int gcm_hash_assoc_remain_continue(struct aead_request *req, u32 flags) in gcm_hash_assoc_remain_continue() argument
318 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash_assoc_remain_continue()
322 return gcm_hash_update(req, gcm_hash_crypt_done, in gcm_hash_assoc_remain_continue()
324 gcm_hash_crypt_continue(req, flags); in gcm_hash_assoc_remain_continue()
326 return gcm_hash_crypt_remain_continue(req, flags); in gcm_hash_assoc_remain_continue()
332 struct aead_request *req = areq->data; in gcm_hash_assoc_remain_done() local
337 err = gcm_hash_assoc_remain_continue(req, 0); in gcm_hash_assoc_remain_done()
342 aead_request_complete(req, err); in gcm_hash_assoc_remain_done()
345 static int gcm_hash_assoc_continue(struct aead_request *req, u32 flags) in gcm_hash_assoc_continue() argument
349 remain = gcm_remain(req->assoclen); in gcm_hash_assoc_continue()
351 return gcm_hash_remain(req, remain, in gcm_hash_assoc_continue()
353 gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_assoc_continue()
355 return gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_assoc_continue()
360 struct aead_request *req = areq->data; in gcm_hash_assoc_done() local
365 err = gcm_hash_assoc_continue(req, 0); in gcm_hash_assoc_done()
370 aead_request_complete(req, err); in gcm_hash_assoc_done()
373 static int gcm_hash_init_continue(struct aead_request *req, u32 flags) in gcm_hash_init_continue() argument
375 if (req->assoclen) in gcm_hash_init_continue()
376 return gcm_hash_update(req, gcm_hash_assoc_done, in gcm_hash_init_continue()
377 req->src, req->assoclen, flags) ?: in gcm_hash_init_continue()
378 gcm_hash_assoc_continue(req, flags); in gcm_hash_init_continue()
380 return gcm_hash_assoc_remain_continue(req, flags); in gcm_hash_init_continue()
385 struct aead_request *req = areq->data; in gcm_hash_init_done() local
390 err = gcm_hash_init_continue(req, 0); in gcm_hash_init_done()
395 aead_request_complete(req, err); in gcm_hash_init_done()
398 static int gcm_hash(struct aead_request *req, u32 flags) in gcm_hash() argument
400 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_hash()
402 struct crypto_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); in gcm_hash()
406 ahash_request_set_callback(ahreq, flags, gcm_hash_init_done, req); in gcm_hash()
408 gcm_hash_init_continue(req, flags); in gcm_hash()
411 static int gcm_enc_copy_hash(struct aead_request *req, u32 flags) in gcm_enc_copy_hash() argument
413 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_enc_copy_hash()
414 struct crypto_aead *aead = crypto_aead_reqtfm(req); in gcm_enc_copy_hash()
418 scatterwalk_map_and_copy(auth_tag, req->dst, in gcm_enc_copy_hash()
419 req->assoclen + req->cryptlen, in gcm_enc_copy_hash()
424 static int gcm_encrypt_continue(struct aead_request *req, u32 flags) in gcm_encrypt_continue() argument
426 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_encrypt_continue()
429 gctx->src = sg_next(req->src == req->dst ? pctx->src : pctx->dst); in gcm_encrypt_continue()
430 gctx->cryptlen = req->cryptlen; in gcm_encrypt_continue()
433 return gcm_hash(req, flags); in gcm_encrypt_continue()
438 struct aead_request *req = areq->data; in gcm_encrypt_done() local
443 err = gcm_encrypt_continue(req, 0); in gcm_encrypt_done()
448 aead_request_complete(req, err); in gcm_encrypt_done()
451 static int crypto_gcm_encrypt(struct aead_request *req) in crypto_gcm_encrypt() argument
453 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_encrypt()
455 u32 flags = aead_request_flags(req); in crypto_gcm_encrypt()
457 crypto_gcm_init_common(req); in crypto_gcm_encrypt()
458 crypto_gcm_init_crypt(req, req->cryptlen); in crypto_gcm_encrypt()
459 skcipher_request_set_callback(skreq, flags, gcm_encrypt_done, req); in crypto_gcm_encrypt()
462 gcm_encrypt_continue(req, flags); in crypto_gcm_encrypt()
465 static int crypto_gcm_verify(struct aead_request *req) in crypto_gcm_verify() argument
467 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_verify()
468 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_verify()
472 unsigned int cryptlen = req->cryptlen - authsize; in crypto_gcm_verify()
475 scatterwalk_map_and_copy(iauth_tag, req->src, in crypto_gcm_verify()
476 req->assoclen + cryptlen, authsize, 0); in crypto_gcm_verify()
482 struct aead_request *req = areq->data; in gcm_decrypt_done() local
485 err = crypto_gcm_verify(req); in gcm_decrypt_done()
487 aead_request_complete(req, err); in gcm_decrypt_done()
490 static int gcm_dec_hash_continue(struct aead_request *req, u32 flags) in gcm_dec_hash_continue() argument
492 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in gcm_dec_hash_continue()
496 crypto_gcm_init_crypt(req, gctx->cryptlen); in gcm_dec_hash_continue()
497 skcipher_request_set_callback(skreq, flags, gcm_decrypt_done, req); in gcm_dec_hash_continue()
498 return crypto_skcipher_decrypt(skreq) ?: crypto_gcm_verify(req); in gcm_dec_hash_continue()
501 static int crypto_gcm_decrypt(struct aead_request *req) in crypto_gcm_decrypt() argument
503 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_gcm_decrypt()
504 struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req); in crypto_gcm_decrypt()
507 unsigned int cryptlen = req->cryptlen; in crypto_gcm_decrypt()
508 u32 flags = aead_request_flags(req); in crypto_gcm_decrypt()
512 crypto_gcm_init_common(req); in crypto_gcm_decrypt()
518 return gcm_hash(req, flags); in crypto_gcm_decrypt()
722 static struct aead_request *crypto_rfc4106_crypt(struct aead_request *req) in crypto_rfc4106_crypt() argument
724 struct crypto_rfc4106_req_ctx *rctx = aead_request_ctx(req); in crypto_rfc4106_crypt()
725 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_rfc4106_crypt()
733 scatterwalk_map_and_copy(iv + GCM_AES_IV_SIZE, req->src, 0, req->assoclen - 8, 0); in crypto_rfc4106_crypt()
736 memcpy(iv + 4, req->iv, 8); in crypto_rfc4106_crypt()
739 sg_set_buf(rctx->src, iv + GCM_AES_IV_SIZE, req->assoclen - 8); in crypto_rfc4106_crypt()
740 sg = scatterwalk_ffwd(rctx->src + 1, req->src, req->assoclen); in crypto_rfc4106_crypt()
744 if (req->src != req->dst) { in crypto_rfc4106_crypt()
746 sg_set_buf(rctx->dst, iv + GCM_AES_IV_SIZE, req->assoclen - 8); in crypto_rfc4106_crypt()
747 sg = scatterwalk_ffwd(rctx->dst + 1, req->dst, req->assoclen); in crypto_rfc4106_crypt()
753 aead_request_set_callback(subreq, req->base.flags, req->base.complete, in crypto_rfc4106_crypt()
754 req->base.data); in crypto_rfc4106_crypt()
756 req->src == req->dst ? rctx->src : rctx->dst, in crypto_rfc4106_crypt()
757 req->cryptlen, iv); in crypto_rfc4106_crypt()
758 aead_request_set_ad(subreq, req->assoclen - 8); in crypto_rfc4106_crypt()
763 static int crypto_rfc4106_encrypt(struct aead_request *req) in crypto_rfc4106_encrypt() argument
767 err = crypto_ipsec_check_assoclen(req->assoclen); in crypto_rfc4106_encrypt()
771 req = crypto_rfc4106_crypt(req); in crypto_rfc4106_encrypt()
773 return crypto_aead_encrypt(req); in crypto_rfc4106_encrypt()
776 static int crypto_rfc4106_decrypt(struct aead_request *req) in crypto_rfc4106_decrypt() argument
780 err = crypto_ipsec_check_assoclen(req->assoclen); in crypto_rfc4106_decrypt()
784 req = crypto_rfc4106_crypt(req); in crypto_rfc4106_decrypt()
786 return crypto_aead_decrypt(req); in crypto_rfc4106_decrypt()
928 static int crypto_rfc4543_crypt(struct aead_request *req, bool enc) in crypto_rfc4543_crypt() argument
930 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_rfc4543_crypt()
932 struct crypto_rfc4543_req_ctx *rctx = aead_request_ctx(req); in crypto_rfc4543_crypt()
939 if (req->src != req->dst) { in crypto_rfc4543_crypt()
940 err = crypto_rfc4543_copy_src_to_dst(req, enc); in crypto_rfc4543_crypt()
946 memcpy(iv + 4, req->iv, 8); in crypto_rfc4543_crypt()
949 aead_request_set_callback(subreq, req->base.flags, in crypto_rfc4543_crypt()
950 req->base.complete, req->base.data); in crypto_rfc4543_crypt()
951 aead_request_set_crypt(subreq, req->src, req->dst, in crypto_rfc4543_crypt()
953 aead_request_set_ad(subreq, req->assoclen + req->cryptlen - in crypto_rfc4543_crypt()
959 static int crypto_rfc4543_copy_src_to_dst(struct aead_request *req, bool enc) in crypto_rfc4543_copy_src_to_dst() argument
961 struct crypto_aead *aead = crypto_aead_reqtfm(req); in crypto_rfc4543_copy_src_to_dst()
964 unsigned int nbytes = req->assoclen + req->cryptlen - in crypto_rfc4543_copy_src_to_dst()
969 skcipher_request_set_callback(nreq, req->base.flags, NULL, NULL); in crypto_rfc4543_copy_src_to_dst()
970 skcipher_request_set_crypt(nreq, req->src, req->dst, nbytes, NULL); in crypto_rfc4543_copy_src_to_dst()
975 static int crypto_rfc4543_encrypt(struct aead_request *req) in crypto_rfc4543_encrypt() argument
977 return crypto_ipsec_check_assoclen(req->assoclen) ?: in crypto_rfc4543_encrypt()
978 crypto_rfc4543_crypt(req, true); in crypto_rfc4543_encrypt()
981 static int crypto_rfc4543_decrypt(struct aead_request *req) in crypto_rfc4543_decrypt() argument
983 return crypto_ipsec_check_assoclen(req->assoclen) ?: in crypto_rfc4543_decrypt()
984 crypto_rfc4543_crypt(req, false); in crypto_rfc4543_decrypt()