Lines Matching refs:ctx
51 struct chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in chainiv_givencrypt() local
64 spin_lock_bh(&ctx->lock); in chainiv_givencrypt()
68 memcpy(req->giv, ctx->iv, ivsize); in chainiv_givencrypt()
69 memcpy(subreq->info, ctx->iv, ivsize); in chainiv_givencrypt()
75 memcpy(ctx->iv, subreq->info, ivsize); in chainiv_givencrypt()
78 spin_unlock_bh(&ctx->lock); in chainiv_givencrypt()
86 struct chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in chainiv_givencrypt_first() local
89 spin_lock_bh(&ctx->lock); in chainiv_givencrypt_first()
95 err = crypto_rng_get_bytes(crypto_default_rng, ctx->iv, in chainiv_givencrypt_first()
99 spin_unlock_bh(&ctx->lock); in chainiv_givencrypt_first()
116 struct chainiv_ctx *ctx = crypto_tfm_ctx(tfm); in chainiv_init() local
118 spin_lock_init(&ctx->lock); in chainiv_init()
123 static int async_chainiv_schedule_work(struct async_chainiv_ctx *ctx) in async_chainiv_schedule_work() argument
126 int err = ctx->err; in async_chainiv_schedule_work()
128 if (!ctx->queue.qlen) { in async_chainiv_schedule_work()
130 clear_bit(CHAINIV_STATE_INUSE, &ctx->state); in async_chainiv_schedule_work()
132 if (!ctx->queue.qlen || in async_chainiv_schedule_work()
133 test_and_set_bit(CHAINIV_STATE_INUSE, &ctx->state)) in async_chainiv_schedule_work()
137 queued = queue_work(kcrypto_wq, &ctx->postponed); in async_chainiv_schedule_work()
147 struct async_chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in async_chainiv_postpone_request() local
150 spin_lock_bh(&ctx->lock); in async_chainiv_postpone_request()
151 err = skcipher_enqueue_givcrypt(&ctx->queue, req); in async_chainiv_postpone_request()
152 spin_unlock_bh(&ctx->lock); in async_chainiv_postpone_request()
154 if (test_and_set_bit(CHAINIV_STATE_INUSE, &ctx->state)) in async_chainiv_postpone_request()
157 ctx->err = err; in async_chainiv_postpone_request()
158 return async_chainiv_schedule_work(ctx); in async_chainiv_postpone_request()
164 struct async_chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in async_chainiv_givencrypt_tail() local
168 memcpy(req->giv, ctx->iv, ivsize); in async_chainiv_givencrypt_tail()
169 memcpy(subreq->info, ctx->iv, ivsize); in async_chainiv_givencrypt_tail()
171 ctx->err = crypto_ablkcipher_encrypt(subreq); in async_chainiv_givencrypt_tail()
172 if (ctx->err) in async_chainiv_givencrypt_tail()
175 memcpy(ctx->iv, subreq->info, ivsize); in async_chainiv_givencrypt_tail()
178 return async_chainiv_schedule_work(ctx); in async_chainiv_givencrypt_tail()
184 struct async_chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in async_chainiv_givencrypt() local
194 if (test_and_set_bit(CHAINIV_STATE_INUSE, &ctx->state)) in async_chainiv_givencrypt()
197 if (ctx->queue.qlen) { in async_chainiv_givencrypt()
198 clear_bit(CHAINIV_STATE_INUSE, &ctx->state); in async_chainiv_givencrypt()
211 struct async_chainiv_ctx *ctx = crypto_ablkcipher_ctx(geniv); in async_chainiv_givencrypt_first() local
214 if (test_and_set_bit(CHAINIV_STATE_INUSE, &ctx->state)) in async_chainiv_givencrypt_first()
222 err = crypto_rng_get_bytes(crypto_default_rng, ctx->iv, in async_chainiv_givencrypt_first()
226 clear_bit(CHAINIV_STATE_INUSE, &ctx->state); in async_chainiv_givencrypt_first()
237 struct async_chainiv_ctx *ctx = container_of(work, in async_chainiv_do_postponed() local
245 spin_lock_bh(&ctx->lock); in async_chainiv_do_postponed()
246 req = skcipher_dequeue_givcrypt(&ctx->queue); in async_chainiv_do_postponed()
247 spin_unlock_bh(&ctx->lock); in async_chainiv_do_postponed()
250 async_chainiv_schedule_work(ctx); in async_chainiv_do_postponed()
266 struct async_chainiv_ctx *ctx = crypto_tfm_ctx(tfm); in async_chainiv_init() local
268 spin_lock_init(&ctx->lock); in async_chainiv_init()
270 crypto_init_queue(&ctx->queue, 100); in async_chainiv_init()
271 INIT_WORK(&ctx->postponed, async_chainiv_do_postponed); in async_chainiv_init()
278 struct async_chainiv_ctx *ctx = crypto_tfm_ctx(tfm); in async_chainiv_exit() local
280 BUG_ON(test_bit(CHAINIV_STATE_INUSE, &ctx->state) || ctx->queue.qlen); in async_chainiv_exit()