diff options
| author | djm <> | 2011-11-03 02:32:23 +0000 |
|---|---|---|
| committer | djm <> | 2011-11-03 02:32:23 +0000 |
| commit | 113f799ec7d1728f0a5d7ab5b0e3b42e3de56407 (patch) | |
| tree | 26d712b25a8fa580b8f2dfc6df470ba5ffea9eb7 /src/lib/libcrypto/ec | |
| parent | 829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (diff) | |
| download | openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.gz openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.bz2 openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.zip | |
import OpenSSL 1.0.0e
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/ec2_smpl.c | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 3 |
5 files changed, 26 insertions, 7 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/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index cf357b462a..af94458ca7 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
| @@ -937,6 +937,9 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT | |||
| 937 | { | 937 | { |
| 938 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 938 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; |
| 939 | } | 939 | } |
| 940 | |||
| 941 | if (EC_POINT_is_at_infinity(group, b)) | ||
| 942 | return 1; | ||
| 940 | 943 | ||
| 941 | if (a->Z_is_one && b->Z_is_one) | 944 | if (a->Z_is_one && b->Z_is_one) |
| 942 | { | 945 | { |
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) |
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index f05df5332e..19f21675fb 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
| @@ -169,11 +169,13 @@ static void ec_pre_comp_clear_free(void *pre_) | |||
| 169 | EC_POINT **p; | 169 | EC_POINT **p; |
| 170 | 170 | ||
| 171 | for (p = pre->points; *p != NULL; p++) | 171 | for (p = pre->points; *p != NULL; p++) |
| 172 | { | ||
| 172 | EC_POINT_clear_free(*p); | 173 | EC_POINT_clear_free(*p); |
| 173 | OPENSSL_cleanse(pre->points, sizeof pre->points); | 174 | OPENSSL_cleanse(p, sizeof *p); |
| 175 | } | ||
| 174 | OPENSSL_free(pre->points); | 176 | OPENSSL_free(pre->points); |
| 175 | } | 177 | } |
| 176 | OPENSSL_cleanse(pre, sizeof pre); | 178 | OPENSSL_cleanse(pre, sizeof *pre); |
| 177 | OPENSSL_free(pre); | 179 | OPENSSL_free(pre); |
| 178 | } | 180 | } |
| 179 | 181 | ||
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 4d26f8bdf6..66a92e2a90 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
| @@ -1406,6 +1406,9 @@ int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT * | |||
| 1406 | { | 1406 | { |
| 1407 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 1407 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; |
| 1408 | } | 1408 | } |
| 1409 | |||
| 1410 | if (EC_POINT_is_at_infinity(group, b)) | ||
| 1411 | return 1; | ||
| 1409 | 1412 | ||
| 1410 | if (a->Z_is_one && b->Z_is_one) | 1413 | if (a->Z_is_one && b->Z_is_one) |
| 1411 | { | 1414 | { |
