Lines Matching refs:ctx
43 static inline int starfive_pka_wait_done(struct starfive_cryp_ctx *ctx)
45 struct starfive_cryp_dev *cryp = ctx->cryp;
51 static inline void starfive_pka_irq_mask_clear(struct starfive_cryp_ctx *ctx)
53 struct starfive_cryp_dev *cryp = ctx->cryp;
88 static int starfive_rsa_montgomery_form(struct starfive_cryp_ctx *ctx,
92 struct starfive_cryp_dev *cryp = ctx->cryp;
93 struct starfive_cryp_request_ctx *rctx = ctx->rctx;
117 starfive_pka_irq_mask_clear(ctx);
120 if (!starfive_pka_wait_done(ctx))
139 starfive_pka_irq_mask_clear(ctx);
142 if (!starfive_pka_wait_done(ctx))
154 starfive_pka_irq_mask_clear(ctx);
157 if (!starfive_pka_wait_done(ctx))
175 starfive_pka_irq_mask_clear(ctx);
178 if (!starfive_pka_wait_done(ctx))
190 static int starfive_rsa_cpu_start(struct starfive_cryp_ctx *ctx, u32 *result,
193 struct starfive_cryp_dev *cryp = ctx->cryp;
194 struct starfive_cryp_request_ctx *rctx = ctx->rctx;
195 struct starfive_rsa_key *key = &ctx->rsa_key;
207 ret = starfive_rsa_montgomery_form(ctx, mta, (u32 *)rctx->rsa_data,
229 starfive_pka_irq_mask_clear(ctx);
233 if (!starfive_pka_wait_done(ctx))
245 starfive_pka_irq_mask_clear(ctx);
248 if (!starfive_pka_wait_done(ctx))
258 ret = starfive_rsa_montgomery_form(ctx, result, result, 1, n, key_sz << 3);
266 static int starfive_rsa_start(struct starfive_cryp_ctx *ctx, u8 *result,
269 return starfive_rsa_cpu_start(ctx, (u32 *)result, de, (u32 *)n, key_sz);
272 static int starfive_rsa_enc_core(struct starfive_cryp_ctx *ctx, int enc)
274 struct starfive_cryp_dev *cryp = ctx->cryp;
275 struct starfive_cryp_request_ctx *rctx = ctx->rctx;
276 struct starfive_rsa_key *key = &ctx->rsa_key;
286 ret = starfive_rsa_start(ctx, rctx->rsa_data, key->e,
290 ret = starfive_rsa_start(ctx, rctx->rsa_data, key->d,
309 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
310 struct starfive_cryp_dev *cryp = ctx->cryp;
311 struct starfive_rsa_key *key = &ctx->rsa_key;
316 akcipher_request_set_tfm(req, ctx->akcipher_fbk);
333 ctx->rctx = rctx;
335 return starfive_rsa_enc_core(ctx, 1);
341 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
342 struct starfive_cryp_dev *cryp = ctx->cryp;
343 struct starfive_rsa_key *key = &ctx->rsa_key;
348 akcipher_request_set_tfm(req, ctx->akcipher_fbk);
363 ctx->rctx = rctx;
366 return starfive_rsa_enc_core(ctx, 0);
475 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
477 struct starfive_rsa_key *rsa_key = &ctx->rsa_key;
526 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
529 ret = crypto_akcipher_set_pub_key(ctx->akcipher_fbk, key, keylen);
539 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
542 ret = crypto_akcipher_set_priv_key(ctx->akcipher_fbk, key, keylen);
551 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
553 if (ctx->rsa_key.key_sz)
554 return ctx->rsa_key.key_sz;
556 return crypto_akcipher_maxsize(ctx->akcipher_fbk);
561 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
563 ctx->akcipher_fbk = crypto_alloc_akcipher("rsa-generic", 0, 0);
564 if (IS_ERR(ctx->akcipher_fbk))
565 return PTR_ERR(ctx->akcipher_fbk);
567 ctx->cryp = starfive_cryp_find_dev(ctx);
568 if (!ctx->cryp) {
569 crypto_free_akcipher(ctx->akcipher_fbk);
581 struct starfive_cryp_ctx *ctx = akcipher_tfm_ctx(tfm);
582 struct starfive_rsa_key *key = (struct starfive_rsa_key *)&ctx->rsa_key;
584 crypto_free_akcipher(ctx->akcipher_fbk);