mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-30 00:46:22 -04:00
Add compile time initilaizers to ECDH and bignum structs
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
parent
280e22518e
commit
f840b3a2c0
@ -95,6 +95,14 @@ typedef struct mbedtls_ecdh_context_mbed {
|
|||||||
} mbedtls_ecdh_context_mbed;
|
} mbedtls_ecdh_context_mbed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
#define MBEDTLS_ECDH_CTX_MBED_INIT {MBEDTLS_ECP_GROUP_INIT, MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, MBEDTLS_ECP_RESTART_INIT}
|
||||||
|
#else
|
||||||
|
#define MBEDTLS_ECDH_CTX_MBED_INIT {MBEDTLS_ECP_GROUP_INIT, MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* \warning Performing multiple operations concurrently on the same
|
* \warning Performing multiple operations concurrently on the same
|
||||||
@ -141,6 +149,32 @@ typedef struct mbedtls_ecdh_context {
|
|||||||
}
|
}
|
||||||
mbedtls_ecdh_context;
|
mbedtls_ecdh_context;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {MBEDTLS_ECP_GROUP_INIT, MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, 0, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT,0, MBEDTLS_ECP_RESTART_INIT}
|
||||||
|
#else
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {MBEDTLS_ECP_GROUP_INIT, MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, 0, MBEDTLS_ECP_POINT_INIT, \
|
||||||
|
MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT}
|
||||||
|
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||||
|
#else
|
||||||
|
#if !defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {0, MBEDTLS_ECP_DP_NONE, MBEDTLS_ECDH_VARIANT_NONE, MBEDTLS_ECDH_CTX_MBED_INIT, MBEDTLS_ECDH_CTX_MBED_INIT, 0}
|
||||||
|
#else
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {0, MBEDTLS_ECP_DP_NONE, MBEDTLS_ECDH_VARIANT_NONE, MBEDTLS_ECDH_CTX_MBED_INIT, MBEDTLS_ECDH_CTX_MBED_INIT}
|
||||||
|
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||||
|
#else
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {0, MBEDTLS_ECP_DP_NONE, MBEDTLS_ECDH_VARIANT_NONE, MBEDTLS_ECDH_CTX_EVEREST_INIT, MBEDTLS_ECDH_CTX_MBED_INIT, 0}
|
||||||
|
#else
|
||||||
|
#define MBEDTLS_ECDH_CTX_INIT {0, MBEDTLS_ECP_DP_NONE, MBEDTLS_ECDH_VARIANT_NONE, MBEDTLS_ECDH_CTX_EVEREST_INIT, MBEDTLS_ECDH_CTX_MBED_INIT}
|
||||||
|
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||||
|
#endif /* !MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED */
|
||||||
|
#endif /* MBEDTLS_ECDH_LEGACY_CONTEXT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return the ECP group for provided context.
|
* \brief Return the ECP group for provided context.
|
||||||
*
|
*
|
||||||
|
@ -255,6 +255,7 @@ mbedtls_ecp_group;
|
|||||||
#define MBEDTLS_ECP_GROUP_INIT { MBEDTLS_ECP_DP_NONE, MBEDTLS_MPI_INIT, MBEDTLS_MPI_INIT, \
|
#define MBEDTLS_ECP_GROUP_INIT { MBEDTLS_ECP_DP_NONE, MBEDTLS_MPI_INIT, MBEDTLS_MPI_INIT, \
|
||||||
MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, \
|
MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, \
|
||||||
0, 0, 0, NULL, NULL, NULL, NULL, NULL, 0 }
|
0, 0, 0, NULL, NULL, NULL, NULL, NULL, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name SECTION: Module settings
|
* \name SECTION: Module settings
|
||||||
*
|
*
|
||||||
@ -372,6 +373,8 @@ typedef struct {
|
|||||||
mbedtls_ecp_restart_muladd_ctx *MBEDTLS_PRIVATE(ma); /*!< ecp_muladd() sub-context */
|
mbedtls_ecp_restart_muladd_ctx *MBEDTLS_PRIVATE(ma); /*!< ecp_muladd() sub-context */
|
||||||
} mbedtls_ecp_restart_ctx;
|
} mbedtls_ecp_restart_ctx;
|
||||||
|
|
||||||
|
#define MBEDTLS_ECP_RESTART_INIT {0, 0, NULL, NULL}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Operation counts for restartable functions
|
* Operation counts for restartable functions
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +41,7 @@ typedef struct {
|
|||||||
mbedtls_x25519_context ctx;
|
mbedtls_x25519_context ctx;
|
||||||
} mbedtls_ecdh_context_everest;
|
} mbedtls_ecdh_context_everest;
|
||||||
|
|
||||||
|
#define MBEDTLS_ECDH_CTX_EVERSET_INIT {MBEDTLS_X25519_CTX_INIT}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This function sets up the ECDH context with the information
|
* \brief This function sets up the ECDH context with the information
|
||||||
|
@ -47,6 +47,8 @@ typedef struct
|
|||||||
unsigned char peer_point[MBEDTLS_X25519_KEY_SIZE_BYTES];
|
unsigned char peer_point[MBEDTLS_X25519_KEY_SIZE_BYTES];
|
||||||
} mbedtls_x25519_context;
|
} mbedtls_x25519_context;
|
||||||
|
|
||||||
|
#define MBEDTLS_X25519_CTX_INIT {{0}, {0}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This function initializes an x25519 context.
|
* \brief This function initializes an x25519 context.
|
||||||
*
|
*
|
||||||
|
@ -243,9 +243,9 @@ typedef struct {
|
|||||||
} mbedtls_psa_key_agreement_interruptible_operation_t;
|
} mbedtls_psa_key_agreement_interruptible_operation_t;
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECDH) && defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECDH) && defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
#define MBEDTLS_PSA_KEY_AGREEMENT_INTERRUPTIBLE_OPERATION_INIT { { 0 }, 0 }
|
#define MBEDTLS_PSA_KEY_AGREEMENT_IOP_INIT { MBEDTLS_ECDH_CTX_INIT, 0 }
|
||||||
#else
|
#else
|
||||||
#define MBEDTLS_PSA_KEY_AGREEMENT_INTERRUPTIBLE_OPERATION_INIT { 0 }
|
#define MBEDTLS_PSA_KEY_AGREEMENT_IOP_INIT { 0 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|
||||||
|
@ -518,7 +518,7 @@ struct psa_key_agreement_iop_s {
|
|||||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
|
||||||
#define PSA_KEY_AGREEMENT_IOP_INIT { 0 }
|
#define PSA_KEY_AGREEMENT_IOP_INIT { 0 }
|
||||||
#else
|
#else
|
||||||
#define PSA_KEY_AGREEMENT_IOP_INIT { 0, { 0 }, 0, PSA_KEY_ATTRIBUTES_INIT, 0 }
|
#define PSA_KEY_AGREEMENT_IOP_INIT { 0, MBEDTLS_PSA_KEY_AGREEMENT_IOP_INIT, 0, PSA_KEY_ATTRIBUTES_INIT, 0 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline struct psa_key_agreement_iop_s
|
static inline struct psa_key_agreement_iop_s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user