Lines Matching refs:ctx

23 static int _ecdsa_verify(struct ecc_ctx *ctx, const u64 *hash, const u64 *r, const u64 *s)  in _ecdsa_verify()  argument
25 const struct ecc_curve *curve = ctx->curve; in _ecdsa_verify()
50 ecc_point_mult_shamir(&res, u1, &curve->g, u2, &ctx->pub_key, curve); in _ecdsa_verify()
70 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_verify() local
71 size_t bufsize = ctx->curve->g.ndigits * sizeof(u64); in ecdsa_verify()
75 if (unlikely(!ctx->pub_key_set)) in ecdsa_verify()
84 ecc_digits_from_bytes(digest, bufsize, hash, ctx->curve->g.ndigits); in ecdsa_verify()
86 return _ecdsa_verify(ctx, hash, sig->r, sig->s); in ecdsa_verify()
89 static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id) in ecdsa_ecc_ctx_init() argument
91 ctx->curve_id = curve_id; in ecdsa_ecc_ctx_init()
92 ctx->curve = ecc_get_curve(curve_id); in ecdsa_ecc_ctx_init()
93 if (!ctx->curve) in ecdsa_ecc_ctx_init()
100 static void ecdsa_ecc_ctx_deinit(struct ecc_ctx *ctx) in ecdsa_ecc_ctx_deinit() argument
102 ctx->pub_key_set = false; in ecdsa_ecc_ctx_deinit()
105 static int ecdsa_ecc_ctx_reset(struct ecc_ctx *ctx) in ecdsa_ecc_ctx_reset() argument
107 unsigned int curve_id = ctx->curve_id; in ecdsa_ecc_ctx_reset()
110 ecdsa_ecc_ctx_deinit(ctx); in ecdsa_ecc_ctx_reset()
111 ret = ecdsa_ecc_ctx_init(ctx, curve_id); in ecdsa_ecc_ctx_reset()
113 ctx->pub_key = ECC_POINT_INIT(ctx->x, ctx->y, in ecdsa_ecc_ctx_reset()
114 ctx->curve->g.ndigits); in ecdsa_ecc_ctx_reset()
125 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_set_pub_key() local
130 ret = ecdsa_ecc_ctx_reset(ctx); in ecdsa_set_pub_key()
144 if (ndigits != ctx->curve->g.ndigits) in ecdsa_set_pub_key()
149 ecc_digits_from_bytes(d, digitlen, ctx->pub_key.x, ndigits); in ecdsa_set_pub_key()
150 ecc_digits_from_bytes(&d[digitlen], digitlen, ctx->pub_key.y, ndigits); in ecdsa_set_pub_key()
152 ret = ecc_is_pubkey_valid_full(ctx->curve, &ctx->pub_key); in ecdsa_set_pub_key()
154 ctx->pub_key_set = ret == 0; in ecdsa_set_pub_key()
161 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_exit_tfm() local
163 ecdsa_ecc_ctx_deinit(ctx); in ecdsa_exit_tfm()
168 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_key_size() local
170 return ctx->curve->nbits; in ecdsa_key_size()
186 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_nist_p521_init_tfm() local
188 return ecdsa_ecc_ctx_init(ctx, ECC_CURVE_NIST_P521); in ecdsa_nist_p521_init_tfm()
209 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_nist_p384_init_tfm() local
211 return ecdsa_ecc_ctx_init(ctx, ECC_CURVE_NIST_P384); in ecdsa_nist_p384_init_tfm()
232 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_nist_p256_init_tfm() local
234 return ecdsa_ecc_ctx_init(ctx, ECC_CURVE_NIST_P256); in ecdsa_nist_p256_init_tfm()
255 struct ecc_ctx *ctx = crypto_sig_ctx(tfm); in ecdsa_nist_p192_init_tfm() local
257 return ecdsa_ecc_ctx_init(ctx, ECC_CURVE_NIST_P192); in ecdsa_nist_p192_init_tfm()