Fixed Windows compilation failure
[oweals/openssl.git] / crypto / ecdh / ech_ossl.c
index 2a40ff12dfa8c29c4624e49bb668f2c5d0eebbbf..fa98eb11cefc0e10420cee5fa4e1297359c5ee06 100644 (file)
@@ -137,6 +137,18 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                }
 
        group = EC_KEY_get0_group(ecdh);
+
+       if (EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH)
+               {
+               if (!EC_GROUP_get_cofactor(group, x, ctx) ||
+                       !BN_mul(x, x, priv_key, ctx))
+                       {
+                       ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
+                       goto err;
+                       }
+               priv_key = x;
+               }
+
        if ((tmp=EC_POINT_new(group)) == NULL)
                {
                ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE);
@@ -157,6 +169,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                        goto err;
                        }
                }
+#ifndef OPENSSL_NO_EC2M
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) 
@@ -165,6 +178,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                        goto err;
                        }
                }
+#endif
 
        buflen = (EC_GROUP_get_degree(group) + 7)/8;
        len = BN_num_bytes(x);