Lines Matching refs:ctx
150 struct bpf_crypto_ctx *ctx; in bpf_crypto_ctx_create() local
179 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in bpf_crypto_ctx_create()
180 if (!ctx) { in bpf_crypto_ctx_create()
185 ctx->type = type; in bpf_crypto_ctx_create()
186 ctx->tfm = type->alloc_tfm(params->algo); in bpf_crypto_ctx_create()
187 if (IS_ERR(ctx->tfm)) { in bpf_crypto_ctx_create()
188 *err = PTR_ERR(ctx->tfm); in bpf_crypto_ctx_create()
193 *err = type->setauthsize(ctx->tfm, params->authsize); in bpf_crypto_ctx_create()
198 *err = type->setkey(ctx->tfm, params->key, params->key_len); in bpf_crypto_ctx_create()
202 if (type->get_flags(ctx->tfm) & CRYPTO_TFM_NEED_KEY) { in bpf_crypto_ctx_create()
207 ctx->siv_len = type->ivsize(ctx->tfm) + type->statesize(ctx->tfm); in bpf_crypto_ctx_create()
209 refcount_set(&ctx->usage, 1); in bpf_crypto_ctx_create()
211 return ctx; in bpf_crypto_ctx_create()
214 type->free_tfm(ctx->tfm); in bpf_crypto_ctx_create()
216 kfree(ctx); in bpf_crypto_ctx_create()
225 struct bpf_crypto_ctx *ctx; in crypto_free_cb() local
227 ctx = container_of(head, struct bpf_crypto_ctx, rcu); in crypto_free_cb()
228 ctx->type->free_tfm(ctx->tfm); in crypto_free_cb()
229 module_put(ctx->type->owner); in crypto_free_cb()
230 kfree(ctx); in crypto_free_cb()
243 bpf_crypto_ctx_acquire(struct bpf_crypto_ctx *ctx) in bpf_crypto_ctx_acquire() argument
245 if (!refcount_inc_not_zero(&ctx->usage)) in bpf_crypto_ctx_acquire()
247 return ctx; in bpf_crypto_ctx_acquire()
258 __bpf_kfunc void bpf_crypto_ctx_release(struct bpf_crypto_ctx *ctx) in bpf_crypto_ctx_release() argument
260 if (refcount_dec_and_test(&ctx->usage)) in bpf_crypto_ctx_release()
261 call_rcu(&ctx->rcu, crypto_free_cb); in bpf_crypto_ctx_release()
264 static int bpf_crypto_crypt(const struct bpf_crypto_ctx *ctx, in bpf_crypto_crypt() argument
284 if (siv_len != ctx->siv_len) in bpf_crypto_crypt()
298 err = decrypt ? ctx->type->decrypt(ctx->tfm, psrc, pdst, src_len, piv) in bpf_crypto_crypt()
299 : ctx->type->encrypt(ctx->tfm, psrc, pdst, src_len, piv); in bpf_crypto_crypt()
313 __bpf_kfunc int bpf_crypto_decrypt(struct bpf_crypto_ctx *ctx, in bpf_crypto_decrypt() argument
322 return bpf_crypto_crypt(ctx, src_kern, dst_kern, siv_kern, true); in bpf_crypto_decrypt()
334 __bpf_kfunc int bpf_crypto_encrypt(struct bpf_crypto_ctx *ctx, in bpf_crypto_encrypt() argument
343 return bpf_crypto_crypt(ctx, src_kern, dst_kern, siv_kern, false); in bpf_crypto_encrypt()