summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ecp_smpl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ec/ecp_smpl.c')
-rw-r--r--src/lib/libcrypto/ec/ecp_smpl.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c
index 5ba9a925d6..dabc5af899 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.12 2014/06/12 15:49:29 deraadt Exp $ */ 1/* $OpenBSD: ecp_smpl.c,v 1.13 2014/07/12 16:03:37 miod 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.
@@ -222,8 +222,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group,
222 222
223err: 223err:
224 BN_CTX_end(ctx); 224 BN_CTX_end(ctx);
225 if (new_ctx != NULL) 225 BN_CTX_free(new_ctx);
226 BN_CTX_free(new_ctx);
227 return ret; 226 return ret;
228} 227}
229 228
@@ -267,8 +266,7 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI
267 ret = 1; 266 ret = 1;
268 267
269err: 268err:
270 if (new_ctx) 269 BN_CTX_free(new_ctx);
271 BN_CTX_free(new_ctx);
272 return ret; 270 return ret;
273} 271}
274 272
@@ -348,8 +346,7 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
348err: 346err:
349 if (ctx != NULL) 347 if (ctx != NULL)
350 BN_CTX_end(ctx); 348 BN_CTX_end(ctx);
351 if (new_ctx != NULL) 349 BN_CTX_free(new_ctx);
352 BN_CTX_free(new_ctx);
353 return ret; 350 return ret;
354} 351}
355 352
@@ -457,8 +454,7 @@ ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT *
457 ret = 1; 454 ret = 1;
458 455
459err: 456err:
460 if (new_ctx != NULL) 457 BN_CTX_free(new_ctx);
461 BN_CTX_free(new_ctx);
462 return ret; 458 return ret;
463} 459}
464 460
@@ -506,8 +502,7 @@ ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_P
506 ret = 1; 502 ret = 1;
507 503
508err: 504err:
509 if (new_ctx != NULL) 505 BN_CTX_free(new_ctx);
510 BN_CTX_free(new_ctx);
511 return ret; 506 return ret;
512} 507}
513 508
@@ -626,8 +621,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN
626 621
627err: 622err:
628 BN_CTX_end(ctx); 623 BN_CTX_end(ctx);
629 if (new_ctx != NULL) 624 BN_CTX_free(new_ctx);
630 BN_CTX_free(new_ctx);
631 return ret; 625 return ret;
632} 626}
633 627
@@ -810,8 +804,7 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons
810end: 804end:
811 if (ctx) /* otherwise we already called BN_CTX_end */ 805 if (ctx) /* otherwise we already called BN_CTX_end */
812 BN_CTX_end(ctx); 806 BN_CTX_end(ctx);
813 if (new_ctx != NULL) 807 BN_CTX_free(new_ctx);
814 BN_CTX_free(new_ctx);
815 return ret; 808 return ret;
816} 809}
817 810
@@ -951,8 +944,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C
951 944
952err: 945err:
953 BN_CTX_end(ctx); 946 BN_CTX_end(ctx);
954 if (new_ctx != NULL) 947 BN_CTX_free(new_ctx);
955 BN_CTX_free(new_ctx);
956 return ret; 948 return ret;
957} 949}
958 950
@@ -1071,8 +1063,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX
1071 1063
1072err: 1064err:
1073 BN_CTX_end(ctx); 1065 BN_CTX_end(ctx);
1074 if (new_ctx != NULL) 1066 BN_CTX_free(new_ctx);
1075 BN_CTX_free(new_ctx);
1076 return ret; 1067 return ret;
1077} 1068}
1078 1069
@@ -1172,8 +1163,7 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b
1172 1163
1173end: 1164end:
1174 BN_CTX_end(ctx); 1165 BN_CTX_end(ctx);
1175 if (new_ctx != NULL) 1166 BN_CTX_free(new_ctx);
1176 BN_CTX_free(new_ctx);
1177 return ret; 1167 return ret;
1178} 1168}
1179 1169
@@ -1211,8 +1201,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx
1211 1201
1212err: 1202err:
1213 BN_CTX_end(ctx); 1203 BN_CTX_end(ctx);
1214 if (new_ctx != NULL) 1204 BN_CTX_free(new_ctx);
1215 BN_CTX_free(new_ctx);
1216 return ret; 1205 return ret;
1217} 1206}
1218 1207
@@ -1377,16 +1366,14 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT *
1377 1366
1378err: 1367err:
1379 BN_CTX_end(ctx); 1368 BN_CTX_end(ctx);
1380 if (new_ctx != NULL) 1369 BN_CTX_free(new_ctx);
1381 BN_CTX_free(new_ctx);
1382 if (heap != NULL) { 1370 if (heap != NULL) {
1383 /* 1371 /*
1384 * heap[pow2/2] .. heap[pow2-1] have not been allocated 1372 * heap[pow2/2] .. heap[pow2-1] have not been allocated
1385 * locally! 1373 * locally!
1386 */ 1374 */
1387 for (i = pow2 / 2 - 1; i > 0; i--) { 1375 for (i = pow2 / 2 - 1; i > 0; i--) {
1388 if (heap[i] != NULL) 1376 BN_clear_free(heap[i]);
1389 BN_clear_free(heap[i]);
1390 } 1377 }
1391 free(heap); 1378 free(heap);
1392 } 1379 }