mbedtls_ecp_set_public_key() function
Set the public key in a key pair object.
Arguments
grp_id
The ECP group identifier.
key
The key pair object. It must be initialized. If its group has already been set, it must match \p grp_id. If its group has not been set, it will be set to \p grp_id. If the public key has already been set, it is overwritten.
Q
The public key to copy. This must be a point on the curve indicated by \p grp_id.
Return value
\c 0 on success. #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p key does not match \p grp_id. #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the operation for the group is not implemented. #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. Another negative error code on other kinds of failure.
Notes
This function does not check that the point actually belongs to the given group. Call mbedtls_ecp_check_pubkey() on \p Q before calling this function to check that. This function does not check that the public key matches the private key that is already in \p key, if any. To check the consistency of the resulting key pair object, call mbedtls_ecp_check_pub_priv() after setting both the public key and the private key.
mbedtls_ecp_set_public_key() calls 2 functions:
![]()
mbedtls_ecp_set_public_key()
mbedtls_ecp_set_public_key() reads 3 variables:
![]()
mbedtls_ecp_set_public_key()