mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
DHM: new functions to query the length of the modulus
Add two functions mbedtls_dhm_get_len() and mbedtls_dhm_get_bitlen() to query the length of the modulus in bytes or bits. Remove the len field: the cost of calling mbedtls_dhm_get_len() each time it's needed is negligible, and this improves the abstraction of the DHM module. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -96,7 +96,6 @@ extern "C" {
|
||||
*/
|
||||
typedef struct mbedtls_dhm_context
|
||||
{
|
||||
size_t MBEDTLS_PRIVATE(len); /*!< The size of \p P in Bytes. */
|
||||
mbedtls_mpi MBEDTLS_PRIVATE(P); /*!< The prime modulus. */
|
||||
mbedtls_mpi MBEDTLS_PRIVATE(G); /*!< The generator. */
|
||||
mbedtls_mpi MBEDTLS_PRIVATE(X); /*!< Our secret value. */
|
||||
@ -282,6 +281,26 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
|
||||
/**
|
||||
* \brief This function returns the size of the prime modulus in bits.
|
||||
*
|
||||
* \param ctx The DHM context to query.
|
||||
*
|
||||
* \return The size of the prime modulus in bits,
|
||||
* i.e. the number n such that 2^(n-1) <= P < 2^n.
|
||||
*/
|
||||
size_t mbedtls_dhm_get_bitlen( const mbedtls_dhm_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function returns the size of the prime modulus in bytes.
|
||||
*
|
||||
* \param ctx The DHM context to query.
|
||||
*
|
||||
* \return The size of the prime modulus in bytes,
|
||||
* i.e. the number n such that 2^(8*(n-1)) <= P < 2^(8*n).
|
||||
*/
|
||||
size_t mbedtls_dhm_get_len( const mbedtls_dhm_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function frees and clears the components
|
||||
* of a DHM context.
|
||||
|
Reference in New Issue
Block a user