X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=src%2Fec%2Fecdsa_i31_sign_raw.c;h=1df98fed2314442546774a90ff357020df41ecc0;hp=38495458cd632415208807ebae9e6d2e67c40785;hb=d021b7eb7fada2acbe16b1b56f6e2cbdf8eee362;hpb=3210f38e0491b39aec1ef419cb4114e9483089fb diff --git a/src/ec/ecdsa_i31_sign_raw.c b/src/ec/ecdsa_i31_sign_raw.c index 3849545..1df98fe 100644 --- a/src/ec/ecdsa_i31_sign_raw.c +++ b/src/ec/ecdsa_i31_sign_raw.c @@ -50,6 +50,13 @@ br_ecdsa_i31_sign_raw(const br_ec_impl *impl, uint32_t n0i, ctl; br_hmac_drbg_context drbg; + /* + * If the curve is not supported, then exit with an error. + */ + if (((impl->supported_curves >> sk->curve) & 1) == 0) { + return 0; + } + /* * Get the curve parameters (generator and order). */ @@ -125,18 +132,8 @@ br_ecdsa_i31_sign_raw(const br_ec_impl *impl, * prime order, that reduction is only a matter of computing * a subtraction. */ - ulen = cd->generator_len; - memcpy(eU, cd->generator, ulen); br_i31_encode(tt, nlen, k); - if (!impl->mul(eU, ulen, tt, nlen, sk->curve)) { - /* - * Point multiplication may fail here only if the - * EC implementation does not support the curve, or the - * private key is incorrect (x is a multiple of the curve - * order). - */ - return 0; - } + ulen = impl->mulgen(eU, tt, nlen, sk->curve); br_i31_zero(r, n[0]); br_i31_decode(r, &eU[1], ulen >> 1); r[0] = n[0];