• Home
  • Raw
  • Download

Lines Matching refs:ctx

21 static void dh_clear_ctx(struct dh_ctx *ctx)  in dh_clear_ctx()  argument
23 mpi_free(ctx->p); in dh_clear_ctx()
24 mpi_free(ctx->q); in dh_clear_ctx()
25 mpi_free(ctx->g); in dh_clear_ctx()
26 mpi_free(ctx->xa); in dh_clear_ctx()
27 memset(ctx, 0, sizeof(*ctx)); in dh_clear_ctx()
36 static int _compute_val(const struct dh_ctx *ctx, MPI base, MPI val) in _compute_val() argument
39 return mpi_powm(val, base, ctx->xa, ctx->p); in _compute_val()
52 static int dh_set_params(struct dh_ctx *ctx, struct dh *params) in dh_set_params() argument
57 ctx->p = mpi_read_raw_data(params->p, params->p_size); in dh_set_params()
58 if (!ctx->p) in dh_set_params()
62 ctx->q = mpi_read_raw_data(params->q, params->q_size); in dh_set_params()
63 if (!ctx->q) in dh_set_params()
67 ctx->g = mpi_read_raw_data(params->g, params->g_size); in dh_set_params()
68 if (!ctx->g) in dh_set_params()
77 struct dh_ctx *ctx = dh_get_ctx(tfm); in dh_set_secret() local
81 dh_clear_ctx(ctx); in dh_set_secret()
86 if (dh_set_params(ctx, &params) < 0) in dh_set_secret()
89 ctx->xa = mpi_read_raw_data(params.key, params.key_size); in dh_set_secret()
90 if (!ctx->xa) in dh_set_secret()
96 dh_clear_ctx(ctx); in dh_set_secret()
109 static int dh_is_pubkey_valid(struct dh_ctx *ctx, MPI y) in dh_is_pubkey_valid() argument
111 if (unlikely(!ctx->p)) in dh_is_pubkey_valid()
120 if (mpi_cmp_ui(y, 1) < 1 || mpi_cmp(y, ctx->p) >= 0) in dh_is_pubkey_valid()
124 if (ctx->q) { in dh_is_pubkey_valid()
131 ret = mpi_powm(val, y, ctx->q, ctx->p); in dh_is_pubkey_valid()
152 struct dh_ctx *ctx = dh_get_ctx(tfm); in dh_compute_value() local
160 if (unlikely(!ctx->xa)) { in dh_compute_value()
171 ret = dh_is_pubkey_valid(ctx, base); in dh_compute_value()
175 base = ctx->g; in dh_compute_value()
178 ret = _compute_val(ctx, base, val); in dh_compute_value()
198 struct dh_ctx *ctx = dh_get_ctx(tfm); in dh_max_size() local
200 return mpi_get_size(ctx->p); in dh_max_size()
205 struct dh_ctx *ctx = dh_get_ctx(tfm); in dh_exit_tfm() local
207 dh_clear_ctx(ctx); in dh_exit_tfm()