diff options
Diffstat (limited to 'lib/libcrypto/ec/ec2_smpl.c')
-rw-r--r-- | lib/libcrypto/ec/ec2_smpl.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index b9c066c5c16..43f0afd5ae9 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.13 2015/02/08 22:25:03 miod Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.14 2015/02/09 15:49:22 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -291,8 +291,7 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) } } BN_CTX_start(ctx); - b = BN_CTX_get(ctx); - if (b == NULL) + if ((b = BN_CTX_get(ctx)) == NULL) goto err; 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, return 0; } BN_CTX_start(ctx); - x0 = BN_CTX_get(ctx); - y0 = BN_CTX_get(ctx); - x1 = BN_CTX_get(ctx); - y1 = BN_CTX_get(ctx); - x2 = BN_CTX_get(ctx); - y2 = BN_CTX_get(ctx); - s = BN_CTX_get(ctx); - t = BN_CTX_get(ctx); - if (t == NULL) + if ((x0 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((y0 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((x1 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((y1 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((x2 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((y2 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((s = BN_CTX_get(ctx)) == NULL) + goto err; + if ((t = BN_CTX_get(ctx)) == NULL) goto err; 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 return -1; } BN_CTX_start(ctx); - y2 = BN_CTX_get(ctx); - lh = BN_CTX_get(ctx); - if (lh == NULL) + if ((y2 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((lh = BN_CTX_get(ctx)) == NULL) goto err; /* @@ -651,7 +656,8 @@ err: * 1 not equal */ int -ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) +ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, + const EC_POINT *b, BN_CTX *ctx) { BIGNUM *aX, *aY, *bX, *bY; BN_CTX *new_ctx = NULL; @@ -672,11 +678,13 @@ ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * return -1; } BN_CTX_start(ctx); - aX = BN_CTX_get(ctx); - aY = BN_CTX_get(ctx); - bX = BN_CTX_get(ctx); - bY = BN_CTX_get(ctx); - if (bY == NULL) + if ((aX = BN_CTX_get(ctx)) == NULL) + goto err; + if ((aY = BN_CTX_get(ctx)) == NULL) + goto err; + if ((bX = BN_CTX_get(ctx)) == NULL) + goto err; + if ((bY = BN_CTX_get(ctx)) == NULL) goto err; 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 return 0; } BN_CTX_start(ctx); - x = BN_CTX_get(ctx); - y = BN_CTX_get(ctx); - if (y == NULL) + if ((x = BN_CTX_get(ctx)) == NULL) + goto err; + if ((y = BN_CTX_get(ctx)) == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) |