Call single parent free_comp routine.
authorRich Salz <rsalz@akamai.com>
Thu, 14 Jan 2016 02:26:00 +0000 (21:26 -0500)
committerRich Salz <rsalz@openssl.org>
Thu, 14 Jan 2016 03:01:02 +0000 (22:01 -0500)
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
crypto/ec/ec_lcl.h
crypto/ec/ec_lib.c
crypto/ec/ec_mult.c
crypto/ec/ecp_nistp224.c
crypto/ec/ecp_nistp256.c
crypto/ec/ecp_nistp521.c
crypto/ec/ecp_nistz256.c

index 36432e16f587ddf097f4c526238e70f54a683aef..2c5e1d901dfb60d663e5629af8b3e987538fbf9b 100644 (file)
@@ -308,6 +308,8 @@ NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);
 NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);
 NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
 EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);
 NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);
 NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
 EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);
+
+void EC_pre_comp_free(EC_GROUP *group);
 void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);
 void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);
 void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);
 void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);
 void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);
 void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);
index 890a274b9738141d44dba6e363085ca6373bf284..6fb4268b8c898ff98a533a244aaab5ecf618eb34 100644 (file)
@@ -109,7 +109,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
     return NULL;
 }
 
     return NULL;
 }
 
-static void ec_group_free_precomp(EC_GROUP *group)
+void EC_pre_comp_free(EC_GROUP *group)
 {
     switch (group->pre_comp_type) {
     default:
 {
     switch (group->pre_comp_type) {
     default:
@@ -145,7 +145,7 @@ void EC_GROUP_free(EC_GROUP *group)
     if (group->meth->group_finish != 0)
         group->meth->group_finish(group);
 
     if (group->meth->group_finish != 0)
         group->meth->group_finish(group);
 
-    ec_group_free_precomp(group);
+    EC_pre_comp_free(group);
     BN_MONT_CTX_free(group->mont_data);
     EC_POINT_free(group->generator);
     BN_free(group->order);
     BN_MONT_CTX_free(group->mont_data);
     EC_POINT_free(group->generator);
     BN_free(group->order);
@@ -164,7 +164,7 @@ void EC_GROUP_clear_free(EC_GROUP *group)
     else if (group->meth->group_finish != 0)
         group->meth->group_finish(group);
 
     else if (group->meth->group_finish != 0)
         group->meth->group_finish(group);
 
-    ec_group_free_precomp(group);
+    EC_pre_comp_free(group);
     BN_MONT_CTX_free(group->mont_data);
     EC_POINT_clear_free(group->generator);
     BN_clear_free(group->order);
     BN_MONT_CTX_free(group->mont_data);
     EC_POINT_clear_free(group->generator);
     BN_clear_free(group->order);
index 8a4e23d6498fcdf52d867107466007ec0d47a415..5908f594f109b5158044f7493c05f1ff8d42a99e 100644 (file)
@@ -562,7 +562,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     int ret = 0;
 
     /* if there is an old EC_PRE_COMP object, throw it away */
     int ret = 0;
 
     /* if there is an old EC_PRE_COMP object, throw it away */
-    EC_ec_pre_comp_free(group->pre_comp.ec);
+    EC_pre_comp_free(group);
     if ((pre_comp = ec_pre_comp_new(group)) == NULL)
         return 0;
 
     if ((pre_comp = ec_pre_comp_new(group)) == NULL)
         return 0;
 
index a2def18031c26104d2be240f343ae5a180c76184..e17ac18255d3ceff728c0dae6b502ae52d60c249 100644 (file)
@@ -1559,8 +1559,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     felem tmp_felems[32];
 
     /* throw away old precomputation */
     felem tmp_felems[32];
 
     /* throw away old precomputation */
-    EC_nistp224_pre_comp_free(group->pre_comp.nistp224);
-    group->pre_comp.nistp224 = NULL;
+    EC_pre_comp_free(group);
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
index 11bde8a50f4b5bc92b8482b4162374d1a8ea023e..9db5ffa7f21634e103166b5d5443c0b6493788b4 100644 (file)
@@ -2184,8 +2184,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     felem x_tmp, y_tmp, z_tmp;
 
     /* throw away old precomputation */
     felem x_tmp, y_tmp, z_tmp;
 
     /* throw away old precomputation */
-    EC_nistp256_pre_comp_free(group->pre_comp.nistp256);
-    group->pre_comp.nistp256 = NULL;
+    EC_pre_comp_free(group);
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
index d6565177914601770dac29ca0575662e2aa198a0..ee9c07e885be0f4aff9de1c3fad02bffe461f551 100644 (file)
@@ -2008,8 +2008,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     felem tmp_felems[16];
 
     /* throw away old precomputation */
     felem tmp_felems[16];
 
     /* throw away old precomputation */
-    EC_nistp521_pre_comp_free(group->pre_comp.nistp521);
-    group->pre_comp.nistp521 = NULL;
+    EC_pre_comp_free(group);
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
     if (ctx == NULL)
         if ((ctx = new_ctx = BN_CTX_new()) == NULL)
             return 0;
index c25a7daf3cea419da397ca1bbdd91b00c4539664..579a3ad622b7efd1cf1dc82f68ff3ef552156ab7 100644 (file)
@@ -769,8 +769,7 @@ __owur static int ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx)
     unsigned char *precomp_storage = NULL;
 
     /* if there is an old NISTZ256_PRE_COMP object, throw it away */
     unsigned char *precomp_storage = NULL;
 
     /* if there is an old NISTZ256_PRE_COMP object, throw it away */
-    EC_nistz256_pre_comp_free(group->pre_comp.nistz256);
-    group->pre_comp.nistz256 = NULL;
+    EC_pre_comp_free(group);
     generator = EC_GROUP_get0_generator(group);
     if (generator == NULL) {
         ECerr(EC_F_ECP_NISTZ256_MULT_PRECOMPUTE, EC_R_UNDEFINED_GENERATOR);
     generator = EC_GROUP_get0_generator(group);
     if (generator == NULL) {
         ECerr(EC_F_ECP_NISTZ256_MULT_PRECOMPUTE, EC_R_UNDEFINED_GENERATOR);