Mailing List Archive

[PATCH v2] mpi: Fix error that point not uninitialized
* cipher/ecc-curves.c (mpi_ec_get_elliptic_curve): Initialize E->G poing

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
cipher/ecc-curves.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
index 1592d23a..92850ac7 100644
--- a/cipher/ecc-curves.c
+++ b/cipher/ecc-curves.c
@@ -1058,6 +1058,7 @@ mpi_ec_get_elliptic_curve (elliptic_curve_t *E, int *r_flags,
goto leave;
if (G)
{
+ _gcry_mpi_point_init (&E->G);
mpi_point_set (&E->G, G->x, G->y, G->z);
mpi_point_set (G, NULL, NULL, NULL);
mpi_point_release (G);
--
2.17.1


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: [PATCH v2] mpi: Fix error that point not uninitialized [ In reply to ]
On Wed, 8 Jan 2020 21:36, Tianjia Zhang said:
> * cipher/ecc-curves.c (mpi_ec_get_elliptic_curve): Initialize E->G poing

Do you have a bug report for this or how did you stepped on this?


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
Re: [PATCH v2] mpi: Fix error that point not uninitialized [ In reply to ]
On 2020/5/7 3:08, Werner Koch wrote:
> On Wed, 8 Jan 2020 21:36, Tianjia Zhang said:
>> * cipher/ecc-curves.c (mpi_ec_get_elliptic_curve): Initialize E->G poing
>
> Do you have a bug report for this or how did you stepped on this?
>
>
> Shalom-Salam,
>
> Werner
>

This was discovered when I developed the sm2 algorithm before. Calling
_gcry_mpi_ec_internal_new() to generate an ec from ecc_domain_parms_t
will cause a crash. It seems that there is no such usage in the existing
code. For details, please refer to the earliest patch of sm2, Of course,
this patch is not accepted.

https://lists.gnupg.org/pipermail/gcrypt-devel/2019-December/004862.html

Thanks and best,
Tianjia

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel