mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 00:49:04 +08:00
Add cookie parsing tests to test_suite_ssl
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
c8183cc492
commit
cfb01948c8
@ -2296,4 +2296,12 @@ int mbedtls_ssl_validate_ciphersuite(
|
|||||||
int mbedtls_ssl_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf,
|
int mbedtls_ssl_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf,
|
||||||
const unsigned char *end, size_t *out_len );
|
const unsigned char *end, size_t *out_len );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
int ssl_check_dtls_clihlo_cookie(
|
||||||
|
mbedtls_ssl_context *ssl,
|
||||||
|
const unsigned char *cli_id, size_t cli_id_len,
|
||||||
|
const unsigned char *in, size_t in_len,
|
||||||
|
unsigned char *obuf, size_t buf_len, size_t *olen );
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ssl_misc.h */
|
#endif /* ssl_misc.h */
|
||||||
|
@ -3149,7 +3149,10 @@ void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl )
|
|||||||
* return MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED
|
* return MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED
|
||||||
* - otherwise return a specific error code
|
* - otherwise return a specific error code
|
||||||
*/
|
*/
|
||||||
static int ssl_check_dtls_clihlo_cookie(
|
#if !defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
static
|
||||||
|
#endif
|
||||||
|
int ssl_check_dtls_clihlo_cookie(
|
||||||
mbedtls_ssl_context *ssl,
|
mbedtls_ssl_context *ssl,
|
||||||
const unsigned char *cli_id, size_t cli_id_len,
|
const unsigned char *cli_id, size_t cli_id_len,
|
||||||
const unsigned char *in, size_t in_len,
|
const unsigned char *in, size_t in_len,
|
||||||
|
@ -3366,3 +3366,21 @@ raw_key_agreement_fail:0
|
|||||||
|
|
||||||
Raw key agreement: bad server key
|
Raw key agreement: bad server key
|
||||||
raw_key_agreement_fail:1
|
raw_key_agreement_fail:1
|
||||||
|
|
||||||
|
Cookie parsing: nominal run
|
||||||
|
cookie_parsing:"16fefd0000000000000000002F010000de000000000000011efefd7b7272727272727272727272727272727272727272727272727272727272727d00200000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_SSL_INTERNAL_ERROR
|
||||||
|
|
||||||
|
Cookie parsing: cookie_len overflow
|
||||||
|
cookie_parsing:"16fefd000000000000000000ea010000de000000000000011efefd7b7272727272727272727272727272727272727272727272727272727272727db97b7373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737db963":MBEDTLS_ERR_SSL_DECODE_ERROR
|
||||||
|
|
||||||
|
Cookie parsing: non-zero fragment offset
|
||||||
|
cookie_parsing:"16fefd00000000000000000032010000de000072000000011efefd7b7272727272727272727272727272727272727272727272727272727272727d01730143":MBEDTLS_ERR_SSL_DECODE_ERROR
|
||||||
|
|
||||||
|
Cookie parsing: sid_len overflow
|
||||||
|
cookie_parsing:"16fefd00000000000000000032010000de000000000000011efefd7b7272727272727272727272727272727272727272727272727272727272727dFF730143":MBEDTLS_ERR_SSL_DECODE_ERROR
|
||||||
|
|
||||||
|
Cookie parsing: record too short
|
||||||
|
cookie_parsing:"16fefd0000000000000000002f010000de000072000000011efefd7b7272727272727272727272727272727272727272727272727272727272727dFF":MBEDTLS_ERR_SSL_DECODE_ERROR
|
||||||
|
|
||||||
|
Cookie parsing: one byte overread
|
||||||
|
cookie_parsing:"16fefd0000000000000000002F010000de000000000000011efefd7b7272727272727272727272727272727272727272727272727272727272727d0001":MBEDTLS_ERR_SSL_DECODE_ERROR
|
||||||
|
@ -5506,6 +5506,33 @@ void conf_group()
|
|||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */
|
||||||
|
void cookie_parsing( data_t *cookie, int exp_ret )
|
||||||
|
{
|
||||||
|
mbedtls_ssl_context ssl;
|
||||||
|
mbedtls_ssl_config conf;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
mbedtls_ssl_init( &ssl );
|
||||||
|
mbedtls_ssl_config_init( &conf );
|
||||||
|
TEST_EQUAL( mbedtls_ssl_config_defaults( &conf, MBEDTLS_SSL_IS_SERVER,
|
||||||
|
MBEDTLS_SSL_TRANSPORT_DATAGRAM,
|
||||||
|
MBEDTLS_SSL_PRESET_DEFAULT ),
|
||||||
|
0 );
|
||||||
|
|
||||||
|
TEST_EQUAL( mbedtls_ssl_setup( &ssl, &conf ), 0 );
|
||||||
|
TEST_EQUAL( ssl_check_dtls_clihlo_cookie( &ssl, ssl.cli_id, ssl.cli_id_len,
|
||||||
|
cookie->x, cookie->len,
|
||||||
|
ssl.out_buf,
|
||||||
|
MBEDTLS_SSL_OUT_CONTENT_LEN,
|
||||||
|
&len ),
|
||||||
|
exp_ret );
|
||||||
|
|
||||||
|
mbedtls_ssl_free( &ssl );
|
||||||
|
mbedtls_ssl_config_free( &conf );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_TIMING_C:MBEDTLS_HAVE_TIME */
|
/* BEGIN_CASE depends_on:MBEDTLS_TIMING_C:MBEDTLS_HAVE_TIME */
|
||||||
void timing_final_delay_accessor( )
|
void timing_final_delay_accessor( )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user