Sync the early_data option with internal parameters in ssl_client2

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
This commit is contained in:
Xiaokang Qian 2023-12-06 09:24:58 +00:00
parent f8fe11d14d
commit 611c717c02

View File

@ -544,8 +544,8 @@ struct options {
int reproducible; /* make communication reproducible */ int reproducible; /* make communication reproducible */
int skip_close_notify; /* skip sending the close_notify alert */ int skip_close_notify; /* skip sending the close_notify alert */
#if defined(MBEDTLS_SSL_EARLY_DATA) #if defined(MBEDTLS_SSL_EARLY_DATA)
const char *early_data_file; /* the path of the file containing the const char *early_data; /* the path of the file containing the
* early data to send */ * early data to send */
#endif #endif
int query_config_mode; /* whether to read config */ int query_config_mode; /* whether to read config */
int use_srtp; /* Support SRTP */ int use_srtp; /* Support SRTP */
@ -914,7 +914,7 @@ int main(int argc, char *argv[])
opt.groups = DFL_GROUPS; opt.groups = DFL_GROUPS;
opt.sig_algs = DFL_SIG_ALGS; opt.sig_algs = DFL_SIG_ALGS;
#if defined(MBEDTLS_SSL_EARLY_DATA) #if defined(MBEDTLS_SSL_EARLY_DATA)
opt.early_data_file = DFL_EARLY_DATA_FILE; opt.early_data = DFL_EARLY_DATA_FILE;
#endif #endif
opt.transport = DFL_TRANSPORT; opt.transport = DFL_TRANSPORT;
opt.hs_to_min = DFL_HS_TO_MIN; opt.hs_to_min = DFL_HS_TO_MIN;
@ -1198,7 +1198,7 @@ usage:
#if defined(MBEDTLS_SSL_PROTO_TLS1_3) #if defined(MBEDTLS_SSL_PROTO_TLS1_3)
#if defined(MBEDTLS_SSL_EARLY_DATA) #if defined(MBEDTLS_SSL_EARLY_DATA)
else if (strcmp(p, "early_data") == 0) { else if (strcmp(p, "early_data") == 0) {
opt.early_data_file = q; opt.early_data = q;
} }
#endif /* MBEDTLS_SSL_EARLY_DATA */ #endif /* MBEDTLS_SSL_EARLY_DATA */
@ -1968,10 +1968,10 @@ usage:
int early_data_enabled = MBEDTLS_SSL_EARLY_DATA_DISABLED; int early_data_enabled = MBEDTLS_SSL_EARLY_DATA_DISABLED;
FILE *early_data_fp = NULL; FILE *early_data_fp = NULL;
size_t early_data_len = 0; size_t early_data_len = 0;
if (strlen(opt.early_data_file) > 0) { if (strlen(opt.early_data) > 0) {
if ((early_data_fp = fopen(opt.early_data_file, "rb")) == NULL) { if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) {
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n",
opt.early_data_file); opt.early_data);
goto exit; goto exit;
} }
early_data_len = fread(buf, 1, sizeof(buf), early_data_fp); early_data_len = fread(buf, 1, sizeof(buf), early_data_fp);