Skip to content

Commit

Permalink
Fold EC_POINT_clear_free into EC_POINT_free.
Browse files Browse the repository at this point in the history
All frees zero memory now.

Change-Id: I5b04a0d14f38d5a7422e148d077fcba85a593594
Reviewed-on: https://boringssl-review.googlesource.com/22225
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
  • Loading branch information
davidben authored and CQ bot account: commit-bot@chromium.org committed Oct 27, 2017
1 parent ed84291 commit d24fd47
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
10 changes: 1 addition & 9 deletions crypto/fipsmodule/ec/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,7 @@ void EC_POINT_free(EC_POINT *point) {
OPENSSL_free(point);
}

void EC_POINT_clear_free(EC_POINT *point) {
if (!point) {
return;
}

ec_GFp_simple_point_clear_finish(point);

OPENSSL_free(point);
}
void EC_POINT_clear_free(EC_POINT *point) { EC_POINT_free(point); }

int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src) {
if (dest->meth != src->meth) {
Expand Down
1 change: 0 additions & 1 deletion crypto/fipsmodule/ec/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
unsigned ec_GFp_simple_group_get_degree(const EC_GROUP *);
int ec_GFp_simple_point_init(EC_POINT *);
void ec_GFp_simple_point_finish(EC_POINT *);
void ec_GFp_simple_point_clear_finish(EC_POINT *);
int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);
int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *,
Expand Down
6 changes: 0 additions & 6 deletions crypto/fipsmodule/ec/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,6 @@ void ec_GFp_simple_point_finish(EC_POINT *point) {
BN_free(&point->Z);
}

void ec_GFp_simple_point_clear_finish(EC_POINT *point) {
BN_clear_free(&point->X);
BN_clear_free(&point->Y);
BN_clear_free(&point->Z);
}

int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) {
if (!BN_copy(&dest->X, &src->X) ||
!BN_copy(&dest->Y, &src->Y) ||
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/ec/wnaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
}
if (val != NULL) {
for (i = 0; i < num_val; i++) {
EC_POINT_clear_free(val[i]);
EC_POINT_free(val[i]);
}

OPENSSL_free(val);
Expand Down
7 changes: 3 additions & 4 deletions include/openssl/ec.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ OPENSSL_EXPORT EC_POINT *EC_POINT_new(const EC_GROUP *group);
// EC_POINT_free frees |point| and the data that it points to.
OPENSSL_EXPORT void EC_POINT_free(EC_POINT *point);

// EC_POINT_clear_free clears the data that |point| points to, frees it and
// then frees |point| itself.
OPENSSL_EXPORT void EC_POINT_clear_free(EC_POINT *point);

// EC_POINT_copy sets |*dest| equal to |*src|. It returns one on success and
// zero otherwise.
OPENSSL_EXPORT int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src);
Expand Down Expand Up @@ -350,6 +346,9 @@ typedef struct {
OPENSSL_EXPORT size_t EC_get_builtin_curves(EC_builtin_curve *out_curves,
size_t max_num_curves);

// EC_POINT_clear_free calls |EC_POINT_free|.
OPENSSL_EXPORT void EC_POINT_clear_free(EC_POINT *point);

// Old code expects to get EC_KEY from ec.h.
#include <openssl/ec_key.h>

Expand Down

0 comments on commit d24fd47

Please sign in to comment.