Home | History | Annotate | Download | only in ec

Lines Matching refs:ctx

84 static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx)
89 /* Since Mdouble is static we can guarantee that ctx != NULL. */
90 BN_CTX_start(ctx);
91 t1 = BN_CTX_get(ctx);
94 if (!group->meth->field_sqr(group, x, x, ctx)) goto err;
95 if (!group->meth->field_sqr(group, t1, z, ctx)) goto err;
96 if (!group->meth->field_mul(group, z, x, t1, ctx)) goto err;
97 if (!group->meth->field_sqr(group, x, x, ctx)) goto err;
98 if (!group->meth->field_sqr(group, t1, t1, ctx)) goto err;
99 if (!group->meth->field_mul(group, t1, &group->b, t1, ctx)) goto err;
105 BN_CTX_end(ctx);
116 const BIGNUM *x2, const BIGNUM *z2, BN_CTX *ctx)
121 /* Since Madd is static we can guarantee that ctx != NULL. */
122 BN_CTX_start(ctx);
123 t1 = BN_CTX_get(ctx);
124 t2 = BN_CTX_get(ctx);
128 if (!group->meth->field_mul(group, x1, x1, z2, ctx)) goto err;
129 if (!group->meth->field_mul(group, z1, z1, x2, ctx)) goto err;
130 if (!group->meth->field_mul(group, t2, x1, z1, ctx)) goto err;
132 if (!group->meth->field_sqr(group, z1, z1, ctx)) goto err;
133 if (!group->meth->field_mul(group, x1, z1, t1, ctx)) goto err;
139 BN_CTX_end(ctx);
153 BIGNUM *z1, BIGNUM *x2, BIGNUM *z2, BN_CTX *ctx)
172 /* Since Mxy is static we can guarantee that ctx != NULL. */
173 BN_CTX_start(ctx);
174 t3 = BN_CTX_get(ctx);
175 t4 = BN_CTX_get(ctx);
176 t5 = BN_CTX_get(ctx);
181 if (!group->meth->field_mul(group, t3, z1, z2, ctx)) goto err;
183 if (!group->meth->field_mul(group, z1, z1, x, ctx)) goto err;
185 if (!group->meth->field_mul(group, z2, z2, x, ctx)) goto err;
186 if (!group->meth->field_mul(group, x1, z2, x1, ctx)) goto err;
189 if (!group->meth->field_mul(group, z2, z2, z1, ctx)) goto err;
190 if (!group->meth->field_sqr(group, t4, x, ctx)) goto err;
192 if (!group->meth->field_mul(group, t4, t4, t3, ctx)) goto err;
195 if (!group->meth->field_mul(group, t3, t3, x, ctx)) goto err;
196 if (!group->meth->field_div(group, t3, t5, t3, ctx)) goto err;
197 if (!group->meth->field_mul(group, t4, t3, t4, ctx)) goto err;
198 if (!group->meth->field_mul(group, x2, x1, t3, ctx)) goto err;
201 if (!group->meth->field_mul(group, z2, z2, t4, ctx)) goto err;
207 BN_CTX_end(ctx);
218 const EC_POINT *point, BN_CTX *ctx)
240 /* Since point_multiply is static we can guarantee that ctx != NULL. */
241 BN_CTX_start(ctx);
242 x1 = BN_CTX_get(ctx);
243 z1 = BN_CTX_get(ctx);
251 if (!group->meth->field_sqr(group, z2, x1, ctx)) goto err; /* z2 = x1^2 = x^2 */
252 if (!group->meth->field_sqr(group, x2, z2, ctx)) goto err;
275 if (!gf2m_Madd(group, &point->X, x1, z1, x2, z2, ctx)) goto err;
276 if (!gf2m_Mdouble(group, x2, z2, ctx)) goto err;
280 if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err;
281 if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err;
289 i = gf2m_Mxy(group, &point->X, &point->Y, x1, z1, x2, z2, ctx);
308 BN_CTX_end(ctx);
318 size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
326 if (ctx == NULL)
328 ctx = new_ctx = BN_CTX_new();
329 if (ctx == NULL)
339 ret = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);
350 if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err;
352 if (!group->meth->invert(group, p, ctx)) goto err;
353 if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
358 if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err;
360 if (!group->meth->invert(group, p, ctx)) goto err;
361 if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
380 int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
382 return ec_wNAF_precompute_mult(group, ctx);