From aa9a15833e713f66da53c2a857082697b1a7eddc Mon Sep 17 00:00:00 2001 From: Chien Wong Date: Wed, 9 Aug 2023 12:33:40 +0800 Subject: [PATCH] Fix doc Signed-off-by: Chien Wong --- include/mbedtls/ecp.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index cd7fd26e2..a89d4d23c 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -196,21 +196,25 @@ mbedtls_ecp_point; * cardinality is denoted by \p N. Our code requires that \p N is an * odd prime as mbedtls_ecp_mul() requires an odd number, and * mbedtls_ecdsa_sign() requires that it is prime for blinding purposes. + * * The default implementation only initializes \p A without setting it to the * authentic value for curves with A = -3(SECP256R1, etc), in which - * case you need to load and free \p A by yourself when using domain parameters - * directly, for example: + * case you need to load \p A by yourself when using domain parameters directly, + * for example: * \code + * mbedtls_mpi_init(&A); * mbedtls_ecp_group_init(&grp); * CHECK_RETURN(mbedtls_ecp_group_load(&grp, grp_id)); * if (mbedtls_ecp_group_a_is_minus_3(&grp)) { - * CHECK_RETURN(mbedtls_mpi_sub_int(&grp.A, &grp.P, 3); + * CHECK_RETURN(mbedtls_mpi_sub_int(&A, &grp.P, 3)); + * } else { + * CHECK_RETURN(mbedtls_mpi_copy(&A, &grp.A)); * } * - * access_grp_A_etc(&grp); + * do_something_with_a(&A); * * cleanup: - * mbedtls_mpi_free(&grp.A); + * mbedtls_mpi_free(&A); * mbedtls_ecp_group_free(&grp); * \endcode * @@ -242,9 +246,9 @@ typedef struct mbedtls_ecp_group { mbedtls_mpi P; /*!< The prime modulus of the base field. */ mbedtls_mpi A; /*!< For Short Weierstrass: \p A in the equation. Note that \p A is not set to the authentic value in some cases. - For Montgomery curves: (A + 2) / 4. - Refer to detailed description of mbedtls_ecp_group if - using domain parameters in the structure. */ + Refer to detailed description of ::mbedtls_ecp_group if + using domain parameters in the structure. + For Montgomery curves: (A + 2) / 4. */ mbedtls_mpi B; /*!< For Short Weierstrass: \p B in the equation. For Montgomery curves: unused. */ mbedtls_ecp_point G; /*!< The generator of the subgroup used. */