mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Merge branch 'development-restricted' into iotssl-1260-non-blocking-ecc-restricted
* development-restricted: (578 commits)
Update library version number to 2.13.1
Don't define _POSIX_C_SOURCE in header file
Don't declare and define gmtime()-mutex on Windows platforms
Correct preprocessor guards determining use of gmtime()
Correct documentation of mbedtls_platform_gmtime_r()
Correct typo in documentation of mbedtls_platform_gmtime_r()
Correct POSIX version check to determine presence of gmtime_r()
Improve documentation of mbedtls_platform_gmtime_r()
platform_utils.{c/h} -> platform_util.{c/h}
Don't include platform_time.h if !MBEDTLS_HAVE_TIME
Improve wording of documentation of MBEDTLS_PLATFORM_GMTIME_R_ALT
Fix typo in documentation of MBEDTLS_PLATFORM_GMTIME_R_ALT
Replace 'thread safe' by 'thread-safe' in the documentation
Improve documentation of MBEDTLS_HAVE_TIME_DATE
ChangeLog: Add missing renamings gmtime -> gmtime_r
Improve documentation of MBEDTLS_HAVE_TIME_DATE
Minor documentation improvements
Style: Add missing period in documentation in threading.h
Rename mbedtls_platform_gmtime() to mbedtls_platform_gmtime_r()
Guard decl and use of gmtime mutex by HAVE_TIME_DATE and !GMTIME_ALT
...
This commit is contained in:
commit
125af948c3
241 changed files with 18474 additions and 5839 deletions
|
|
@ -107,6 +107,8 @@ int main( void )
|
|||
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
|
||||
#define DFL_HS_TO_MIN 0
|
||||
#define DFL_HS_TO_MAX 0
|
||||
#define DFL_DTLS_MTU -1
|
||||
#define DFL_DGRAM_PACKING 1
|
||||
#define DFL_FALLBACK -1
|
||||
#define DFL_EXTENDED_MS -1
|
||||
#define DFL_ETM -1
|
||||
|
|
@ -199,7 +201,11 @@ int main( void )
|
|||
#define USAGE_DTLS \
|
||||
" dtls=%%d default: 0 (TLS)\n" \
|
||||
" hs_timeout=%%d-%%d default: (library default: 1000-60000)\n" \
|
||||
" range of DTLS handshake timeouts in millisecs\n"
|
||||
" range of DTLS handshake timeouts in millisecs\n" \
|
||||
" mtu=%%d default: (library default: unlimited)\n" \
|
||||
" dgram_packing=%%d default: 1 (allowed)\n" \
|
||||
" allow or forbid packing of multiple\n" \
|
||||
" records within a single datgram.\n"
|
||||
#else
|
||||
#define USAGE_DTLS ""
|
||||
#endif
|
||||
|
|
@ -254,8 +260,12 @@ int main( void )
|
|||
" server_addr=%%s default: given by name\n" \
|
||||
" server_port=%%d default: 4433\n" \
|
||||
" request_page=%%s default: \".\"\n" \
|
||||
" request_size=%%d default: about 34 (basic request)\n" \
|
||||
" (minimum: 0, max: " MAX_REQUEST_SIZE_STR " )\n" \
|
||||
" request_size=%%d default: about 34 (basic request)\n" \
|
||||
" (minimum: 0, max: " MAX_REQUEST_SIZE_STR ")\n" \
|
||||
" If 0, in the first exchange only an empty\n" \
|
||||
" application data message is sent followed by\n" \
|
||||
" a second non-empty message before attempting\n" \
|
||||
" to read a response from the server\n" \
|
||||
" debug_level=%%d default: 0 (disabled)\n" \
|
||||
" nbio=%%d default: 0 (blocking I/O)\n" \
|
||||
" options: 1 (non-blocking), 2 (added delays)\n" \
|
||||
|
|
@ -351,7 +361,9 @@ struct options
|
|||
int transport; /* TLS or DTLS? */
|
||||
uint32_t hs_to_min; /* Initial value of DTLS handshake timer */
|
||||
uint32_t hs_to_max; /* Max value of DTLS handshake timer */
|
||||
int dtls_mtu; /* UDP Maximum tranport unit for DTLS */
|
||||
int fallback; /* is this a fallback connection? */
|
||||
int dgram_packing; /* allow/forbid datagram packing */
|
||||
int extended_ms; /* negotiate extended master secret? */
|
||||
int etm; /* negotiate encrypt then mac? */
|
||||
} opt;
|
||||
|
|
@ -624,9 +636,11 @@ int main( int argc, char *argv[] )
|
|||
opt.transport = DFL_TRANSPORT;
|
||||
opt.hs_to_min = DFL_HS_TO_MIN;
|
||||
opt.hs_to_max = DFL_HS_TO_MAX;
|
||||
opt.dtls_mtu = DFL_DTLS_MTU;
|
||||
opt.fallback = DFL_FALLBACK;
|
||||
opt.extended_ms = DFL_EXTENDED_MS;
|
||||
opt.etm = DFL_ETM;
|
||||
opt.dgram_packing = DFL_DGRAM_PACKING;
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
|
|
@ -936,6 +950,21 @@ int main( int argc, char *argv[] )
|
|||
if( opt.hs_to_min == 0 || opt.hs_to_max < opt.hs_to_min )
|
||||
goto usage;
|
||||
}
|
||||
else if( strcmp( p, "mtu" ) == 0 )
|
||||
{
|
||||
opt.dtls_mtu = atoi( q );
|
||||
if( opt.dtls_mtu < 0 )
|
||||
goto usage;
|
||||
}
|
||||
else if( strcmp( p, "dgram_packing" ) == 0 )
|
||||
{
|
||||
opt.dgram_packing = atoi( q );
|
||||
if( opt.dgram_packing != 0 &&
|
||||
opt.dgram_packing != 1 )
|
||||
{
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
else if( strcmp( p, "recsplit" ) == 0 )
|
||||
{
|
||||
opt.recsplit = atoi( q );
|
||||
|
|
@ -1336,6 +1365,9 @@ int main( int argc, char *argv[] )
|
|||
if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX )
|
||||
mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min,
|
||||
opt.hs_to_max );
|
||||
|
||||
if( opt.dgram_packing != DFL_DGRAM_PACKING )
|
||||
mbedtls_ssl_set_datagram_packing( &ssl, opt.dgram_packing );
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
|
|
@ -1494,6 +1526,11 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_net_send, mbedtls_net_recv,
|
||||
opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
if( opt.dtls_mtu != DFL_DTLS_MTU )
|
||||
mbedtls_ssl_set_mtu( &ssl, opt.dtls_mtu );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay,
|
||||
mbedtls_timing_get_delay );
|
||||
|
|
@ -1688,10 +1725,13 @@ send_request:
|
|||
|
||||
if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM )
|
||||
{
|
||||
for( written = 0, frags = 0; written < len; written += ret, frags++ )
|
||||
written = 0;
|
||||
frags = 0;
|
||||
|
||||
do
|
||||
{
|
||||
while( ( ret = mbedtls_ssl_write( &ssl, buf + written,
|
||||
len - written ) ) <= 0 )
|
||||
len - written ) ) < 0 )
|
||||
{
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_SSL_WANT_WRITE &&
|
||||
|
|
@ -1712,7 +1752,11 @@ send_request:
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
frags++;
|
||||
written += ret;
|
||||
}
|
||||
while( written < len );
|
||||
}
|
||||
else /* Not stream, so datagram */
|
||||
{
|
||||
|
|
@ -1761,6 +1805,13 @@ send_request:
|
|||
mbedtls_printf( " %d bytes written in %d fragments\n\n%s\n",
|
||||
written, frags, (char *) buf );
|
||||
|
||||
/* Send a non-empty request if request_size == 0 */
|
||||
if ( len == 0 )
|
||||
{
|
||||
opt.request_size = DFL_REQUEST_SIZE;
|
||||
goto send_request;
|
||||
}
|
||||
|
||||
/*
|
||||
* 7. Read the HTTP response
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue