Manuel Pégourié-Gonnard | 4956fd7 | 2014-09-24 11:13:44 +0200 | [diff] [blame] | 1 | /* BEGIN_HEADER */ |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 2 | #include <mbedtls/ssl.h> |
Manuel Pégourié-Gonnard | 4956fd7 | 2014-09-24 11:13:44 +0200 | [diff] [blame] | 3 | /* END_HEADER */ |
| 4 | |
| 5 | /* BEGIN_DEPENDENCIES |
| 6 | * depends_on:POLARSSL_SSL_TLS_C |
| 7 | * END_DEPENDENCIES |
| 8 | */ |
| 9 | |
| 10 | /* BEGIN_CASE depends_on:POLARSSL_SSL_DTLS_ANTI_REPLAY */ |
| 11 | void ssl_dtls_replay( char *prevs, char *new, int ret ) |
| 12 | { |
| 13 | ssl_context ssl; |
| 14 | char *end_prevs = prevs + strlen( prevs ) + 1; |
| 15 | |
| 16 | TEST_ASSERT( ssl_init( &ssl ) == 0 ); |
| 17 | TEST_ASSERT( ssl_set_transport( &ssl, SSL_TRANSPORT_DATAGRAM ) == 0 ); |
| 18 | |
| 19 | /* Read previous record numbers */ |
| 20 | for( ; end_prevs - prevs >= 13; prevs += 13 ) |
| 21 | { |
| 22 | prevs[12] = '\0'; |
| 23 | unhexify( ssl.in_ctr + 2, prevs ); |
| 24 | ssl_dtls_replay_update( &ssl ); |
| 25 | } |
| 26 | |
| 27 | /* Check new number */ |
| 28 | unhexify( ssl.in_ctr + 2, new ); |
| 29 | TEST_ASSERT( ssl_dtls_replay_check( &ssl ) == ret ); |
| 30 | |
| 31 | ssl_free( &ssl ); |
| 32 | } |
| 33 | /* END_CASE */ |