diff options
| author | tb <> | 2023-07-26 12:26:48 +0000 |
|---|---|---|
| committer | tb <> | 2023-07-26 12:26:48 +0000 |
| commit | 8b47ca9fbdd896b20c0d79c4cdcc050bfffb9fbb (patch) | |
| tree | 9e55adae7732077c513174c0dac83fae27a9798c /src | |
| parent | d532e9694d3555ade9ab916e9b71cfc075ca6ccc (diff) | |
| download | openbsd-8b47ca9fbdd896b20c0d79c4cdcc050bfffb9fbb.tar.gz openbsd-8b47ca9fbdd896b20c0d79c4cdcc050bfffb9fbb.tar.bz2 openbsd-8b47ca9fbdd896b20c0d79c4cdcc050bfffb9fbb.zip | |
Unindent a big block in EC_GROUP_get_affine_coordinates()
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index add1348372..f591fa0267 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecp_smpl.c,v 1.53 2023/07/26 12:24:28 tb Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.54 2023/07/26 12:26:48 tb Exp $ */ |
| 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
| 3 | * for the OpenSSL project. | 3 | * for the OpenSSL project. |
| 4 | * Includes code written by Bodo Moeller for the OpenSSL project. | 4 | * Includes code written by Bodo Moeller for the OpenSSL project. |
| @@ -417,47 +417,49 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, | |||
| 417 | goto err; | 417 | goto err; |
| 418 | if (!ec_decode_scalar(group, y, &point->Y, ctx)) | 418 | if (!ec_decode_scalar(group, y, &point->Y, ctx)) |
| 419 | goto err; | 419 | goto err; |
| 420 | goto done; | ||
| 421 | } | ||
| 422 | |||
| 423 | if (BN_mod_inverse_ct(Z_1, z, &group->field, ctx) == NULL) { | ||
| 424 | ECerror(ERR_R_BN_LIB); | ||
| 425 | goto err; | ||
| 426 | } | ||
| 427 | if (group->meth->field_encode == NULL) { | ||
| 428 | /* field_sqr works on standard representation */ | ||
| 429 | if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) | ||
| 430 | goto err; | ||
| 420 | } else { | 431 | } else { |
| 421 | if (BN_mod_inverse_ct(Z_1, z, &group->field, ctx) == NULL) { | 432 | if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) |
| 422 | ECerror(ERR_R_BN_LIB); | ||
| 423 | goto err; | 433 | goto err; |
| 424 | } | 434 | } |
| 435 | |||
| 436 | if (x != NULL) { | ||
| 437 | /* | ||
| 438 | * in the Montgomery case, field_mul will cancel out | ||
| 439 | * Montgomery factor in X: | ||
| 440 | */ | ||
| 441 | if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx)) | ||
| 442 | goto err; | ||
| 443 | } | ||
| 444 | if (y != NULL) { | ||
| 425 | if (group->meth->field_encode == NULL) { | 445 | if (group->meth->field_encode == NULL) { |
| 426 | /* field_sqr works on standard representation */ | 446 | /* field_mul works on standard representation */ |
| 427 | if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) | 447 | if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) |
| 428 | goto err; | 448 | goto err; |
| 429 | } else { | 449 | } else { |
| 430 | if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) | 450 | if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) |
| 431 | goto err; | 451 | goto err; |
| 432 | } | 452 | } |
| 433 | 453 | ||
| 434 | if (x != NULL) { | 454 | /* |
| 435 | /* | 455 | * in the Montgomery case, field_mul will cancel out |
| 436 | * in the Montgomery case, field_mul will cancel out | 456 | * Montgomery factor in Y: |
| 437 | * Montgomery factor in X: | 457 | */ |
| 438 | */ | 458 | if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx)) |
| 439 | if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx)) | 459 | goto err; |
| 440 | goto err; | ||
| 441 | } | ||
| 442 | if (y != NULL) { | ||
| 443 | if (group->meth->field_encode == NULL) { | ||
| 444 | /* field_mul works on standard representation */ | ||
| 445 | if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) | ||
| 446 | goto err; | ||
| 447 | } else { | ||
| 448 | if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) | ||
| 449 | goto err; | ||
| 450 | } | ||
| 451 | |||
| 452 | /* | ||
| 453 | * in the Montgomery case, field_mul will cancel out | ||
| 454 | * Montgomery factor in Y: | ||
| 455 | */ | ||
| 456 | if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx)) | ||
| 457 | goto err; | ||
| 458 | } | ||
| 459 | } | 460 | } |
| 460 | 461 | ||
| 462 | done: | ||
| 461 | ret = 1; | 463 | ret = 1; |
| 462 | 464 | ||
| 463 | err: | 465 | err: |
