mbed TLS Build
tests/suites/test_suite_ssl.function@0:cdf462088d13, 2017-01-05 (annotated)
- Committer:
- markrad
- Date:
- Thu Jan 05 00:18:44 2017 +0000
- Revision:
- 0:cdf462088d13
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 0:cdf462088d13 | 1 | /* BEGIN_HEADER */ |
markrad | 0:cdf462088d13 | 2 | #include <mbedtls/ssl.h> |
markrad | 0:cdf462088d13 | 3 | #include <mbedtls/ssl_internal.h> |
markrad | 0:cdf462088d13 | 4 | /* END_HEADER */ |
markrad | 0:cdf462088d13 | 5 | |
markrad | 0:cdf462088d13 | 6 | /* BEGIN_DEPENDENCIES |
markrad | 0:cdf462088d13 | 7 | * depends_on:MBEDTLS_SSL_TLS_C |
markrad | 0:cdf462088d13 | 8 | * END_DEPENDENCIES |
markrad | 0:cdf462088d13 | 9 | */ |
markrad | 0:cdf462088d13 | 10 | |
markrad | 0:cdf462088d13 | 11 | /* BEGIN_CASE depends_on:MBEDTLS_SSL_DTLS_ANTI_REPLAY */ |
markrad | 0:cdf462088d13 | 12 | void ssl_dtls_replay( char *prevs, char *new, int ret ) |
markrad | 0:cdf462088d13 | 13 | { |
markrad | 0:cdf462088d13 | 14 | mbedtls_ssl_context ssl; |
markrad | 0:cdf462088d13 | 15 | mbedtls_ssl_config conf; |
markrad | 0:cdf462088d13 | 16 | char *end_prevs = prevs + strlen( prevs ) + 1; |
markrad | 0:cdf462088d13 | 17 | |
markrad | 0:cdf462088d13 | 18 | mbedtls_ssl_init( &ssl ); |
markrad | 0:cdf462088d13 | 19 | mbedtls_ssl_config_init( &conf ); |
markrad | 0:cdf462088d13 | 20 | |
markrad | 0:cdf462088d13 | 21 | TEST_ASSERT( mbedtls_ssl_config_defaults( &conf, |
markrad | 0:cdf462088d13 | 22 | MBEDTLS_SSL_IS_CLIENT, |
markrad | 0:cdf462088d13 | 23 | MBEDTLS_SSL_TRANSPORT_DATAGRAM, |
markrad | 0:cdf462088d13 | 24 | MBEDTLS_SSL_PRESET_DEFAULT ) == 0 ); |
markrad | 0:cdf462088d13 | 25 | TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 ); |
markrad | 0:cdf462088d13 | 26 | |
markrad | 0:cdf462088d13 | 27 | /* Read previous record numbers */ |
markrad | 0:cdf462088d13 | 28 | for( ; end_prevs - prevs >= 13; prevs += 13 ) |
markrad | 0:cdf462088d13 | 29 | { |
markrad | 0:cdf462088d13 | 30 | prevs[12] = '\0'; |
markrad | 0:cdf462088d13 | 31 | unhexify( ssl.in_ctr + 2, prevs ); |
markrad | 0:cdf462088d13 | 32 | mbedtls_ssl_dtls_replay_update( &ssl ); |
markrad | 0:cdf462088d13 | 33 | } |
markrad | 0:cdf462088d13 | 34 | |
markrad | 0:cdf462088d13 | 35 | /* Check new number */ |
markrad | 0:cdf462088d13 | 36 | unhexify( ssl.in_ctr + 2, new ); |
markrad | 0:cdf462088d13 | 37 | TEST_ASSERT( mbedtls_ssl_dtls_replay_check( &ssl ) == ret ); |
markrad | 0:cdf462088d13 | 38 | |
markrad | 0:cdf462088d13 | 39 | mbedtls_ssl_free( &ssl ); |
markrad | 0:cdf462088d13 | 40 | mbedtls_ssl_config_free( &conf ); |
markrad | 0:cdf462088d13 | 41 | } |
markrad | 0:cdf462088d13 | 42 | /* END_CASE */ |