summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec2_mult.c
diff options
context:
space:
mode:
authordjm <>2011-11-03 02:32:23 +0000
committerdjm <>2011-11-03 02:32:23 +0000
commit113f799ec7d1728f0a5d7ab5b0e3b42e3de56407 (patch)
tree26d712b25a8fa580b8f2dfc6df470ba5ffea9eb7 /src/lib/libcrypto/ec/ec2_mult.c
parent829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (diff)
downloadopenbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.gz
openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.bz2
openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.zip
import OpenSSL 1.0.0e
Diffstat (limited to 'src/lib/libcrypto/ec/ec2_mult.c')
-rw-r--r--src/lib/libcrypto/ec/ec2_mult.c13
1 files changed, 9 insertions, 4 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;