blob: 326f22d3b2fbfcfb8fc54c4aaf020790b02d4833 [file] [log] [blame]
Gilles Peskine7dc97042020-02-26 19:48:43 +01001/* BEGIN_HEADER */
2#include <mbedtls/ssl.h>
3#include <mbedtls/ssl_internal.h>
4/* END_HEADER */
5
6/* BEGIN_DEPENDENCIES
7 * depends_on:MBEDTLS_SSL_TLS_C
8 * END_DEPENDENCIES
9 */
10
11/* BEGIN_CASE depends_on:MBEDTLS_SSL_DTLS_ANTI_REPLAY */
12void ssl_dtls_replay( data_t * prevs, data_t * new, int ret )
13{
14 uint32_t len = 0;
15 mbedtls_ssl_context ssl;
16 mbedtls_ssl_config conf;
17
18 mbedtls_ssl_init( &ssl );
19 mbedtls_ssl_config_init( &conf );
20
21 TEST_ASSERT( mbedtls_ssl_config_defaults( &conf,
22 MBEDTLS_SSL_IS_CLIENT,
23 MBEDTLS_SSL_TRANSPORT_DATAGRAM,
24 MBEDTLS_SSL_PRESET_DEFAULT ) == 0 );
25 TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
26
27 /* Read previous record numbers */
28 for( len = 0; len < prevs->len; len += 6 )
29 {
30 memcpy( ssl.in_ctr + 2, prevs->x + len, 6 );
31 mbedtls_ssl_dtls_replay_update( &ssl );
32 }
33
34 /* Check new number */
35 memcpy( ssl.in_ctr + 2, new->x, 6 );
36 TEST_ASSERT( mbedtls_ssl_dtls_replay_check( &ssl ) == ret );
37
38 mbedtls_ssl_free( &ssl );
39 mbedtls_ssl_config_free( &conf );
40}
41/* END_CASE */
42
43/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
44void ssl_set_hostname_twice( char *hostname0, char *hostname1 )
45{
46 mbedtls_ssl_context ssl;
47 mbedtls_ssl_init( &ssl );
48
49 TEST_ASSERT( mbedtls_ssl_set_hostname( &ssl, hostname0 ) == 0 );
50 TEST_ASSERT( mbedtls_ssl_set_hostname( &ssl, hostname1 ) == 0 );
51
52 mbedtls_ssl_free( &ssl );
53}
54/* END_CASE */