Lines Matching refs:ctx

71 #define GET_SREQ(areq, ctx) (struct skcipher_async_req *)((char *)areq + \  argument
72 crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req)))
74 #define GET_REQ_SIZE(ctx) \ argument
75 crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req))
77 #define GET_IV_SIZE(ctx) \ argument
78 crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(&ctx->req))
107 struct skcipher_ctx *ctx = ask->private; in skcipher_async_cb() local
108 struct skcipher_async_req *sreq = GET_SREQ(req, ctx); in skcipher_async_cb()
111 atomic_dec(&ctx->inflight); in skcipher_async_cb()
120 struct skcipher_ctx *ctx = ask->private; in skcipher_sndbuf() local
123 ctx->used, 0); in skcipher_sndbuf()
134 struct skcipher_ctx *ctx = ask->private; in skcipher_alloc_sgl() local
138 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_alloc_sgl()
139 if (!list_empty(&ctx->tsgl)) in skcipher_alloc_sgl()
155 list_add_tail(&sgl->list, &ctx->tsgl); in skcipher_alloc_sgl()
164 struct skcipher_ctx *ctx = ask->private; in skcipher_pull_sgl() local
169 while (!list_empty(&ctx->tsgl)) { in skcipher_pull_sgl()
170 sgl = list_first_entry(&ctx->tsgl, struct skcipher_sg_list, in skcipher_pull_sgl()
184 ctx->used -= plen; in skcipher_pull_sgl()
199 if (!ctx->used) in skcipher_pull_sgl()
200 ctx->merge = 0; in skcipher_pull_sgl()
206 struct skcipher_ctx *ctx = ask->private; in skcipher_free_sgl() local
208 skcipher_pull_sgl(sk, ctx->used, 1); in skcipher_free_sgl()
257 struct skcipher_ctx *ctx = ask->private; in skcipher_wait_for_data() local
273 if (sk_wait_event(sk, &timeout, ctx->used)) { in skcipher_wait_for_data()
288 struct skcipher_ctx *ctx = ask->private; in skcipher_data_wakeup() local
291 if (!ctx->used) in skcipher_data_wakeup()
309 struct skcipher_ctx *ctx = ask->private; in skcipher_sendmsg() local
310 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); in skcipher_sendmsg()
344 if (!ctx->more && ctx->used) in skcipher_sendmsg()
348 ctx->enc = enc; in skcipher_sendmsg()
350 memcpy(ctx->iv, con.iv->iv, ivsize); in skcipher_sendmsg()
358 if (ctx->merge) { in skcipher_sendmsg()
359 sgl = list_entry(ctx->tsgl.prev, in skcipher_sendmsg()
372 ctx->merge = (sg->offset + sg->length) & in skcipher_sendmsg()
375 ctx->used += len; in skcipher_sendmsg()
393 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_sendmsg()
416 ctx->used += plen; in skcipher_sendmsg()
425 ctx->merge = plen & (PAGE_SIZE - 1); in skcipher_sendmsg()
430 ctx->more = msg->msg_flags & MSG_MORE; in skcipher_sendmsg()
444 struct skcipher_ctx *ctx = ask->private; in skcipher_sendpage() local
452 if (!ctx->more && ctx->used) in skcipher_sendpage()
468 ctx->merge = 0; in skcipher_sendpage()
469 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_sendpage()
478 ctx->used += size; in skcipher_sendpage()
481 ctx->more = flags & MSG_MORE; in skcipher_sendpage()
490 static int skcipher_all_sg_nents(struct skcipher_ctx *ctx) in skcipher_all_sg_nents() argument
496 list_for_each_entry(sgl, &ctx->tsgl, list) { in skcipher_all_sg_nents()
512 struct skcipher_ctx *ctx = ask->private; in skcipher_recvmsg_async() local
518 unsigned int txbufs = 0, len = 0, tx_nents = skcipher_all_sg_nents(ctx); in skcipher_recvmsg_async()
520 GET_REQ_SIZE(ctx) + GET_IV_SIZE(ctx); in skcipher_recvmsg_async()
529 sreq = GET_SREQ(req, ctx); in skcipher_recvmsg_async()
539 memcpy(sreq->iv, ctx->iv, GET_IV_SIZE(ctx)); in skcipher_recvmsg_async()
540 ablkcipher_request_set_tfm(req, crypto_ablkcipher_reqtfm(&ctx->req)); in skcipher_recvmsg_async()
548 if (!ctx->used) { in skcipher_recvmsg_async()
553 sgl = list_first_entry(&ctx->tsgl, in skcipher_recvmsg_async()
560 used = min_t(unsigned long, ctx->used, in skcipher_recvmsg_async()
619 err = ctx->enc ? crypto_ablkcipher_encrypt(req) : in skcipher_recvmsg_async()
622 atomic_inc(&ctx->inflight); in skcipher_recvmsg_async()
640 struct skcipher_ctx *ctx = ask->private; in skcipher_recvmsg_sync() local
642 &ctx->req)); in skcipher_recvmsg_sync()
651 sgl = list_first_entry(&ctx->tsgl, in skcipher_recvmsg_sync()
658 if (!ctx->used) { in skcipher_recvmsg_sync()
664 used = min_t(unsigned long, ctx->used, msg_data_left(msg)); in skcipher_recvmsg_sync()
666 used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used); in skcipher_recvmsg_sync()
671 if (ctx->more || used < ctx->used) in skcipher_recvmsg_sync()
678 ablkcipher_request_set_crypt(&ctx->req, sg, in skcipher_recvmsg_sync()
679 ctx->rsgl.sg, used, in skcipher_recvmsg_sync()
680 ctx->iv); in skcipher_recvmsg_sync()
683 ctx->enc ? in skcipher_recvmsg_sync()
684 crypto_ablkcipher_encrypt(&ctx->req) : in skcipher_recvmsg_sync()
685 crypto_ablkcipher_decrypt(&ctx->req), in skcipher_recvmsg_sync()
686 &ctx->completion); in skcipher_recvmsg_sync()
689 af_alg_free_sg(&ctx->rsgl); in skcipher_recvmsg_sync()
721 struct skcipher_ctx *ctx = ask->private; in skcipher_poll() local
727 if (ctx->used) in skcipher_poll()
896 struct skcipher_ctx *ctx = ask->private; in skcipher_wait() local
899 while (atomic_read(&ctx->inflight) && ctr++ < 100) in skcipher_wait()
906 struct skcipher_ctx *ctx = ask->private; in skcipher_sock_destruct() local
907 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); in skcipher_sock_destruct()
909 if (atomic_read(&ctx->inflight)) in skcipher_sock_destruct()
913 sock_kzfree_s(sk, ctx->iv, crypto_ablkcipher_ivsize(tfm)); in skcipher_sock_destruct()
914 sock_kfree_s(sk, ctx, ctx->len); in skcipher_sock_destruct()
920 struct skcipher_ctx *ctx; in skcipher_accept_parent_nokey() local
924 unsigned int len = sizeof(*ctx) + crypto_ablkcipher_reqsize(skcipher); in skcipher_accept_parent_nokey()
926 ctx = sock_kmalloc(sk, len, GFP_KERNEL); in skcipher_accept_parent_nokey()
927 if (!ctx) in skcipher_accept_parent_nokey()
930 ctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(skcipher), in skcipher_accept_parent_nokey()
932 if (!ctx->iv) { in skcipher_accept_parent_nokey()
933 sock_kfree_s(sk, ctx, len); in skcipher_accept_parent_nokey()
937 memset(ctx->iv, 0, crypto_ablkcipher_ivsize(skcipher)); in skcipher_accept_parent_nokey()
939 INIT_LIST_HEAD(&ctx->tsgl); in skcipher_accept_parent_nokey()
940 ctx->len = len; in skcipher_accept_parent_nokey()
941 ctx->used = 0; in skcipher_accept_parent_nokey()
942 ctx->more = 0; in skcipher_accept_parent_nokey()
943 ctx->merge = 0; in skcipher_accept_parent_nokey()
944 ctx->enc = 0; in skcipher_accept_parent_nokey()
945 atomic_set(&ctx->inflight, 0); in skcipher_accept_parent_nokey()
946 af_alg_init_completion(&ctx->completion); in skcipher_accept_parent_nokey()
948 ask->private = ctx; in skcipher_accept_parent_nokey()
950 ablkcipher_request_set_tfm(&ctx->req, skcipher); in skcipher_accept_parent_nokey()
951 ablkcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, in skcipher_accept_parent_nokey()
952 af_alg_complete, &ctx->completion); in skcipher_accept_parent_nokey()