Arm Mbed OS support forum

Use Mbedtls_ecp_point_read_binary parse public key get error

I use Mbedtls_ecp_gen_keypair to generate a pair of public private keys, and use the Mbedtls_ecp_point_write_binary function (format=MBEDTLS_ECP_PF_COMPRESSED) derived the public key as: 0348F8DB4C4F1D76F7FF445B840BCA1194D53C7BBA1AE466ADAA2C592CDB7E3DBC, as the public key of the server;

When the client calculates the shared key, it prompts mbedtls_err_ecp_feature_unavailable when the server public key is imported using Mbedtls_ecp_point_read_binary;

Looking at the function implementation, you find that the following checks do not pass:
if (Buf[0]!= 0x04)
Return (mbedtls_err_ecp_feature_unavailable)

See this API only supports the non-compressed format(fisrt byte is 0x04) not support compressed format(fisrt byte is 0x02 or 0x03) of the public key.

how to import this public key, thank you!

Hi @Ryantcf
Thank yo for your query!

Yes, compressed point is not currently supported by mbedtls_ecp_point_read_binary()
The following PRs address your issue.(Note they haven’t been reviewed and merged yet, and might take some time for them to make it in ). You can look at them for more information:

Mbed TLS Team member

Thank you!

I would also like to ask, when is this feature planned to be incorporated into the version? Thank you!

Hi Tang,
Unfortunately, We don’t publish our roadmap.
As you can see, we have many PRs in the backlog. Although we are working on them, it does take time.

It doesn’t matter, thank you very much for your reply.