diff --git a/src/obfs_tls.h b/src/obfs_tls.h index 29f6f2a6..8cef5c14 100644 --- a/src/obfs_tls.h +++ b/src/obfs_tls.h @@ -46,6 +46,8 @@ struct tls_client_hello { short ext_len; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_client_hello) == 138, tls_client_hello); + struct tls_ext_server_name { short ext_type; short ext_len; @@ -55,12 +57,16 @@ struct tls_ext_server_name { // char server_name[server_name_len]; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_ext_server_name) == 9, tls_ext_server_name); + struct tls_ext_session_ticket { short session_ticket_type; short session_ticket_ext_len; // char session_ticket[session_ticket_ext_len]; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_ext_session_ticket) == 4, tls_ext_session_ticket); + struct tls_ext_others { short ec_point_formats_ext_type; short ec_point_formats_ext_len; @@ -84,6 +90,8 @@ struct tls_ext_others { short extended_master_secret_ext_len; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_ext_others) == 66, tls_ext_others); + struct tls_server_hello { char content_type; short version; @@ -115,6 +123,8 @@ struct tls_server_hello { char ec_point_formats[1]; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_server_hello) == 96, tls_server_hello); + struct tls_change_cipher_spec { char content_type; short version; @@ -122,6 +132,8 @@ struct tls_change_cipher_spec { char msg; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_change_cipher_spec) == 6, tls_change_cipher_spec); + struct tls_encrypted_handshake { char content_type; short version; @@ -129,6 +141,8 @@ struct tls_encrypted_handshake { // char msg[len]; } __attribute__((packed, aligned(1))); +STATIC_ASSERT(sizeof(struct tls_encrypted_handshake) == 5, tls_encrypted_handshake); + typedef struct frame { short idx; short len; diff --git a/src/utils.h b/src/utils.h index 0fb7f5a2..4e79647c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -229,4 +229,6 @@ void *ss_realloc(void *ptr, size_t new_size); ptr = NULL; \ } while (0) +#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1] + #endif // _UTILS_H