Fix EC_POINT_bn2point() for BN_zero()
authorNicola Tuveri <nic.tuv@gmail.com>
Fri, 1 Nov 2019 20:38:21 +0000 (22:38 +0200)
committerNicola Tuveri <nic.tuv@gmail.com>
Wed, 13 Nov 2019 16:02:51 +0000 (18:02 +0200)
commitd47c10875656790d146f62ac3c437db54c58dbf7
tree8b417caa42e95923210717ca5dff8368d342bcc2
parenta7372f592220853740305b468be7c6caf7945524
Fix EC_POINT_bn2point() for BN_zero()

EC_POINT_bn2point() rejected BIGNUMs with a zero value.

This behavior indirectly caused failures when converting a point
at infinity through EC_POINT_point2hex() and then back to a point with
EC_POINT_hex2point().

With this change such BIGNUMs are treated like any other and exported to
an octet buffer filled with zero.
It is then EC_POINT_oct2point() (either the default implementation or
the custom one in group->meth->oct2point) to determine if such encoding
maps to a valid point (generally the point at infinity is encoded as
0x00).

Fixes #10258

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10329)
crypto/ec/ec_print.c