diff options
Diffstat (limited to 'src/lib/libcrypto/ec')
-rw-r--r-- | src/lib/libcrypto/ec/ec2_mult.c | 26 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec2_oct.c | 32 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 56 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 33 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_oct.c | 30 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 101 |
8 files changed, 165 insertions, 127 deletions
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c index dd113907be..8f0091efe1 100644 --- a/src/lib/libcrypto/ec/ec2_mult.c +++ b/src/lib/libcrypto/ec/ec2_mult.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec2_mult.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ec2_mult.c,v 1.7 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -91,8 +91,7 @@ gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) | |||
91 | 91 | ||
92 | /* Since Mdouble is static we can guarantee that ctx != NULL. */ | 92 | /* Since Mdouble is static we can guarantee that ctx != NULL. */ |
93 | BN_CTX_start(ctx); | 93 | BN_CTX_start(ctx); |
94 | t1 = BN_CTX_get(ctx); | 94 | if ((t1 = BN_CTX_get(ctx)) == NULL) |
95 | if (t1 == NULL) | ||
96 | goto err; | 95 | goto err; |
97 | 96 | ||
98 | if (!group->meth->field_sqr(group, x, x, ctx)) | 97 | if (!group->meth->field_sqr(group, x, x, ctx)) |
@@ -132,9 +131,9 @@ gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, | |||
132 | 131 | ||
133 | /* Since Madd is static we can guarantee that ctx != NULL. */ | 132 | /* Since Madd is static we can guarantee that ctx != NULL. */ |
134 | BN_CTX_start(ctx); | 133 | BN_CTX_start(ctx); |
135 | t1 = BN_CTX_get(ctx); | 134 | if ((t1 = BN_CTX_get(ctx)) == NULL) |
136 | t2 = BN_CTX_get(ctx); | 135 | goto err; |
137 | if (t2 == NULL) | 136 | if ((t2 = BN_CTX_get(ctx)) == NULL) |
138 | goto err; | 137 | goto err; |
139 | 138 | ||
140 | if (!BN_copy(t1, x)) | 139 | if (!BN_copy(t1, x)) |
@@ -191,10 +190,11 @@ gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, | |||
191 | } | 190 | } |
192 | /* Since Mxy is static we can guarantee that ctx != NULL. */ | 191 | /* Since Mxy is static we can guarantee that ctx != NULL. */ |
193 | BN_CTX_start(ctx); | 192 | BN_CTX_start(ctx); |
194 | t3 = BN_CTX_get(ctx); | 193 | if ((t3 = BN_CTX_get(ctx)) == NULL) |
195 | t4 = BN_CTX_get(ctx); | 194 | goto err; |
196 | t5 = BN_CTX_get(ctx); | 195 | if ((t4 = BN_CTX_get(ctx)) == NULL) |
197 | if (t5 == NULL) | 196 | goto err; |
197 | if ((t5 = BN_CTX_get(ctx)) == NULL) | ||
198 | goto err; | 198 | goto err; |
199 | 199 | ||
200 | if (!BN_one(t5)) | 200 | if (!BN_one(t5)) |
@@ -281,9 +281,9 @@ ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, | |||
281 | 281 | ||
282 | /* Since point_multiply is static we can guarantee that ctx != NULL. */ | 282 | /* Since point_multiply is static we can guarantee that ctx != NULL. */ |
283 | BN_CTX_start(ctx); | 283 | BN_CTX_start(ctx); |
284 | x1 = BN_CTX_get(ctx); | 284 | if ((x1 = BN_CTX_get(ctx)) == NULL) |
285 | z1 = BN_CTX_get(ctx); | 285 | goto err; |
286 | if (z1 == NULL) | 286 | if ((z1 = BN_CTX_get(ctx)) == NULL) |
287 | goto err; | 287 | goto err; |
288 | 288 | ||
289 | x2 = &r->X; | 289 | x2 = &r->X; |
diff --git a/src/lib/libcrypto/ec/ec2_oct.c b/src/lib/libcrypto/ec/ec2_oct.c index c45d9c2219..72690b1bc7 100644 --- a/src/lib/libcrypto/ec/ec2_oct.c +++ b/src/lib/libcrypto/ec/ec2_oct.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec2_oct.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ec2_oct.c,v 1.7 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -109,11 +109,13 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point | |||
109 | y_bit = (y_bit != 0) ? 1 : 0; | 109 | y_bit = (y_bit != 0) ? 1 : 0; |
110 | 110 | ||
111 | BN_CTX_start(ctx); | 111 | BN_CTX_start(ctx); |
112 | tmp = BN_CTX_get(ctx); | 112 | if ((tmp = BN_CTX_get(ctx)) == NULL) |
113 | x = BN_CTX_get(ctx); | 113 | goto err; |
114 | y = BN_CTX_get(ctx); | 114 | if ((x = BN_CTX_get(ctx)) == NULL) |
115 | z = BN_CTX_get(ctx); | 115 | goto err; |
116 | if (z == NULL) | 116 | if ((y = BN_CTX_get(ctx)) == NULL) |
117 | goto err; | ||
118 | if ((z = BN_CTX_get(ctx)) == NULL) | ||
117 | goto err; | 119 | goto err; |
118 | 120 | ||
119 | if (!BN_GF2m_mod_arr(x, x_, group->poly)) | 121 | if (!BN_GF2m_mod_arr(x, x_, group->poly)) |
@@ -212,10 +214,11 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
212 | } | 214 | } |
213 | BN_CTX_start(ctx); | 215 | BN_CTX_start(ctx); |
214 | used_ctx = 1; | 216 | used_ctx = 1; |
215 | x = BN_CTX_get(ctx); | 217 | if ((x = BN_CTX_get(ctx)) == NULL) |
216 | y = BN_CTX_get(ctx); | 218 | goto err; |
217 | yxi = BN_CTX_get(ctx); | 219 | if ((y = BN_CTX_get(ctx)) == NULL) |
218 | if (yxi == NULL) | 220 | goto err; |
221 | if ((yxi = BN_CTX_get(ctx)) == NULL) | ||
219 | goto err; | 222 | goto err; |
220 | 223 | ||
221 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) | 224 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) |
@@ -329,10 +332,11 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
329 | return 0; | 332 | return 0; |
330 | } | 333 | } |
331 | BN_CTX_start(ctx); | 334 | BN_CTX_start(ctx); |
332 | x = BN_CTX_get(ctx); | 335 | if ((x = BN_CTX_get(ctx)) == NULL) |
333 | y = BN_CTX_get(ctx); | 336 | goto err; |
334 | yxi = BN_CTX_get(ctx); | 337 | if ((y = BN_CTX_get(ctx)) == NULL) |
335 | if (yxi == NULL) | 338 | goto err; |
339 | if ((yxi = BN_CTX_get(ctx)) == NULL) | ||
336 | goto err; | 340 | goto err; |
337 | 341 | ||
338 | if (!BN_bin2bn(buf + 1, field_len, x)) | 342 | if (!BN_bin2bn(buf + 1, field_len, x)) |
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index b9c066c5c1..43f0afd5ae 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec2_smpl.c,v 1.13 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ec2_smpl.c,v 1.14 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -291,8 +291,7 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) | |||
291 | } | 291 | } |
292 | } | 292 | } |
293 | BN_CTX_start(ctx); | 293 | BN_CTX_start(ctx); |
294 | b = BN_CTX_get(ctx); | 294 | if ((b = BN_CTX_get(ctx)) == NULL) |
295 | if (b == NULL) | ||
296 | goto err; | 295 | goto err; |
297 | 296 | ||
298 | if (!BN_GF2m_mod_arr(b, &group->b, group->poly)) | 297 | if (!BN_GF2m_mod_arr(b, &group->b, group->poly)) |
@@ -464,15 +463,21 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | |||
464 | return 0; | 463 | return 0; |
465 | } | 464 | } |
466 | BN_CTX_start(ctx); | 465 | BN_CTX_start(ctx); |
467 | x0 = BN_CTX_get(ctx); | 466 | if ((x0 = BN_CTX_get(ctx)) == NULL) |
468 | y0 = BN_CTX_get(ctx); | 467 | goto err; |
469 | x1 = BN_CTX_get(ctx); | 468 | if ((y0 = BN_CTX_get(ctx)) == NULL) |
470 | y1 = BN_CTX_get(ctx); | 469 | goto err; |
471 | x2 = BN_CTX_get(ctx); | 470 | if ((x1 = BN_CTX_get(ctx)) == NULL) |
472 | y2 = BN_CTX_get(ctx); | 471 | goto err; |
473 | s = BN_CTX_get(ctx); | 472 | if ((y1 = BN_CTX_get(ctx)) == NULL) |
474 | t = BN_CTX_get(ctx); | 473 | goto err; |
475 | if (t == NULL) | 474 | if ((x2 = BN_CTX_get(ctx)) == NULL) |
475 | goto err; | ||
476 | if ((y2 = BN_CTX_get(ctx)) == NULL) | ||
477 | goto err; | ||
478 | if ((s = BN_CTX_get(ctx)) == NULL) | ||
479 | goto err; | ||
480 | if ((t = BN_CTX_get(ctx)) == NULL) | ||
476 | goto err; | 481 | goto err; |
477 | 482 | ||
478 | if (a->Z_is_one) { | 483 | if (a->Z_is_one) { |
@@ -611,9 +616,9 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX | |||
611 | return -1; | 616 | return -1; |
612 | } | 617 | } |
613 | BN_CTX_start(ctx); | 618 | BN_CTX_start(ctx); |
614 | y2 = BN_CTX_get(ctx); | 619 | if ((y2 = BN_CTX_get(ctx)) == NULL) |
615 | lh = BN_CTX_get(ctx); | 620 | goto err; |
616 | if (lh == NULL) | 621 | if ((lh = BN_CTX_get(ctx)) == NULL) |
617 | goto err; | 622 | goto err; |
618 | 623 | ||
619 | /* | 624 | /* |
@@ -651,7 +656,8 @@ err: | |||
651 | * 1 not equal | 656 | * 1 not equal |
652 | */ | 657 | */ |
653 | int | 658 | int |
654 | ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) | 659 | ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, |
660 | const EC_POINT *b, BN_CTX *ctx) | ||
655 | { | 661 | { |
656 | BIGNUM *aX, *aY, *bX, *bY; | 662 | BIGNUM *aX, *aY, *bX, *bY; |
657 | BN_CTX *new_ctx = NULL; | 663 | BN_CTX *new_ctx = NULL; |
@@ -672,11 +678,13 @@ ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * | |||
672 | return -1; | 678 | return -1; |
673 | } | 679 | } |
674 | BN_CTX_start(ctx); | 680 | BN_CTX_start(ctx); |
675 | aX = BN_CTX_get(ctx); | 681 | if ((aX = BN_CTX_get(ctx)) == NULL) |
676 | aY = BN_CTX_get(ctx); | 682 | goto err; |
677 | bX = BN_CTX_get(ctx); | 683 | if ((aY = BN_CTX_get(ctx)) == NULL) |
678 | bY = BN_CTX_get(ctx); | 684 | goto err; |
679 | if (bY == NULL) | 685 | if ((bX = BN_CTX_get(ctx)) == NULL) |
686 | goto err; | ||
687 | if ((bY = BN_CTX_get(ctx)) == NULL) | ||
680 | goto err; | 688 | goto err; |
681 | 689 | ||
682 | if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) | 690 | if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) |
@@ -710,9 +718,9 @@ ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ct | |||
710 | return 0; | 718 | return 0; |
711 | } | 719 | } |
712 | BN_CTX_start(ctx); | 720 | BN_CTX_start(ctx); |
713 | x = BN_CTX_get(ctx); | 721 | if ((x = BN_CTX_get(ctx)) == NULL) |
714 | y = BN_CTX_get(ctx); | 722 | goto err; |
715 | if (y == NULL) | 723 | if ((y = BN_CTX_get(ctx)) == NULL) |
716 | goto err; | 724 | goto err; |
717 | 725 | ||
718 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) | 726 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) |
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index f9904b4ee9..45192c3231 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_key.c,v 1.10 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ec_key.c,v 1.11 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -359,8 +359,11 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) | |||
359 | if (tmp_nid == NID_X9_62_characteristic_two_field) | 359 | if (tmp_nid == NID_X9_62_characteristic_two_field) |
360 | is_char_two = 1; | 360 | is_char_two = 1; |
361 | 361 | ||
362 | tx = BN_CTX_get(ctx); | 362 | if ((tx = BN_CTX_get(ctx)) == NULL) |
363 | ty = BN_CTX_get(ctx); | 363 | goto err; |
364 | if ((ty = BN_CTX_get(ctx)) == NULL) | ||
365 | goto err; | ||
366 | |||
364 | #ifndef OPENSSL_NO_EC2M | 367 | #ifndef OPENSSL_NO_EC2M |
365 | if (is_char_two) { | 368 | if (is_char_two) { |
366 | if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, | 369 | if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, |
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index 47ccc614d1..8cf0f2241e 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_lib.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.16 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -497,18 +497,19 @@ EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) | |||
497 | return -1; | 497 | return -1; |
498 | 498 | ||
499 | BN_CTX_start(ctx); | 499 | BN_CTX_start(ctx); |
500 | a1 = BN_CTX_get(ctx); | 500 | if ((a1 = BN_CTX_get(ctx)) == NULL) |
501 | a2 = BN_CTX_get(ctx); | 501 | goto err; |
502 | a3 = BN_CTX_get(ctx); | 502 | if ((a2 = BN_CTX_get(ctx)) == NULL) |
503 | b1 = BN_CTX_get(ctx); | 503 | goto err; |
504 | b2 = BN_CTX_get(ctx); | 504 | if ((a3 = BN_CTX_get(ctx)) == NULL) |
505 | b3 = BN_CTX_get(ctx); | 505 | goto err; |
506 | if (!b3) { | 506 | if ((b1 = BN_CTX_get(ctx)) == NULL) |
507 | BN_CTX_end(ctx); | 507 | goto err; |
508 | if (ctx_new) | 508 | if ((b2 = BN_CTX_get(ctx)) == NULL) |
509 | BN_CTX_free(ctx); | 509 | goto err; |
510 | return -1; | 510 | if ((b3 = BN_CTX_get(ctx)) == NULL) |
511 | } | 511 | goto err; |
512 | |||
512 | /* | 513 | /* |
513 | * XXX This approach assumes that the external representation of | 514 | * XXX This approach assumes that the external representation of |
514 | * curves over the same field type is the same. | 515 | * curves over the same field type is the same. |
@@ -544,6 +545,12 @@ EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) | |||
544 | BN_CTX_free(ctx); | 545 | BN_CTX_free(ctx); |
545 | 546 | ||
546 | return r; | 547 | return r; |
548 | |||
549 | err: | ||
550 | BN_CTX_end(ctx); | ||
551 | if (ctx_new) | ||
552 | BN_CTX_free(ctx); | ||
553 | return -1; | ||
547 | } | 554 | } |
548 | 555 | ||
549 | 556 | ||
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index 9e3aee13a2..e711413598 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_mult.c,v 1.16 2015/02/07 13:19:15 doug Exp $ */ | 1 | /* $OpenBSD: ec_mult.c,v 1.17 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. | 3 | * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -753,8 +753,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | |||
753 | goto err; | 753 | goto err; |
754 | } | 754 | } |
755 | BN_CTX_start(ctx); | 755 | BN_CTX_start(ctx); |
756 | order = BN_CTX_get(ctx); | 756 | if ((order = BN_CTX_get(ctx)) == NULL) |
757 | if (order == NULL) | ||
758 | goto err; | 757 | goto err; |
759 | 758 | ||
760 | if (!EC_GROUP_get_order(group, order, ctx)) | 759 | if (!EC_GROUP_get_order(group, order, ctx)) |
diff --git a/src/lib/libcrypto/ec/ecp_oct.c b/src/lib/libcrypto/ec/ecp_oct.c index abc31e6382..994f0b08b1 100644 --- a/src/lib/libcrypto/ec/ecp_oct.c +++ b/src/lib/libcrypto/ec/ecp_oct.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_oct.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ecp_oct.c,v 1.7 2015/02/09 15:49:22 jsing 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. |
@@ -67,8 +67,8 @@ | |||
67 | #include "ec_lcl.h" | 67 | #include "ec_lcl.h" |
68 | 68 | ||
69 | int | 69 | int |
70 | ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, EC_POINT * point, | 70 | ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, |
71 | const BIGNUM * x_, int y_bit, BN_CTX * ctx) | 71 | EC_POINT * point, const BIGNUM * x_, int y_bit, BN_CTX * ctx) |
72 | { | 72 | { |
73 | BN_CTX *new_ctx = NULL; | 73 | BN_CTX *new_ctx = NULL; |
74 | BIGNUM *tmp1, *tmp2, *x, *y; | 74 | BIGNUM *tmp1, *tmp2, *x, *y; |
@@ -85,11 +85,13 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, EC_POINT * poin | |||
85 | y_bit = (y_bit != 0); | 85 | y_bit = (y_bit != 0); |
86 | 86 | ||
87 | BN_CTX_start(ctx); | 87 | BN_CTX_start(ctx); |
88 | tmp1 = BN_CTX_get(ctx); | 88 | if ((tmp1 = BN_CTX_get(ctx)) == NULL) |
89 | tmp2 = BN_CTX_get(ctx); | 89 | goto err; |
90 | x = BN_CTX_get(ctx); | 90 | if ((tmp2 = BN_CTX_get(ctx)) == NULL) |
91 | y = BN_CTX_get(ctx); | 91 | goto err; |
92 | if (y == NULL) | 92 | if ((x = BN_CTX_get(ctx)) == NULL) |
93 | goto err; | ||
94 | if ((y = BN_CTX_get(ctx)) == NULL) | ||
93 | goto err; | 95 | goto err; |
94 | 96 | ||
95 | /* | 97 | /* |
@@ -239,9 +241,9 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co | |||
239 | } | 241 | } |
240 | BN_CTX_start(ctx); | 242 | BN_CTX_start(ctx); |
241 | used_ctx = 1; | 243 | used_ctx = 1; |
242 | x = BN_CTX_get(ctx); | 244 | if ((x = BN_CTX_get(ctx)) == NULL) |
243 | y = BN_CTX_get(ctx); | 245 | goto err; |
244 | if (y == NULL) | 246 | if ((y = BN_CTX_get(ctx)) == NULL) |
245 | goto err; | 247 | goto err; |
246 | 248 | ||
247 | if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) | 249 | if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) |
@@ -348,9 +350,9 @@ ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, | |||
348 | return 0; | 350 | return 0; |
349 | } | 351 | } |
350 | BN_CTX_start(ctx); | 352 | BN_CTX_start(ctx); |
351 | x = BN_CTX_get(ctx); | 353 | if ((x = BN_CTX_get(ctx)) == NULL) |
352 | y = BN_CTX_get(ctx); | 354 | goto err; |
353 | if (y == NULL) | 355 | if ((y = BN_CTX_get(ctx)) == NULL) |
354 | goto err; | 356 | goto err; |
355 | 357 | ||
356 | if (!BN_bin2bn(buf + 1, field_len, x)) | 358 | if (!BN_bin2bn(buf + 1, field_len, x)) |
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 7b3bb2364d..f6db4dc9b1 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.14 2015/02/08 22:25:03 miod Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.15 2015/02/09 15:49:22 jsing 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. |
@@ -188,8 +188,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group, | |||
188 | return 0; | 188 | return 0; |
189 | } | 189 | } |
190 | BN_CTX_start(ctx); | 190 | BN_CTX_start(ctx); |
191 | tmp_a = BN_CTX_get(ctx); | 191 | if ((tmp_a = BN_CTX_get(ctx)) == NULL) |
192 | if (tmp_a == NULL) | ||
193 | goto err; | 192 | goto err; |
194 | 193 | ||
195 | /* group->field */ | 194 | /* group->field */ |
@@ -294,12 +293,15 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) | |||
294 | } | 293 | } |
295 | } | 294 | } |
296 | BN_CTX_start(ctx); | 295 | BN_CTX_start(ctx); |
297 | a = BN_CTX_get(ctx); | 296 | if ((a = BN_CTX_get(ctx)) == NULL) |
298 | b = BN_CTX_get(ctx); | 297 | goto err; |
299 | tmp_1 = BN_CTX_get(ctx); | 298 | if ((b = BN_CTX_get(ctx)) == NULL) |
300 | tmp_2 = BN_CTX_get(ctx); | 299 | goto err; |
301 | order = BN_CTX_get(ctx); | 300 | if ((tmp_1 = BN_CTX_get(ctx)) == NULL) |
302 | if (order == NULL) | 301 | goto err; |
302 | if ((tmp_2 = BN_CTX_get(ctx)) == NULL) | ||
303 | goto err; | ||
304 | if ((order = BN_CTX_get(ctx)) == NULL) | ||
303 | goto err; | 305 | goto err; |
304 | 306 | ||
305 | if (group->meth->field_decode) { | 307 | if (group->meth->field_decode) { |
@@ -539,11 +541,13 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN | |||
539 | return 0; | 541 | return 0; |
540 | } | 542 | } |
541 | BN_CTX_start(ctx); | 543 | BN_CTX_start(ctx); |
542 | Z = BN_CTX_get(ctx); | 544 | if ((Z = BN_CTX_get(ctx)) == NULL) |
543 | Z_1 = BN_CTX_get(ctx); | 545 | goto err; |
544 | Z_2 = BN_CTX_get(ctx); | 546 | if ((Z_1 = BN_CTX_get(ctx)) == NULL) |
545 | Z_3 = BN_CTX_get(ctx); | 547 | goto err; |
546 | if (Z_3 == NULL) | 548 | if ((Z_2 = BN_CTX_get(ctx)) == NULL) |
549 | goto err; | ||
550 | if ((Z_3 = BN_CTX_get(ctx)) == NULL) | ||
547 | goto err; | 551 | goto err; |
548 | 552 | ||
549 | /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ | 553 | /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ |
@@ -652,14 +656,19 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons | |||
652 | return 0; | 656 | return 0; |
653 | } | 657 | } |
654 | BN_CTX_start(ctx); | 658 | BN_CTX_start(ctx); |
655 | n0 = BN_CTX_get(ctx); | 659 | if ((n0 = BN_CTX_get(ctx)) == NULL) |
656 | n1 = BN_CTX_get(ctx); | 660 | goto end; |
657 | n2 = BN_CTX_get(ctx); | 661 | if ((n1 = BN_CTX_get(ctx)) == NULL) |
658 | n3 = BN_CTX_get(ctx); | 662 | goto end; |
659 | n4 = BN_CTX_get(ctx); | 663 | if ((n2 = BN_CTX_get(ctx)) == NULL) |
660 | n5 = BN_CTX_get(ctx); | 664 | goto end; |
661 | n6 = BN_CTX_get(ctx); | 665 | if ((n3 = BN_CTX_get(ctx)) == NULL) |
662 | if (n6 == NULL) | 666 | goto end; |
667 | if ((n4 = BN_CTX_get(ctx)) == NULL) | ||
668 | goto end; | ||
669 | if ((n5 = BN_CTX_get(ctx)) == NULL) | ||
670 | goto end; | ||
671 | if ((n6 = BN_CTX_get(ctx)) == NULL) | ||
663 | goto end; | 672 | goto end; |
664 | 673 | ||
665 | /* | 674 | /* |
@@ -834,11 +843,13 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C | |||
834 | return 0; | 843 | return 0; |
835 | } | 844 | } |
836 | BN_CTX_start(ctx); | 845 | BN_CTX_start(ctx); |
837 | n0 = BN_CTX_get(ctx); | 846 | if ((n0 = BN_CTX_get(ctx)) == NULL) |
838 | n1 = BN_CTX_get(ctx); | 847 | goto err; |
839 | n2 = BN_CTX_get(ctx); | 848 | if ((n1 = BN_CTX_get(ctx)) == NULL) |
840 | n3 = BN_CTX_get(ctx); | 849 | goto err; |
841 | if (n3 == NULL) | 850 | if ((n2 = BN_CTX_get(ctx)) == NULL) |
851 | goto err; | ||
852 | if ((n3 = BN_CTX_get(ctx)) == NULL) | ||
842 | goto err; | 853 | goto err; |
843 | 854 | ||
844 | /* | 855 | /* |
@@ -990,11 +1001,13 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX | |||
990 | return -1; | 1001 | return -1; |
991 | } | 1002 | } |
992 | BN_CTX_start(ctx); | 1003 | BN_CTX_start(ctx); |
993 | rh = BN_CTX_get(ctx); | 1004 | if ((rh = BN_CTX_get(ctx)) == NULL) |
994 | tmp = BN_CTX_get(ctx); | 1005 | goto err; |
995 | Z4 = BN_CTX_get(ctx); | 1006 | if ((tmp = BN_CTX_get(ctx)) == NULL) |
996 | Z6 = BN_CTX_get(ctx); | 1007 | goto err; |
997 | if (Z6 == NULL) | 1008 | if ((Z4 = BN_CTX_get(ctx)) == NULL) |
1009 | goto err; | ||
1010 | if ((Z6 = BN_CTX_get(ctx)) == NULL) | ||
998 | goto err; | 1011 | goto err; |
999 | 1012 | ||
1000 | /* | 1013 | /* |
@@ -1101,11 +1114,13 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b | |||
1101 | return -1; | 1114 | return -1; |
1102 | } | 1115 | } |
1103 | BN_CTX_start(ctx); | 1116 | BN_CTX_start(ctx); |
1104 | tmp1 = BN_CTX_get(ctx); | 1117 | if ((tmp1 = BN_CTX_get(ctx)) == NULL) |
1105 | tmp2 = BN_CTX_get(ctx); | 1118 | goto end; |
1106 | Za23 = BN_CTX_get(ctx); | 1119 | if ((tmp2 = BN_CTX_get(ctx)) == NULL) |
1107 | Zb23 = BN_CTX_get(ctx); | 1120 | goto end; |
1108 | if (Zb23 == NULL) | 1121 | if ((Za23 = BN_CTX_get(ctx)) == NULL) |
1122 | goto end; | ||
1123 | if ((Zb23 = BN_CTX_get(ctx)) == NULL) | ||
1109 | goto end; | 1124 | goto end; |
1110 | 1125 | ||
1111 | /* | 1126 | /* |
@@ -1184,9 +1199,9 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx | |||
1184 | return 0; | 1199 | return 0; |
1185 | } | 1200 | } |
1186 | BN_CTX_start(ctx); | 1201 | BN_CTX_start(ctx); |
1187 | x = BN_CTX_get(ctx); | 1202 | if ((x = BN_CTX_get(ctx)) == NULL) |
1188 | y = BN_CTX_get(ctx); | 1203 | goto err; |
1189 | if (y == NULL) | 1204 | if ((y = BN_CTX_get(ctx)) == NULL) |
1190 | goto err; | 1205 | goto err; |
1191 | 1206 | ||
1192 | if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) | 1207 | if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) |
@@ -1225,9 +1240,9 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * | |||
1225 | return 0; | 1240 | return 0; |
1226 | } | 1241 | } |
1227 | BN_CTX_start(ctx); | 1242 | BN_CTX_start(ctx); |
1228 | tmp0 = BN_CTX_get(ctx); | 1243 | if ((tmp0 = BN_CTX_get(ctx)) == NULL) |
1229 | tmp1 = BN_CTX_get(ctx); | 1244 | goto err; |
1230 | if (tmp0 == NULL || tmp1 == NULL) | 1245 | if ((tmp1 = BN_CTX_get(ctx)) == NULL) |
1231 | goto err; | 1246 | goto err; |
1232 | 1247 | ||
1233 | /* | 1248 | /* |