mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-01 13:13:28 +00:00
Enable multi max_early_data_size value for connections
For test purpose, we set different value for each session Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
fceddb310e
commit
3c2b21ed0e
@ -122,7 +122,7 @@ int main(void)
|
|||||||
#define DFL_SNI NULL
|
#define DFL_SNI NULL
|
||||||
#define DFL_ALPN_STRING NULL
|
#define DFL_ALPN_STRING NULL
|
||||||
#define DFL_GROUPS NULL
|
#define DFL_GROUPS NULL
|
||||||
#define DFL_MAX_EARLY_DATA_SIZE 0
|
#define DFL_MAX_EARLY_DATA_SIZE NULL
|
||||||
#define DFL_SIG_ALGS NULL
|
#define DFL_SIG_ALGS NULL
|
||||||
#define DFL_DHM_FILE NULL
|
#define DFL_DHM_FILE NULL
|
||||||
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
|
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
|
||||||
@ -427,11 +427,15 @@ int main(void)
|
|||||||
#define USAGE_ECJPAKE ""
|
#define USAGE_ECJPAKE ""
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||||
|
|
||||||
|
#define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
|
||||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||||
|
|
||||||
#define USAGE_EARLY_DATA \
|
#define USAGE_EARLY_DATA \
|
||||||
" max_early_data_size=%%d default: -1 (disabled)\n" \
|
" max_early_data_size=%%d default: -1 (disabled)\n" \
|
||||||
" options: -1 (disabled), " \
|
" The max amount of 0-RTT data for 1st and 2nd connection\n" \
|
||||||
" >= 0 (enabled, max amount of early data )\n"
|
" format: 1st_connection_value[,2nd_connection_value]\n" \
|
||||||
|
" available values: < 0 (disabled), >= 0 (enabled).\n" \
|
||||||
|
" The absolute value is the max amount of 0-RTT data.\n"
|
||||||
#else
|
#else
|
||||||
#define USAGE_EARLY_DATA ""
|
#define USAGE_EARLY_DATA ""
|
||||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||||
@ -556,6 +560,7 @@ int main(void)
|
|||||||
USAGE_GROUPS \
|
USAGE_GROUPS \
|
||||||
USAGE_SIG_ALGS \
|
USAGE_SIG_ALGS \
|
||||||
USAGE_KEY_OPAQUE_ALGS \
|
USAGE_KEY_OPAQUE_ALGS \
|
||||||
|
USAGE_EARLY_DATA \
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||||
@ -693,7 +698,7 @@ struct options {
|
|||||||
const char *cid_val_renego; /* the CID to use for incoming messages
|
const char *cid_val_renego; /* the CID to use for incoming messages
|
||||||
* after renegotiation */
|
* after renegotiation */
|
||||||
int reproducible; /* make communication reproducible */
|
int reproducible; /* make communication reproducible */
|
||||||
uint32_t max_early_data_size; /* max amount of early data */
|
const char *max_early_data_size; /* max amount list of early data */
|
||||||
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 */
|
||||||
int force_srtp_profile; /* SRTP protection profile to use or all */
|
int force_srtp_profile; /* SRTP protection profile to use or all */
|
||||||
@ -1609,7 +1614,9 @@ int main(int argc, char *argv[])
|
|||||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||||
int tls13_early_data_enabled = MBEDTLS_SSL_EARLY_DATA_DISABLED;
|
long long max_early_data_size_list[2];
|
||||||
|
size_t max_early_data_size_count = 0;
|
||||||
|
size_t tls13_connection_counter = 0;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||||
mbedtls_memory_buffer_alloc_init(alloc_buf, sizeof(alloc_buf));
|
mbedtls_memory_buffer_alloc_init(alloc_buf, sizeof(alloc_buf));
|
||||||
@ -1979,12 +1986,23 @@ usage:
|
|||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||||
else if (strcmp(p, "max_early_data_size") == 0) {
|
else if (strcmp(p, "max_early_data_size") == 0) {
|
||||||
long long value = atoll(q);
|
char *endptr, *str;
|
||||||
tls13_early_data_enabled =
|
opt.max_early_data_size = q;
|
||||||
value >= 0 ? MBEDTLS_SSL_EARLY_DATA_ENABLED :
|
str = endptr = q;
|
||||||
MBEDTLS_SSL_EARLY_DATA_DISABLED;
|
for (size_t early_data_size_iter = 0;
|
||||||
if (tls13_early_data_enabled) {
|
early_data_size_iter < ARRAY_LENGTH(max_early_data_size_list);
|
||||||
opt.max_early_data_size = atoi(q);
|
early_data_size_iter++) {
|
||||||
|
long long value = strtoll(str, &endptr, 0);
|
||||||
|
if (str == endptr || (*endptr != ',' && *endptr != '\0')) {
|
||||||
|
mbedtls_printf("fail\n illegal digital number for max_early_data_size %s\n",
|
||||||
|
endptr);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
max_early_data_size_list[max_early_data_size_count++] = value;
|
||||||
|
if (*endptr == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
str = endptr + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||||
@ -2806,14 +2824,6 @@ usage:
|
|||||||
mbedtls_ssl_conf_cert_req_ca_list(&conf, opt.cert_req_ca_list);
|
mbedtls_ssl_conf_cert_req_ca_list(&conf, opt.cert_req_ca_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
|
||||||
mbedtls_ssl_conf_early_data(&conf, tls13_early_data_enabled);
|
|
||||||
if (tls13_early_data_enabled == MBEDTLS_SSL_EARLY_DATA_ENABLED) {
|
|
||||||
mbedtls_ssl_conf_max_early_data_size(
|
|
||||||
&conf, opt.max_early_data_size);
|
|
||||||
}
|
|
||||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED)
|
||||||
/* exercise setting DN hints for server certificate request
|
/* exercise setting DN hints for server certificate request
|
||||||
* (Intended for use where the client cert expected has been signed by
|
* (Intended for use where the client cert expected has been signed by
|
||||||
@ -3311,6 +3321,17 @@ usage:
|
|||||||
mbedtls_printf(" ok\n");
|
mbedtls_printf(" ok\n");
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||||
|
if (tls13_connection_counter < max_early_data_size_count) {
|
||||||
|
long long max_early_data_size = max_early_data_size_list[tls13_connection_counter];
|
||||||
|
mbedtls_ssl_conf_early_data(
|
||||||
|
&conf, max_early_data_size < 0 ? MBEDTLS_SSL_EARLY_DATA_DISABLED :
|
||||||
|
MBEDTLS_SSL_EARLY_DATA_ENABLED);
|
||||||
|
mbedtls_ssl_conf_max_early_data_size(&conf, (uint32_t) llabs(max_early_data_size));
|
||||||
|
}
|
||||||
|
tls13_connection_counter++;
|
||||||
|
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
if (received_sigterm) {
|
if (received_sigterm) {
|
||||||
mbedtls_printf(" interrupted by SIGTERM (not in net_accept())\n");
|
mbedtls_printf(" interrupted by SIGTERM (not in net_accept())\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user