mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-30 07:04:17 +01:00
mbedtls_ssl_handshake_params: use bytes for some small values
Replace bitfields mbedtls_ssl_handshake_params by bytes. This saves some code size, and since the bitfields weren't group, this doesn't increase the RAM usage. Replace several ints that only store values in the range 0..255 by uint8_t. This can increase or decrease the code size depending on the architecture and on how the field is used. I chose changes that save code size on Arm Thumb builds and may potentially save more after field reordering. Leave the bitfields in struct mbedtls_ssl_hs_buffer alone: replacing them by uint8_t slightly increases the code size. Results (arm-none-eabi-gcc 7.3.1, build_arm_none_eabi_gcc_m0plus build): library/ssl_srv.o: 22735 -> 22691 (diff: 44) library/ssl_tls.o: 23566 -> 23570 (diff: -4) Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
4a13ebff39
commit
51070849fa
@ -480,7 +480,7 @@ struct mbedtls_ssl_handshake_params
|
|||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_ssl_key_cert *key_cert; /*!< chosen key/cert pair (server) */
|
mbedtls_ssl_key_cert *key_cert; /*!< chosen key/cert pair (server) */
|
||||||
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
||||||
int sni_authmode; /*!< authmode from SNI callback */
|
uint8_t sni_authmode; /*!< authmode from SNI callback */
|
||||||
mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */
|
mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */
|
||||||
mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */
|
mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */
|
||||||
mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */
|
mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */
|
||||||
@ -488,8 +488,8 @@ struct mbedtls_ssl_handshake_params
|
|||||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
|
#if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
|
||||||
int ecrs_enabled; /*!< Handshake supports EC restart? */
|
|
||||||
mbedtls_x509_crt_restart_ctx ecrs_ctx; /*!< restart context */
|
mbedtls_x509_crt_restart_ctx ecrs_ctx; /*!< restart context */
|
||||||
|
uint8_t ecrs_enabled; /*!< Handshake supports EC restart? */
|
||||||
enum { /* this complements ssl->state with info on intra-state operations */
|
enum { /* this complements ssl->state with info on intra-state operations */
|
||||||
ssl_ecrs_none = 0, /*!< nothing going on (yet) */
|
ssl_ecrs_none = 0, /*!< nothing going on (yet) */
|
||||||
ssl_ecrs_crt_verify, /*!< Certificate: crt_verify() */
|
ssl_ecrs_crt_verify, /*!< Certificate: crt_verify() */
|
||||||
@ -606,21 +606,21 @@ struct mbedtls_ssl_handshake_params
|
|||||||
unsigned char premaster[MBEDTLS_PREMASTER_SIZE];
|
unsigned char premaster[MBEDTLS_PREMASTER_SIZE];
|
||||||
/*!< premaster secret */
|
/*!< premaster secret */
|
||||||
|
|
||||||
int resume; /*!< session resume indicator*/
|
uint8_t max_major_ver; /*!< max. major version client*/
|
||||||
int max_major_ver; /*!< max. major version client*/
|
uint8_t max_minor_ver; /*!< max. minor version client*/
|
||||||
int max_minor_ver; /*!< max. minor version client*/
|
uint8_t resume; /*!< session resume indicator*/
|
||||||
int cli_exts; /*!< client extension presence*/
|
uint8_t cli_exts; /*!< client extension presence*/
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
int new_session_ticket; /*!< use NewSessionTicket? */
|
uint8_t new_session_ticket; /*!< use NewSessionTicket? */
|
||||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
|
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
|
||||||
int extended_ms; /*!< use Extended Master Secret? */
|
uint8_t extended_ms; /*!< use Extended Master Secret? */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
||||||
unsigned int async_in_progress : 1; /*!< an asynchronous operation is in progress */
|
uint8_t async_in_progress; /*!< an asynchronous operation is in progress */
|
||||||
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
|
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
||||||
|
Loading…
Reference in New Issue
Block a user