Skip to content

Commit

Permalink
PR comments; improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel40791765 committed Oct 2, 2024
1 parent e4d0269 commit 8e1fd2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions crypto/fipsmodule/ec/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
// for |EC_GROUP_new_curve_GFp| and |EC_GROUP_set_generator|.
// Note: See commit cb16f17b36d9ee9528a06d2e520374a4f177af4d.
ret->mutable_ec_group = 0;
ret->conv_form = POINT_CONVERSION_UNCOMPRESSED;
ret->meth = EC_GFp_mont_method();
bn_mont_ctx_init(&ret->field);
bn_mont_ctx_init(&ret->order);
Expand Down Expand Up @@ -456,7 +457,7 @@ void EC_GROUP_free(EC_GROUP *group) {

EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
if (a == NULL) {
return (EC_GROUP *)a;
return NULL;
}

if (!a->mutable_ec_group) {
Expand Down Expand Up @@ -491,21 +492,20 @@ EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
}

int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ignored) {
if (!a->mutable_ec_group && !b->mutable_ec_group) {
// Note this function returns 0 if equal and non-zero otherwise.
if (a == b) {
return 0;
}
// Built-in static curves may be compared by curve name alone.
if (a->curve_name != b->curve_name) {
return 1;
}
if (a->curve_name != NID_undef) {
// |NID_undef| indicates a custom curve. If we're comparing custom curves
// we fall through and compare the entire curve structure below.
return 0;
}
// Note this function returns 0 if equal and non-zero otherwise.
if (a == b) {
return 0;
}
// Built-in static curves may be compared by curve name alone.
if (a->curve_name != b->curve_name) {
return 1;
}
if (a->curve_name != NID_undef) {
// |NID_undef| indicates a custom curve. If we're comparing custom curves
// we fall through and compare the entire curve structure below.
return 0;
}

// |a| and |b| are both custom curves. We compare the entire curve
// structure. If |a| or |b| is incomplete (due to legacy OpenSSL mistakes,
// custom curve construction is sadly done in two parts) but otherwise not the
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/ec/ec_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key) {
}

void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform) {
if (key == NULL || key->group == NULL) {
if (key == NULL) {
OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER);
return;
}
key->conv_form = cform;
if (key->group->mutable_ec_group) {
if (key->group != NULL && key->group->mutable_ec_group) {
key->group->conv_form = cform;
}
}
Expand Down

0 comments on commit 8e1fd2f

Please sign in to comment.