mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-08 14:49:59 -04:00
Merge pull request #8798 from ivq/8665-backport
Backport 2.28: Reduce many unnecessary static memory consumption
This commit is contained in:
commit
ede909f99a
@ -535,10 +535,10 @@ static inline void ecp_mpi_load(mbedtls_mpi *X, const mbedtls_mpi_uint *p, size_
|
|||||||
*/
|
*/
|
||||||
static inline void ecp_mpi_set1(mbedtls_mpi *X)
|
static inline void ecp_mpi_set1(mbedtls_mpi *X)
|
||||||
{
|
{
|
||||||
static mbedtls_mpi_uint one[] = { 1 };
|
static const mbedtls_mpi_uint one[] = { 1 };
|
||||||
X->s = 1;
|
X->s = 1;
|
||||||
X->n = 1;
|
X->n = 1;
|
||||||
X->p = one;
|
X->p = (mbedtls_mpi_uint *) one; /* X->p will not be modified so the cast is safe */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1348,7 +1348,7 @@ cleanup:
|
|||||||
*/
|
*/
|
||||||
#define P_KOBLITZ_MAX (256 / 8 / sizeof(mbedtls_mpi_uint)) // Max limbs in P
|
#define P_KOBLITZ_MAX (256 / 8 / sizeof(mbedtls_mpi_uint)) // Max limbs in P
|
||||||
#define P_KOBLITZ_R (8 / sizeof(mbedtls_mpi_uint)) // Limbs in R
|
#define P_KOBLITZ_R (8 / sizeof(mbedtls_mpi_uint)) // Limbs in R
|
||||||
static inline int ecp_mod_koblitz(mbedtls_mpi *N, mbedtls_mpi_uint *Rp, size_t p_limbs,
|
static inline int ecp_mod_koblitz(mbedtls_mpi *N, const mbedtls_mpi_uint *Rp, size_t p_limbs,
|
||||||
size_t adjust, size_t shift, mbedtls_mpi_uint mask)
|
size_t adjust, size_t shift, mbedtls_mpi_uint mask)
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
@ -1362,7 +1362,7 @@ static inline int ecp_mod_koblitz(mbedtls_mpi *N, mbedtls_mpi_uint *Rp, size_t p
|
|||||||
|
|
||||||
/* Init R */
|
/* Init R */
|
||||||
R.s = 1;
|
R.s = 1;
|
||||||
R.p = Rp;
|
R.p = (mbedtls_mpi_uint *) Rp; /* R.p will not be modified so the cast is safe */
|
||||||
R.n = P_KOBLITZ_R;
|
R.n = P_KOBLITZ_R;
|
||||||
|
|
||||||
/* Common setup for M */
|
/* Common setup for M */
|
||||||
@ -1433,7 +1433,7 @@ cleanup:
|
|||||||
*/
|
*/
|
||||||
static int ecp_mod_p192k1(mbedtls_mpi *N)
|
static int ecp_mod_p192k1(mbedtls_mpi *N)
|
||||||
{
|
{
|
||||||
static mbedtls_mpi_uint Rp[] = {
|
static const mbedtls_mpi_uint Rp[] = {
|
||||||
MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00,
|
MBEDTLS_BYTES_TO_T_UINT_8(0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||||
0x00)
|
0x00)
|
||||||
};
|
};
|
||||||
@ -1450,7 +1450,7 @@ static int ecp_mod_p192k1(mbedtls_mpi *N)
|
|||||||
*/
|
*/
|
||||||
static int ecp_mod_p224k1(mbedtls_mpi *N)
|
static int ecp_mod_p224k1(mbedtls_mpi *N)
|
||||||
{
|
{
|
||||||
static mbedtls_mpi_uint Rp[] = {
|
static const mbedtls_mpi_uint Rp[] = {
|
||||||
MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00,
|
MBEDTLS_BYTES_TO_T_UINT_8(0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||||
0x00)
|
0x00)
|
||||||
};
|
};
|
||||||
@ -1472,7 +1472,7 @@ static int ecp_mod_p224k1(mbedtls_mpi *N)
|
|||||||
*/
|
*/
|
||||||
static int ecp_mod_p256k1(mbedtls_mpi *N)
|
static int ecp_mod_p256k1(mbedtls_mpi *N)
|
||||||
{
|
{
|
||||||
static mbedtls_mpi_uint Rp[] = {
|
static const mbedtls_mpi_uint Rp[] = {
|
||||||
MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00,
|
MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||||
0x00)
|
0x00)
|
||||||
};
|
};
|
||||||
|
@ -5254,7 +5254,7 @@ const mbedtls_ssl_session *mbedtls_ssl_get_session_pointer(const mbedtls_ssl_con
|
|||||||
(SSL_SERIALIZED_SESSION_CONFIG_ETM << SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT) | \
|
(SSL_SERIALIZED_SESSION_CONFIG_ETM << SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT) | \
|
||||||
(SSL_SERIALIZED_SESSION_CONFIG_TICKET << SSL_SERIALIZED_SESSION_CONFIG_TICKET_BIT)))
|
(SSL_SERIALIZED_SESSION_CONFIG_TICKET << SSL_SERIALIZED_SESSION_CONFIG_TICKET_BIT)))
|
||||||
|
|
||||||
static unsigned char ssl_serialized_session_header[] = {
|
static const unsigned char ssl_serialized_session_header[] = {
|
||||||
MBEDTLS_VERSION_MAJOR,
|
MBEDTLS_VERSION_MAJOR,
|
||||||
MBEDTLS_VERSION_MINOR,
|
MBEDTLS_VERSION_MINOR,
|
||||||
MBEDTLS_VERSION_PATCH,
|
MBEDTLS_VERSION_PATCH,
|
||||||
@ -6123,7 +6123,7 @@ void mbedtls_ssl_session_free(mbedtls_ssl_session *session)
|
|||||||
(SSL_SERIALIZED_CONTEXT_CONFIG_ALPN << SSL_SERIALIZED_CONTEXT_CONFIG_ALPN_BIT) | \
|
(SSL_SERIALIZED_CONTEXT_CONFIG_ALPN << SSL_SERIALIZED_CONTEXT_CONFIG_ALPN_BIT) | \
|
||||||
0u))
|
0u))
|
||||||
|
|
||||||
static unsigned char ssl_serialized_context_header[] = {
|
static const unsigned char ssl_serialized_context_header[] = {
|
||||||
MBEDTLS_VERSION_MAJOR,
|
MBEDTLS_VERSION_MAJOR,
|
||||||
MBEDTLS_VERSION_MINOR,
|
MBEDTLS_VERSION_MINOR,
|
||||||
MBEDTLS_VERSION_PATCH,
|
MBEDTLS_VERSION_PATCH,
|
||||||
@ -6821,7 +6821,7 @@ void mbedtls_ssl_config_init(mbedtls_ssl_config *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||||
static int ssl_preset_default_hashes[] = {
|
static const int ssl_preset_default_hashes[] = {
|
||||||
#if defined(MBEDTLS_SHA512_C)
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
MBEDTLS_MD_SHA512,
|
MBEDTLS_MD_SHA512,
|
||||||
#endif
|
#endif
|
||||||
@ -6839,14 +6839,14 @@ static int ssl_preset_default_hashes[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ssl_preset_suiteb_ciphersuites[] = {
|
static const int ssl_preset_suiteb_ciphersuites[] = {
|
||||||
MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||||
MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||||
static int ssl_preset_suiteb_hashes[] = {
|
static const int ssl_preset_suiteb_hashes[] = {
|
||||||
MBEDTLS_MD_SHA256,
|
MBEDTLS_MD_SHA256,
|
||||||
MBEDTLS_MD_SHA384,
|
MBEDTLS_MD_SHA384,
|
||||||
MBEDTLS_MD_NONE
|
MBEDTLS_MD_NONE
|
||||||
@ -6854,7 +6854,7 @@ static int ssl_preset_suiteb_hashes[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_C)
|
#if defined(MBEDTLS_ECP_C)
|
||||||
static mbedtls_ecp_group_id ssl_preset_suiteb_curves[] = {
|
static const mbedtls_ecp_group_id ssl_preset_suiteb_curves[] = {
|
||||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||||
MBEDTLS_ECP_DP_SECP256R1,
|
MBEDTLS_ECP_DP_SECP256R1,
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user