Lines Matching refs:ctx
109 struct skcipher_ctx *ctx = ask->private; in skcipher_sndbuf() local
112 ctx->used, 0); in skcipher_sndbuf()
123 struct skcipher_ctx *ctx = ask->private; in skcipher_alloc_sgl() local
127 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_alloc_sgl()
128 if (!list_empty(&ctx->tsgl)) in skcipher_alloc_sgl()
144 list_add_tail(&sgl->list, &ctx->tsgl); in skcipher_alloc_sgl()
153 struct skcipher_ctx *ctx = ask->private; in skcipher_pull_sgl() local
158 while (!list_empty(&ctx->tsgl)) { in skcipher_pull_sgl()
159 sgl = list_first_entry(&ctx->tsgl, struct skcipher_sg_list, in skcipher_pull_sgl()
173 ctx->used -= plen; in skcipher_pull_sgl()
188 if (!ctx->used) in skcipher_pull_sgl()
189 ctx->merge = 0; in skcipher_pull_sgl()
195 struct skcipher_ctx *ctx = ask->private; in skcipher_free_sgl() local
197 skcipher_pull_sgl(sk, ctx->used, 1); in skcipher_free_sgl()
246 struct skcipher_ctx *ctx = ask->private; in skcipher_wait_for_data() local
262 if (sk_wait_event(sk, &timeout, ctx->used)) { in skcipher_wait_for_data()
277 struct skcipher_ctx *ctx = ask->private; in skcipher_data_wakeup() local
280 if (!ctx->used) in skcipher_data_wakeup()
300 struct skcipher_ctx *ctx = ask->private; in skcipher_sendmsg() local
336 if (!ctx->more && ctx->used) in skcipher_sendmsg()
340 ctx->enc = enc; in skcipher_sendmsg()
342 memcpy(ctx->iv, con.iv->iv, ivsize); in skcipher_sendmsg()
350 if (ctx->merge) { in skcipher_sendmsg()
351 sgl = list_entry(ctx->tsgl.prev, in skcipher_sendmsg()
364 ctx->merge = (sg->offset + sg->length) & in skcipher_sendmsg()
367 ctx->used += len; in skcipher_sendmsg()
385 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_sendmsg()
408 ctx->used += plen; in skcipher_sendmsg()
417 ctx->merge = plen & (PAGE_SIZE - 1); in skcipher_sendmsg()
422 ctx->more = msg->msg_flags & MSG_MORE; in skcipher_sendmsg()
436 struct skcipher_ctx *ctx = ask->private; in skcipher_sendpage() local
444 if (!ctx->more && ctx->used) in skcipher_sendpage()
460 ctx->merge = 0; in skcipher_sendpage()
461 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); in skcipher_sendpage()
470 ctx->used += size; in skcipher_sendpage()
473 ctx->more = flags & MSG_MORE; in skcipher_sendpage()
482 static int skcipher_all_sg_nents(struct skcipher_ctx *ctx) in skcipher_all_sg_nents() argument
488 list_for_each_entry(sgl, &ctx->tsgl, list) { in skcipher_all_sg_nents()
506 struct skcipher_ctx *ctx = ask->private; in skcipher_recvmsg_async() local
529 sreq->inflight = &ctx->inflight; in skcipher_recvmsg_async()
532 tx_nents = skcipher_all_sg_nents(ctx); in skcipher_recvmsg_async()
537 memcpy(iv, ctx->iv, ivsize); in skcipher_recvmsg_async()
546 if (!ctx->used) { in skcipher_recvmsg_async()
551 sgl = list_first_entry(&ctx->tsgl, in skcipher_recvmsg_async()
558 used = min_t(unsigned long, ctx->used, in skcipher_recvmsg_async()
617 err = ctx->enc ? crypto_skcipher_encrypt(req) : in skcipher_recvmsg_async()
620 atomic_inc(&ctx->inflight); in skcipher_recvmsg_async()
642 struct skcipher_ctx *ctx = ask->private; in skcipher_recvmsg_sync() local
654 if (!ctx->used) { in skcipher_recvmsg_sync()
660 used = min_t(unsigned long, ctx->used, msg_data_left(msg)); in skcipher_recvmsg_sync()
662 used = af_alg_make_sg(&ctx->rsgl, &msg->msg_iter, used); in skcipher_recvmsg_sync()
667 if (ctx->more || used < ctx->used) in skcipher_recvmsg_sync()
674 sgl = list_first_entry(&ctx->tsgl, in skcipher_recvmsg_sync()
681 skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used, in skcipher_recvmsg_sync()
682 ctx->iv); in skcipher_recvmsg_sync()
685 ctx->enc ? in skcipher_recvmsg_sync()
686 crypto_skcipher_encrypt(&ctx->req) : in skcipher_recvmsg_sync()
687 crypto_skcipher_decrypt(&ctx->req), in skcipher_recvmsg_sync()
688 &ctx->completion); in skcipher_recvmsg_sync()
691 af_alg_free_sg(&ctx->rsgl); in skcipher_recvmsg_sync()
723 struct skcipher_ctx *ctx = ask->private; in skcipher_poll() local
729 if (ctx->used) in skcipher_poll()
898 struct skcipher_ctx *ctx = ask->private; in skcipher_wait() local
901 while (atomic_read(&ctx->inflight) && ctr++ < 100) in skcipher_wait()
908 struct skcipher_ctx *ctx = ask->private; in skcipher_sock_destruct() local
909 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req); in skcipher_sock_destruct()
911 if (atomic_read(&ctx->inflight)) in skcipher_sock_destruct()
915 sock_kzfree_s(sk, ctx->iv, crypto_skcipher_ivsize(tfm)); in skcipher_sock_destruct()
916 sock_kfree_s(sk, ctx, ctx->len); in skcipher_sock_destruct()
922 struct skcipher_ctx *ctx; in skcipher_accept_parent_nokey() local
926 unsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(skcipher); in skcipher_accept_parent_nokey()
928 ctx = sock_kmalloc(sk, len, GFP_KERNEL); in skcipher_accept_parent_nokey()
929 if (!ctx) in skcipher_accept_parent_nokey()
932 ctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(skcipher), in skcipher_accept_parent_nokey()
934 if (!ctx->iv) { in skcipher_accept_parent_nokey()
935 sock_kfree_s(sk, ctx, len); in skcipher_accept_parent_nokey()
939 memset(ctx->iv, 0, crypto_skcipher_ivsize(skcipher)); in skcipher_accept_parent_nokey()
941 INIT_LIST_HEAD(&ctx->tsgl); in skcipher_accept_parent_nokey()
942 ctx->len = len; in skcipher_accept_parent_nokey()
943 ctx->used = 0; in skcipher_accept_parent_nokey()
944 ctx->more = 0; in skcipher_accept_parent_nokey()
945 ctx->merge = 0; in skcipher_accept_parent_nokey()
946 ctx->enc = 0; in skcipher_accept_parent_nokey()
947 atomic_set(&ctx->inflight, 0); in skcipher_accept_parent_nokey()
948 af_alg_init_completion(&ctx->completion); in skcipher_accept_parent_nokey()
950 ask->private = ctx; in skcipher_accept_parent_nokey()
952 skcipher_request_set_tfm(&ctx->req, skcipher); in skcipher_accept_parent_nokey()
953 skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_SLEEP | in skcipher_accept_parent_nokey()
955 af_alg_complete, &ctx->completion); in skcipher_accept_parent_nokey()