]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ECC library bugfixes.
authorBodo Möller <bodo@openssl.org>
Thu, 26 Aug 2010 12:10:25 +0000 (12:10 +0000)
committerBodo Möller <bodo@openssl.org>
Thu, 26 Aug 2010 12:10:25 +0000 (12:10 +0000)
Submitted by: Emilia Kapser (Google)

CHANGES
crypto/ec/ec2_mult.c
crypto/ec/ec_mult.c

diff --git a/CHANGES b/CHANGES
index 95d0c375c4c2616fb335031effca32f5e9a0fc5e..75e49cc5ee1aca19f66b985c07caee2dd00d6db8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,10 @@
 
  Changes between 0.9.8o and 0.9.8p [xx XXX xxxx]
 
+  *) ec2_GF2m_simple_mul bugfix: compute correct result if the output EC_POINT
+     is also one of the inputs.
+     [Emilia Käsper <emilia.kasper@esat.kuleuven.be> (Google)]
+
   *) Don't repeatedly append PBE algorithms to table if they already exist.
      Sort table on each new add. This effectively makes the table read only
      after all algorithms are added and subsequent calls to PKCS12_pbe_add
index ff368fd7d7b3d277db18ab1884aa59201d80692a..7dca5e4bcd4364e43b6a3ec6af199f83e3e538b3 100644 (file)
@@ -318,6 +318,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
        int ret = 0;
        size_t i;
        EC_POINT *p=NULL;
+       EC_POINT *acc = NULL;
 
        if (ctx == NULL)
                {
@@ -337,15 +338,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
                }
 
        if ((p = EC_POINT_new(group)) == NULL) goto err;
+       if ((acc = EC_POINT_new(group)) == NULL) goto err;
 
-       if (!EC_POINT_set_to_infinity(group, r)) goto err;
+       if (!EC_POINT_set_to_infinity(group, acc)) goto err;
 
        if (scalar)
                {
                if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err;
-               if (BN_is_negative(scalar)) 
+               if (BN_is_negative(scalar))
                        if (!group->meth->invert(group, p, ctx)) goto err;
-               if (!group->meth->add(group, r, r, p, ctx)) goto err;
+               if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
                }
 
        for (i = 0; i < num; i++)
@@ -353,13 +355,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
                if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err;
                if (BN_is_negative(scalars[i]))
                        if (!group->meth->invert(group, p, ctx)) goto err;
-               if (!group->meth->add(group, r, r, p, ctx)) goto err;
+               if (!group->meth->add(group, acc, acc, p, ctx)) goto err;
                }
 
+       if (!EC_POINT_copy(r, acc)) goto err;
+
        ret = 1;
 
   err:
        if (p) EC_POINT_free(p);
+       if (acc) EC_POINT_free(acc);
        if (new_ctx != NULL)
                BN_CTX_free(new_ctx);
        return ret;
index 2ba173ef36422ad1c715fe3ebd5b0dc9b17cb03d..ee422697267e663e352420fcb63d6ede209afafb 100644 (file)
@@ -169,11 +169,13 @@ static void ec_pre_comp_clear_free(void *pre_)
                EC_POINT **p;
 
                for (p = pre->points; *p != NULL; p++)
+                       {
                        EC_POINT_clear_free(*p);
-               OPENSSL_cleanse(pre->points, sizeof pre->points);
+                       OPENSSL_cleanse(p, sizeof *p);
+                       }
                OPENSSL_free(pre->points);
                }
-       OPENSSL_cleanse(pre, sizeof pre);
+       OPENSSL_cleanse(pre, sizeof *pre);
        OPENSSL_free(pre);
        }