Lines Matching refs:ctx
74 struct ecrdsa_ctx *ctx = crypto_sig_ctx(tfm); in ecrdsa_verify() local
90 if (!ctx->curve || in ecrdsa_verify()
91 !ctx->digest || in ecrdsa_verify()
94 !ctx->pub_key.x || in ecrdsa_verify()
95 dlen != ctx->digest_len || in ecrdsa_verify()
96 dlen != ctx->curve->g.ndigits * sizeof(u64) || in ecrdsa_verify()
97 ctx->pub_key.ndigits != ctx->curve->g.ndigits || in ecrdsa_verify()
108 vli_cmp(r, ctx->curve->n, ndigits) >= 0 || in ecrdsa_verify()
110 vli_cmp(s, ctx->curve->n, ndigits) >= 0) in ecrdsa_verify()
116 if (vli_cmp(e, ctx->curve->n, ndigits) >= 0) in ecrdsa_verify()
117 vli_sub(e, e, ctx->curve->n, ndigits); in ecrdsa_verify()
122 vli_mod_inv(v, e, ctx->curve->n, ndigits); in ecrdsa_verify()
125 vli_mod_mult_slow(z1, s, v, ctx->curve->n, ndigits); in ecrdsa_verify()
126 vli_sub(_r, ctx->curve->n, r, ndigits); in ecrdsa_verify()
127 vli_mod_mult_slow(z2, _r, v, ctx->curve->n, ndigits); in ecrdsa_verify()
130 ecc_point_mult_shamir(&cc, z1, &ctx->curve->g, z2, &ctx->pub_key, in ecrdsa_verify()
131 ctx->curve); in ecrdsa_verify()
132 if (vli_cmp(cc.x, ctx->curve->n, ndigits) >= 0) in ecrdsa_verify()
133 vli_sub(cc.x, cc.x, ctx->curve->n, ndigits); in ecrdsa_verify()
145 struct ecrdsa_ctx *ctx = context; in ecrdsa_param_curve() local
147 ctx->curve_oid = look_up_OID(value, vlen); in ecrdsa_param_curve()
148 if (!ctx->curve_oid) in ecrdsa_param_curve()
150 ctx->curve = get_curve_by_oid(ctx->curve_oid); in ecrdsa_param_curve()
158 struct ecrdsa_ctx *ctx = context; in ecrdsa_param_digest() local
161 if (digest_oid != ctx->digest_oid) in ecrdsa_param_digest()
169 struct ecrdsa_ctx *ctx = context; in ecrdsa_parse_pub_key() local
171 ctx->key = value; in ecrdsa_parse_pub_key()
172 ctx->key_len = vlen; in ecrdsa_parse_pub_key()
186 struct ecrdsa_ctx *ctx = crypto_sig_ctx(tfm); in ecrdsa_set_pub_key() local
192 err = asn1_ber_decoder(&ecrdsa_pub_key_decoder, ctx, key, keylen); in ecrdsa_set_pub_key()
201 ctx->digest = "streebog256"; in ecrdsa_set_pub_key()
202 ctx->digest_oid = OID_gost2012Digest256; in ecrdsa_set_pub_key()
203 ctx->digest_len = 256 / 8; in ecrdsa_set_pub_key()
205 ctx->digest = "streebog512"; in ecrdsa_set_pub_key()
206 ctx->digest_oid = OID_gost2012Digest512; in ecrdsa_set_pub_key()
207 ctx->digest_len = 512 / 8; in ecrdsa_set_pub_key()
210 ctx->algo_oid = algo; in ecrdsa_set_pub_key()
213 err = asn1_ber_decoder(&ecrdsa_params_decoder, ctx, params, paramlen); in ecrdsa_set_pub_key()
220 if (!ctx->curve || in ecrdsa_set_pub_key()
221 ctx->curve->g.ndigits * sizeof(u64) != ctx->digest_len) in ecrdsa_set_pub_key()
227 if ((ctx->key_len != (2 * 256 / 8) && in ecrdsa_set_pub_key()
228 ctx->key_len != (2 * 512 / 8)) || in ecrdsa_set_pub_key()
229 ctx->key_len != ctx->curve->g.ndigits * sizeof(u64) * 2) in ecrdsa_set_pub_key()
232 ndigits = ctx->key_len / sizeof(u64) / 2; in ecrdsa_set_pub_key()
233 ctx->pub_key = ECC_POINT_INIT(ctx->_pubp[0], ctx->_pubp[1], ndigits); in ecrdsa_set_pub_key()
234 vli_from_le64(ctx->pub_key.x, ctx->key, ndigits); in ecrdsa_set_pub_key()
235 vli_from_le64(ctx->pub_key.y, ctx->key + ndigits * sizeof(u64), in ecrdsa_set_pub_key()
238 if (ecc_is_pubkey_valid_partial(ctx->curve, &ctx->pub_key)) in ecrdsa_set_pub_key()
246 struct ecrdsa_ctx *ctx = crypto_sig_ctx(tfm); in ecrdsa_key_size() local
252 return ctx->pub_key.ndigits * sizeof(u64) * BITS_PER_BYTE; in ecrdsa_key_size()
257 struct ecrdsa_ctx *ctx = crypto_sig_ctx(tfm); in ecrdsa_max_size() local
259 return 2 * ctx->pub_key.ndigits * sizeof(u64); in ecrdsa_max_size()