提交 615614c8 编写于 作者: M Matt Caswell

Fix bug in nistp224/256/521 where have_precompute_mult always returns 0

During precomputation if the group given is well known then we memcpy a
well known precomputation. However we go the wrong label in the code and
don't store the data properly. Consequently if we call have_precompute_mult
the data isn't there and we return 0.

RT#3600
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 f5a12207
...@@ -1582,8 +1582,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -1582,8 +1582,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
*/ */
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) { if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
ret = 1; goto done;
goto err;
} }
if ((!BN_to_felem(pre->g_pre_comp[0][1][0], group->generator->X)) || if ((!BN_to_felem(pre->g_pre_comp[0][1][0], group->generator->X)) ||
(!BN_to_felem(pre->g_pre_comp[0][1][1], group->generator->Y)) || (!BN_to_felem(pre->g_pre_comp[0][1][1], group->generator->Y)) ||
...@@ -1661,6 +1660,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -1661,6 +1660,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
} }
make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_felems); make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_felems);
done:
SETPRECOMP(group, nistp224, pre); SETPRECOMP(group, nistp224, pre);
pre = NULL; pre = NULL;
ret = 1; ret = 1;
......
...@@ -2207,8 +2207,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -2207,8 +2207,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
*/ */
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) { if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
ret = 1; goto done;
goto err;
} }
if ((!BN_to_felem(x_tmp, group->generator->X)) || if ((!BN_to_felem(x_tmp, group->generator->X)) ||
(!BN_to_felem(y_tmp, group->generator->Y)) || (!BN_to_felem(y_tmp, group->generator->Y)) ||
...@@ -2295,6 +2294,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -2295,6 +2294,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
} }
make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_smallfelems); make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_smallfelems);
done:
SETPRECOMP(group, nistp256, pre); SETPRECOMP(group, nistp256, pre);
pre = NULL; pre = NULL;
ret = 1; ret = 1;
......
...@@ -2031,8 +2031,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -2031,8 +2031,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
*/ */
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) { if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp)); memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
ret = 1; goto done;
goto err;
} }
if ((!BN_to_felem(pre->g_pre_comp[1][0], group->generator->X)) || if ((!BN_to_felem(pre->g_pre_comp[1][0], group->generator->X)) ||
(!BN_to_felem(pre->g_pre_comp[1][1], group->generator->Y)) || (!BN_to_felem(pre->g_pre_comp[1][1], group->generator->Y)) ||
...@@ -2090,6 +2089,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx) ...@@ -2090,6 +2089,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
} }
make_points_affine(15, &(pre->g_pre_comp[1]), tmp_felems); make_points_affine(15, &(pre->g_pre_comp[1]), tmp_felems);
done:
SETPRECOMP(group, nistp521, pre); SETPRECOMP(group, nistp521, pre);
ret = 1; ret = 1;
pre = NULL; pre = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册