diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_mult.c')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 50 | 
1 files changed, 25 insertions, 25 deletions
| diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index 19f21675fb..b48c888048 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
| @@ -102,7 +102,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group) | |||
| 102 | if (!group) | 102 | if (!group) | 
| 103 | return NULL; | 103 | return NULL; | 
| 104 | 104 | ||
| 105 | ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP)); | 105 | ret = (EC_PRE_COMP *)malloc(sizeof(EC_PRE_COMP)); | 
| 106 | if (!ret) | 106 | if (!ret) | 
| 107 | { | 107 | { | 
| 108 | ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); | 108 | ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); | 
| @@ -147,9 +147,9 @@ static void ec_pre_comp_free(void *pre_) | |||
| 147 | 147 | ||
| 148 | for (p = pre->points; *p != NULL; p++) | 148 | for (p = pre->points; *p != NULL; p++) | 
| 149 | EC_POINT_free(*p); | 149 | EC_POINT_free(*p); | 
| 150 | OPENSSL_free(pre->points); | 150 | free(pre->points); | 
| 151 | } | 151 | } | 
| 152 | OPENSSL_free(pre); | 152 | free(pre); | 
| 153 | } | 153 | } | 
| 154 | 154 | ||
| 155 | static void ec_pre_comp_clear_free(void *pre_) | 155 | static void ec_pre_comp_clear_free(void *pre_) | 
| @@ -173,10 +173,10 @@ static void ec_pre_comp_clear_free(void *pre_) | |||
| 173 | EC_POINT_clear_free(*p); | 173 | EC_POINT_clear_free(*p); | 
| 174 | OPENSSL_cleanse(p, sizeof *p); | 174 | OPENSSL_cleanse(p, sizeof *p); | 
| 175 | } | 175 | } | 
| 176 | OPENSSL_free(pre->points); | 176 | free(pre->points); | 
| 177 | } | 177 | } | 
| 178 | OPENSSL_cleanse(pre, sizeof *pre); | 178 | OPENSSL_cleanse(pre, sizeof *pre); | 
| 179 | OPENSSL_free(pre); | 179 | free(pre); | 
| 180 | } | 180 | } | 
| 181 | 181 | ||
| 182 | 182 | ||
| @@ -201,7 +201,7 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | |||
| 201 | 201 | ||
| 202 | if (BN_is_zero(scalar)) | 202 | if (BN_is_zero(scalar)) | 
| 203 | { | 203 | { | 
| 204 | r = OPENSSL_malloc(1); | 204 | r = malloc(1); | 
| 205 | if (!r) | 205 | if (!r) | 
| 206 | { | 206 | { | 
| 207 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); | 207 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); | 
| @@ -233,7 +233,7 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | |||
| 233 | } | 233 | } | 
| 234 | 234 | ||
| 235 | len = BN_num_bits(scalar); | 235 | len = BN_num_bits(scalar); | 
| 236 | r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation | 236 | r = malloc(len + 1); /* modified wNAF may be one digit longer than binary representation | 
| 237 | * (*ret_len will be set to the actual length, i.e. at most | 237 | * (*ret_len will be set to the actual length, i.e. at most | 
| 238 | * BN_num_bits(scalar) + 1) */ | 238 | * BN_num_bits(scalar) + 1) */ | 
| 239 | if (r == NULL) | 239 | if (r == NULL) | 
| @@ -315,7 +315,7 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | |||
| 315 | err: | 315 | err: | 
| 316 | if (!ok) | 316 | if (!ok) | 
| 317 | { | 317 | { | 
| 318 | OPENSSL_free(r); | 318 | free(r); | 
| 319 | r = NULL; | 319 | r = NULL; | 
| 320 | } | 320 | } | 
| 321 | if (ok) | 321 | if (ok) | 
| @@ -441,10 +441,10 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 441 | 441 | ||
| 442 | totalnum = num + numblocks; | 442 | totalnum = num + numblocks; | 
| 443 | 443 | ||
| 444 | wsize = OPENSSL_malloc(totalnum * sizeof wsize[0]); | 444 | wsize = malloc(totalnum * sizeof wsize[0]); | 
| 445 | wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]); | 445 | wNAF_len = malloc(totalnum * sizeof wNAF_len[0]); | 
| 446 | wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space for pivot */ | 446 | wNAF = malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space for pivot */ | 
| 447 | val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]); | 447 | val_sub = malloc(totalnum * sizeof val_sub[0]); | 
| 448 | 448 | ||
| 449 | if (!wsize || !wNAF_len || !wNAF || !val_sub) | 449 | if (!wsize || !wNAF_len || !wNAF || !val_sub) | 
| 450 | { | 450 | { | 
| @@ -560,11 +560,11 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 560 | wNAF_len[i] = tmp_len; | 560 | wNAF_len[i] = tmp_len; | 
| 561 | 561 | ||
| 562 | wNAF[i + 1] = NULL; | 562 | wNAF[i + 1] = NULL; | 
| 563 | wNAF[i] = OPENSSL_malloc(wNAF_len[i]); | 563 | wNAF[i] = malloc(wNAF_len[i]); | 
| 564 | if (wNAF[i] == NULL) | 564 | if (wNAF[i] == NULL) | 
| 565 | { | 565 | { | 
| 566 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); | 566 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); | 
| 567 | OPENSSL_free(tmp_wNAF); | 567 | free(tmp_wNAF); | 
| 568 | goto err; | 568 | goto err; | 
| 569 | } | 569 | } | 
| 570 | memcpy(wNAF[i], pp, wNAF_len[i]); | 570 | memcpy(wNAF[i], pp, wNAF_len[i]); | 
| @@ -574,14 +574,14 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 574 | if (*tmp_points == NULL) | 574 | if (*tmp_points == NULL) | 
| 575 | { | 575 | { | 
| 576 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); | 576 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); | 
| 577 | OPENSSL_free(tmp_wNAF); | 577 | free(tmp_wNAF); | 
| 578 | goto err; | 578 | goto err; | 
| 579 | } | 579 | } | 
| 580 | val_sub[i] = tmp_points; | 580 | val_sub[i] = tmp_points; | 
| 581 | tmp_points += pre_points_per_block; | 581 | tmp_points += pre_points_per_block; | 
| 582 | pp += blocksize; | 582 | pp += blocksize; | 
| 583 | } | 583 | } | 
| 584 | OPENSSL_free(tmp_wNAF); | 584 | free(tmp_wNAF); | 
| 585 | } | 585 | } | 
| 586 | } | 586 | } | 
| 587 | } | 587 | } | 
| @@ -589,7 +589,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 589 | /* All points we precompute now go into a single array 'val'. | 589 | /* All points we precompute now go into a single array 'val'. | 
| 590 | * 'val_sub[i]' is a pointer to the subarray for the i-th point, | 590 | * 'val_sub[i]' is a pointer to the subarray for the i-th point, | 
| 591 | * or to a subarray of 'pre_comp->points' if we already have precomputation. */ | 591 | * or to a subarray of 'pre_comp->points' if we already have precomputation. */ | 
| 592 | val = OPENSSL_malloc((num_val + 1) * sizeof val[0]); | 592 | val = malloc((num_val + 1) * sizeof val[0]); | 
| 593 | if (val == NULL) | 593 | if (val == NULL) | 
| 594 | { | 594 | { | 
| 595 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); | 595 | ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); | 
| @@ -716,28 +716,28 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 716 | if (tmp != NULL) | 716 | if (tmp != NULL) | 
| 717 | EC_POINT_free(tmp); | 717 | EC_POINT_free(tmp); | 
| 718 | if (wsize != NULL) | 718 | if (wsize != NULL) | 
| 719 | OPENSSL_free(wsize); | 719 | free(wsize); | 
| 720 | if (wNAF_len != NULL) | 720 | if (wNAF_len != NULL) | 
| 721 | OPENSSL_free(wNAF_len); | 721 | free(wNAF_len); | 
| 722 | if (wNAF != NULL) | 722 | if (wNAF != NULL) | 
| 723 | { | 723 | { | 
| 724 | signed char **w; | 724 | signed char **w; | 
| 725 | 725 | ||
| 726 | for (w = wNAF; *w != NULL; w++) | 726 | for (w = wNAF; *w != NULL; w++) | 
| 727 | OPENSSL_free(*w); | 727 | free(*w); | 
| 728 | 728 | ||
| 729 | OPENSSL_free(wNAF); | 729 | free(wNAF); | 
| 730 | } | 730 | } | 
| 731 | if (val != NULL) | 731 | if (val != NULL) | 
| 732 | { | 732 | { | 
| 733 | for (v = val; *v != NULL; v++) | 733 | for (v = val; *v != NULL; v++) | 
| 734 | EC_POINT_clear_free(*v); | 734 | EC_POINT_clear_free(*v); | 
| 735 | 735 | ||
| 736 | OPENSSL_free(val); | 736 | free(val); | 
| 737 | } | 737 | } | 
| 738 | if (val_sub != NULL) | 738 | if (val_sub != NULL) | 
| 739 | { | 739 | { | 
| 740 | OPENSSL_free(val_sub); | 740 | free(val_sub); | 
| 741 | } | 741 | } | 
| 742 | return ret; | 742 | return ret; | 
| 743 | } | 743 | } | 
| @@ -825,7 +825,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) | |||
| 825 | pre_points_per_block = (size_t)1 << (w - 1); | 825 | pre_points_per_block = (size_t)1 << (w - 1); | 
| 826 | num = pre_points_per_block * numblocks; /* number of points to compute and store */ | 826 | num = pre_points_per_block * numblocks; /* number of points to compute and store */ | 
| 827 | 827 | ||
| 828 | points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1)); | 828 | points = malloc(sizeof (EC_POINT*)*(num + 1)); | 
| 829 | if (!points) | 829 | if (!points) | 
| 830 | { | 830 | { | 
| 831 | ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); | 831 | ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); | 
| @@ -921,7 +921,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) | |||
| 921 | 921 | ||
| 922 | for (p = points; *p != NULL; p++) | 922 | for (p = points; *p != NULL; p++) | 
| 923 | EC_POINT_free(*p); | 923 | EC_POINT_free(*p); | 
| 924 | OPENSSL_free(points); | 924 | free(points); | 
| 925 | } | 925 | } | 
| 926 | if (tmp_point) | 926 | if (tmp_point) | 
| 927 | EC_POINT_free(tmp_point); | 927 | EC_POINT_free(tmp_point); | 
