diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_key.c')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 3d6c900b95..12fb0e6d6d 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
| @@ -296,7 +296,7 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 296 | { | 296 | { |
| 297 | int ok = 0; | 297 | int ok = 0; |
| 298 | BN_CTX *ctx = NULL; | 298 | BN_CTX *ctx = NULL; |
| 299 | BIGNUM *order = NULL; | 299 | const BIGNUM *order = NULL; |
| 300 | EC_POINT *point = NULL; | 300 | EC_POINT *point = NULL; |
| 301 | 301 | ||
| 302 | if (!eckey || !eckey->group || !eckey->pub_key) | 302 | if (!eckey || !eckey->group || !eckey->pub_key) |
| @@ -307,8 +307,6 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 307 | 307 | ||
| 308 | if ((ctx = BN_CTX_new()) == NULL) | 308 | if ((ctx = BN_CTX_new()) == NULL) |
| 309 | goto err; | 309 | goto err; |
| 310 | if ((order = BN_new()) == NULL) | ||
| 311 | goto err; | ||
| 312 | if ((point = EC_POINT_new(eckey->group)) == NULL) | 310 | if ((point = EC_POINT_new(eckey->group)) == NULL) |
| 313 | goto err; | 311 | goto err; |
| 314 | 312 | ||
| @@ -319,17 +317,13 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 319 | goto err; | 317 | goto err; |
| 320 | } | 318 | } |
| 321 | /* testing whether pub_key * order is the point at infinity */ | 319 | /* testing whether pub_key * order is the point at infinity */ |
| 322 | if (!EC_GROUP_get_order(eckey->group, order, ctx)) | 320 | order = &eckey->group->order; |
| 321 | if (BN_is_zero(order)) | ||
| 323 | { | 322 | { |
| 324 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); | 323 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); |
| 325 | goto err; | 324 | goto err; |
| 326 | } | 325 | } |
| 327 | if (!EC_POINT_copy(point, eckey->pub_key)) | 326 | if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) |
| 328 | { | ||
| 329 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); | ||
| 330 | goto err; | ||
| 331 | } | ||
| 332 | if (!EC_POINT_mul(eckey->group, point, order, NULL, NULL, ctx)) | ||
| 333 | { | 327 | { |
| 334 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); | 328 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); |
| 335 | goto err; | 329 | goto err; |
| @@ -366,8 +360,6 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
| 366 | err: | 360 | err: |
| 367 | if (ctx != NULL) | 361 | if (ctx != NULL) |
| 368 | BN_CTX_free(ctx); | 362 | BN_CTX_free(ctx); |
| 369 | if (order != NULL) | ||
| 370 | BN_free(order); | ||
| 371 | if (point != NULL) | 363 | if (point != NULL) |
| 372 | EC_POINT_free(point); | 364 | EC_POINT_free(point); |
| 373 | return(ok); | 365 | return(ok); |
