Simplify identification of TLS 1.3 labels in unit test suite

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2020-09-09 12:46:09 +01:00
parent 8c82bfdf22
commit 1413bd8ae9
3 changed files with 29 additions and 26 deletions

View file

@ -28,7 +28,7 @@
#include <stdint.h>
#include <string.h>
#define MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) \
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
.name = string,
struct mbedtls_ssl_tls1_3_labels_struct const mbedtls_ssl_tls1_3_labels =

View file

@ -23,26 +23,26 @@
* the point of use. See e.g. the definition of mbedtls_ssl_tls1_3_labels_union
* below. */
#define MBEDTLS_SSL_TLS1_3_LABEL_LIST \
MBEDTLS_SSL_TLS1_3_LABEL( 0, finished , "finished" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 1, resumption , "resumption" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 2, traffic_upd , "traffic upd" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 3, exporter , "exporter" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 4, key , "key" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 5, iv , "iv" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 6, c_hs_traffic, "c hs traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 7, c_ap_traffic, "c ap traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 8, c_e_traffic , "c e traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 9, s_hs_traffic, "s hs traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 10, s_ap_traffic, "s ap traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 11, s_e_traffic , "s e traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 12, e_exp_master, "e exp master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 13, res_master , "res master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 14, exp_master , "exp master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 15, ext_binder , "ext binder" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 16, res_binder , "res binder" ) \
MBEDTLS_SSL_TLS1_3_LABEL( 17, derived , "derived" )
MBEDTLS_SSL_TLS1_3_LABEL( finished , "finished" ) \
MBEDTLS_SSL_TLS1_3_LABEL( resumption , "resumption" ) \
MBEDTLS_SSL_TLS1_3_LABEL( traffic_upd , "traffic upd" ) \
MBEDTLS_SSL_TLS1_3_LABEL( exporter , "exporter" ) \
MBEDTLS_SSL_TLS1_3_LABEL( key , "key" ) \
MBEDTLS_SSL_TLS1_3_LABEL( iv , "iv" ) \
MBEDTLS_SSL_TLS1_3_LABEL( c_hs_traffic, "c hs traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( c_ap_traffic, "c ap traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( c_e_traffic , "c e traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( s_hs_traffic, "s hs traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( s_ap_traffic, "s ap traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( s_e_traffic , "s e traffic" ) \
MBEDTLS_SSL_TLS1_3_LABEL( e_exp_master, "e exp master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( res_master , "res master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( exp_master , "exp master" ) \
MBEDTLS_SSL_TLS1_3_LABEL( ext_binder , "ext binder" ) \
MBEDTLS_SSL_TLS1_3_LABEL( res_binder , "res binder" ) \
MBEDTLS_SSL_TLS1_3_LABEL( derived , "derived" )
#define MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) \
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
const unsigned char name [ sizeof(string) - 1 ];
union mbedtls_ssl_tls1_3_labels_union

View file

@ -12,10 +12,13 @@
#include <test/constant_flow.h>
#define MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) \
const int tls1_3_label_ ## name = idx;
enum
{
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
tls1_3_label_ ## name,
MBEDTLS_SSL_TLS1_3_LABEL_LIST
#undef MBEDTLS_SSL_TLS1_3_LABEL
};
typedef struct log_pattern
{
@ -3687,8 +3690,8 @@ void ssl_tls1_3_hkdf_expand_label( int hash_alg,
unsigned char const *lbl = NULL;
size_t lbl_len;
#define MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) \
if( label_idx == tls1_3_label_ ## name ) \
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
if( label_idx == (int) tls1_3_label_ ## name ) \
{ \
lbl = mbedtls_ssl_tls1_3_labels.name; \
lbl_len = sizeof( mbedtls_ssl_tls1_3_labels.name ); \
@ -3773,8 +3776,8 @@ void ssl_tls1_3_derive_secret( int hash_alg,
unsigned char const *lbl = NULL;
size_t lbl_len;
#define MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) \
if( label_idx == tls1_3_label_ ## name ) \
#define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \
if( label_idx == (int) tls1_3_label_ ## name ) \
{ \
lbl = mbedtls_ssl_tls1_3_labels.name; \
lbl_len = sizeof( mbedtls_ssl_tls1_3_labels.name ); \