From 3e08866e06aa1865badf869ae4af9c5a05aeff6c Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 29 May 2019 11:10:18 +0100 Subject: [PATCH] Use def'n consts for bits in config-identifier of serialized data --- library/ssl_tls.c | 51 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index b436abbd4..3a33ab45f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -9860,39 +9860,39 @@ const mbedtls_ssl_session *mbedtls_ssl_get_session_pointer( const mbedtls_ssl_co #endif /* MBEDTLS_SSL_SERIALIZED_STRUCTURES_LOCAL_ONLY */ #if defined(MBEDTLS_HAVE_TIME) -#define SSL_SERIALIZED_SESSION_CONFIG_TIME_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_TIME 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_TIME_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_TIME 0 #endif /* MBEDTLS_HAVE_TIME */ #if defined(MBEDTLS_X509_CRT_PARSE_C) -#define SSL_SERIALIZED_SESSION_CONFIG_CRT_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_CRT 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_CRT_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_CRT 0 #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_SSL_SESSION_TICKETS) -#define SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET 0 #endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_SESSION_TICKETS */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) -#define SSL_SERIALIZED_SESSION_CONFIG_MFL_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_MFL 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_MFL_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_MFL 0 #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ #if defined(MBEDTLS_SSL_TRUNCATED_HMAC) -#define SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC 0 #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) -#define SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_ETM 1 #else -#define SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_ETM 0 #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) @@ -9901,16 +9901,25 @@ const mbedtls_ssl_session *mbedtls_ssl_get_session_pointer( const mbedtls_ssl_co #define SSL_SERIALIZED_SESSION_CONFIG_TICKET 0 #endif /* MBEDTLS_SSL_SESSION_TICKETS */ +#define SSL_SERIALIZED_SESSION_CONFIG_TIME_BIT 0 +#define SSL_SERIALIZED_SESSION_CONFIG_CRT_BIT 1 +#define SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET_BIT 2 +#define SSL_SERIALIZED_SESSION_CONFIG_MFL_BIT 3 +#define SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC_BIT 4 +#define SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT 5 +#define SSL_SERIALIZED_SESSION_CONFIG_TICKET_BIT 6 +#define SSL_SERIALIZED_SESSION_CONFIG_LOCAL_BIT 7 + #define SSL_SERIALIZED_SESSION_CONFIG_BITFLAG \ - ( (uint16_t) ( ( SSL_SERIALIZED_SESSION_CONFIG_TIME_BIT << 0 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_CRT_BIT << 1 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET_BIT << 2 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_MFL_BIT << 3 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC_BIT << 4 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_ETM_BIT << 5 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_CRT << 6 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_TICKET << 7 ) | \ - ( SSL_SERIALIZED_SESSION_CONFIG_LOCAL << 8 ) ) ) + ( (uint16_t) ( \ + ( SSL_SERIALIZED_SESSION_CONFIG_TIME << SSL_SERIALIZED_SESSION_CONFIG_TIME_BIT ) | \ + ( SSL_SERIALIZED_SESSION_CONFIG_CRT << SSL_SERIALIZED_SESSION_CONFIG_CRT_BIT ) | \ + ( SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET << SSL_SERIALIZED_SESSION_CONFIG_CLIENT_TICKET_BIT ) | \ + ( SSL_SERIALIZED_SESSION_CONFIG_MFL << SSL_SERIALIZED_SESSION_CONFIG_MFL_BIT ) | \ + ( SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC << SSL_SERIALIZED_SESSION_CONFIG_TRUNC_HMAC_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_LOCAL << SSL_SERIALIZED_SESSION_CONFIG_LOCAL_BIT ) ) ) static unsigned char ssl_serialized_session_header[] = { MBEDTLS_VERSION_MAJOR,