diff options
| author | tb <> | 2021-04-20 17:23:37 +0000 |
|---|---|---|
| committer | tb <> | 2021-04-20 17:23:37 +0000 |
| commit | b567b8b60d2a8021e06cc33d2fee8b1cf180eac5 (patch) | |
| tree | 2d01b94789dd9feb10bf48a12e3b8d831acb2076 /src/lib/libcrypto/ec | |
| parent | 0b9d2ddee375142a5100f30f23c6869070bcaedd (diff) | |
| download | openbsd-b567b8b60d2a8021e06cc33d2fee8b1cf180eac5.tar.gz openbsd-b567b8b60d2a8021e06cc33d2fee8b1cf180eac5.tar.bz2 openbsd-b567b8b60d2a8021e06cc33d2fee8b1cf180eac5.zip | |
Simplify code after adding EC_POINT_{s,g}et_affine_coordinates()
ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 348156e680..27b8f26608 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_key.c,v 1.25 2021/04/20 17:16:37 tb Exp $ */ | 1 | /* $OpenBSD: ec_key.c,v 1.26 2021/04/20 17:23:37 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -381,7 +381,7 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) | |||
| 381 | BN_CTX *ctx = NULL; | 381 | BN_CTX *ctx = NULL; |
| 382 | BIGNUM *tx, *ty; | 382 | BIGNUM *tx, *ty; |
| 383 | EC_POINT *point = NULL; | 383 | EC_POINT *point = NULL; |
| 384 | int ok = 0, tmp_nid, is_char_two = 0; | 384 | int ok = 0; |
| 385 | 385 | ||
| 386 | if (!key || !key->group || !x || !y) { | 386 | if (!key || !key->group || !x || !y) { |
| 387 | ECerror(ERR_R_PASSED_NULL_PARAMETER); | 387 | ECerror(ERR_R_PASSED_NULL_PARAMETER); |
| @@ -396,34 +396,15 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) | |||
| 396 | if (!point) | 396 | if (!point) |
| 397 | goto err; | 397 | goto err; |
| 398 | 398 | ||
| 399 | tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group)); | ||
| 400 | |||
| 401 | if (tmp_nid == NID_X9_62_characteristic_two_field) | ||
| 402 | is_char_two = 1; | ||
| 403 | |||
| 404 | if ((tx = BN_CTX_get(ctx)) == NULL) | 399 | if ((tx = BN_CTX_get(ctx)) == NULL) |
| 405 | goto err; | 400 | goto err; |
| 406 | if ((ty = BN_CTX_get(ctx)) == NULL) | 401 | if ((ty = BN_CTX_get(ctx)) == NULL) |
| 407 | goto err; | 402 | goto err; |
| 408 | 403 | ||
| 409 | #ifndef OPENSSL_NO_EC2M | 404 | if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx)) |
| 410 | if (is_char_two) { | 405 | goto err; |
| 411 | if (!EC_POINT_set_affine_coordinates(key->group, point, | 406 | if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx)) |
| 412 | x, y, ctx)) | 407 | goto err; |
| 413 | goto err; | ||
| 414 | if (!EC_POINT_get_affine_coordinates(key->group, point, | ||
| 415 | tx, ty, ctx)) | ||
| 416 | goto err; | ||
| 417 | } else | ||
| 418 | #endif | ||
| 419 | { | ||
| 420 | if (!EC_POINT_set_affine_coordinates(key->group, point, | ||
| 421 | x, y, ctx)) | ||
| 422 | goto err; | ||
| 423 | if (!EC_POINT_get_affine_coordinates(key->group, point, | ||
| 424 | tx, ty, ctx)) | ||
| 425 | goto err; | ||
| 426 | } | ||
| 427 | /* | 408 | /* |
| 428 | * Check if retrieved coordinates match originals: if not values are | 409 | * Check if retrieved coordinates match originals: if not values are |
| 429 | * out of range. | 410 | * out of range. |
