mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add ecp_keypair struct, init/free and constants
This commit is contained in:
@ -91,6 +91,25 @@ typedef struct
|
||||
}
|
||||
ecp_group;
|
||||
|
||||
/**
|
||||
* \brief ECP key pair structure
|
||||
*
|
||||
* A generic key pair that could be used for ECDSA, fixed ECDH, etc.
|
||||
* Usage can be restricted to a particular algorithm by the 'alg' field,
|
||||
* see POLARSSL_ECP_KEY_ALG_* constants (default: unrestricted).
|
||||
*
|
||||
* \sa ecdh_context
|
||||
* \sa ecdsa_context
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecp_group grp; /*!< Elliptic curve and base point */
|
||||
mpi d; /*!< our secret value */
|
||||
ecp_point Q; /*!< our public value */
|
||||
int alg; /*!< algorithm to use this key with */
|
||||
}
|
||||
ecp_keypair;
|
||||
|
||||
/**
|
||||
* RFC 5114 defines a number of standardized ECP groups for use with TLS.
|
||||
*
|
||||
@ -139,6 +158,16 @@ ecp_group;
|
||||
*/
|
||||
#define POLARSSL_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */
|
||||
|
||||
/*
|
||||
* Algorithm identifiers from RFC 5480 for use with EC keys
|
||||
*/
|
||||
#define POLARSSL_ECP_KEY_ALG_UNRESTRICTED 0 /**< RFC 5480 2.1.1 */
|
||||
#define POLARSSL_ECP_KEY_ALG_ECDH 1 /**< RFC 5480 2.1.2 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Initialize a point (as zero)
|
||||
*/
|
||||
@ -149,6 +178,11 @@ void ecp_point_init( ecp_point *pt );
|
||||
*/
|
||||
void ecp_group_init( ecp_group *grp );
|
||||
|
||||
/**
|
||||
* \brief Initialize a key pair (as an invalid one)
|
||||
*/
|
||||
void ecp_keypair_init( ecp_keypair *key );
|
||||
|
||||
/**
|
||||
* \brief Free the components of a point
|
||||
*/
|
||||
@ -159,6 +193,11 @@ void ecp_point_free( ecp_point *pt );
|
||||
*/
|
||||
void ecp_group_free( ecp_group *grp );
|
||||
|
||||
/**
|
||||
* \brief Free the components of a key pair
|
||||
*/
|
||||
void ecp_keypair_free( ecp_keypair *key );
|
||||
|
||||
/**
|
||||
* \brief Set a point to zero
|
||||
*
|
||||
|
Reference in New Issue
Block a user