diff options
Diffstat (limited to 'src/lib/libcrypto/ec')
-rw-r--r-- | src/lib/libcrypto/ec/ec2_mult.c | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 8 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c index ab631a50a2..e12b9b284a 100644 --- a/src/lib/libcrypto/ec/ec2_mult.c +++ b/src/lib/libcrypto/ec/ec2_mult.c | |||
@@ -319,6 +319,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
319 | int ret = 0; | 319 | int ret = 0; |
320 | size_t i; | 320 | size_t i; |
321 | EC_POINT *p=NULL; | 321 | EC_POINT *p=NULL; |
322 | EC_POINT *acc = NULL; | ||
322 | 323 | ||
323 | if (ctx == NULL) | 324 | if (ctx == NULL) |
324 | { | 325 | { |
@@ -338,15 +339,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
338 | } | 339 | } |
339 | 340 | ||
340 | if ((p = EC_POINT_new(group)) == NULL) goto err; | 341 | if ((p = EC_POINT_new(group)) == NULL) goto err; |
342 | if ((acc = EC_POINT_new(group)) == NULL) goto err; | ||
341 | 343 | ||
342 | if (!EC_POINT_set_to_infinity(group, r)) goto err; | 344 | if (!EC_POINT_set_to_infinity(group, acc)) goto err; |
343 | 345 | ||
344 | if (scalar) | 346 | if (scalar) |
345 | { | 347 | { |
346 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; | 348 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; |
347 | if (BN_is_negative(scalar)) | 349 | if (BN_is_negative(scalar)) |
348 | if (!group->meth->invert(group, p, ctx)) goto err; | 350 | if (!group->meth->invert(group, p, ctx)) goto err; |
349 | if (!group->meth->add(group, r, r, p, ctx)) goto err; | 351 | if (!group->meth->add(group, acc, acc, p, ctx)) goto err; |
350 | } | 352 | } |
351 | 353 | ||
352 | for (i = 0; i < num; i++) | 354 | for (i = 0; i < num; i++) |
@@ -354,13 +356,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
354 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; | 356 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; |
355 | if (BN_is_negative(scalars[i])) | 357 | if (BN_is_negative(scalars[i])) |
356 | if (!group->meth->invert(group, p, ctx)) goto err; | 358 | if (!group->meth->invert(group, p, ctx)) goto err; |
357 | if (!group->meth->add(group, r, r, p, ctx)) goto err; | 359 | if (!group->meth->add(group, acc, acc, p, ctx)) goto err; |
358 | } | 360 | } |
359 | 361 | ||
362 | if (!EC_POINT_copy(r, acc)) goto err; | ||
363 | |||
360 | ret = 1; | 364 | ret = 1; |
361 | 365 | ||
362 | err: | 366 | err: |
363 | if (p) EC_POINT_free(p); | 367 | if (p) EC_POINT_free(p); |
368 | if (acc) EC_POINT_free(acc); | ||
364 | if (new_ctx != NULL) | 369 | if (new_ctx != NULL) |
365 | BN_CTX_free(new_ctx); | 370 | BN_CTX_free(new_ctx); |
366 | return ret; | 371 | return ret; |
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 12fb0e6d6d..522802c07a 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
@@ -304,7 +304,13 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
304 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); | 304 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); |
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) | ||
309 | { | ||
310 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); | ||
311 | goto err; | ||
312 | } | ||
313 | |||
308 | if ((ctx = BN_CTX_new()) == NULL) | 314 | if ((ctx = BN_CTX_new()) == NULL) |
309 | goto err; | 315 | goto err; |
310 | if ((point = EC_POINT_new(eckey->group)) == NULL) | 316 | if ((point = EC_POINT_new(eckey->group)) == NULL) |