Simon Butcher | d812fa6 | 2016-10-05 14:13:31 +0100 | [diff] [blame] | 1 | /* BEGIN_HEADER */ |
| 2 | #include "mbedtls/cipher.h" |
| 3 | #include "mbedtls/cmac.h" |
| 4 | /* END_HEADER */ |
| 5 | |
| 6 | /* BEGIN_DEPENDENCIES |
| 7 | * depends_on:MBEDTLS_CMAC_C |
| 8 | * END_DEPENDENCIES |
| 9 | */ |
| 10 | |
| 11 | /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ |
| 12 | void mbedtls_cmac_self_test( ) |
| 13 | { |
| 14 | TEST_ASSERT( mbedtls_cmac_self_test( 1 ) == 0 ); |
| 15 | } |
| 16 | /* END_CASE */ |
| 17 | |
| 18 | /* BEGIN_CASE */ |
| 19 | void mbedtls_cmac_setkey( int cipher_type, int key_size, |
| 20 | int result ) |
| 21 | { |
| 22 | const mbedtls_cipher_info_t *cipher_info; |
| 23 | unsigned char key[32]; |
| 24 | unsigned char buf[16]; |
| 25 | unsigned char tmp[16]; |
| 26 | |
| 27 | memset( key, 0x2A, sizeof( key ) ); |
| 28 | TEST_ASSERT( (unsigned) key_size <= 8 * sizeof( key ) ); |
| 29 | |
| 30 | TEST_ASSERT( ( cipher_info = mbedtls_cipher_info_from_type( cipher_type ) ) |
| 31 | != NULL ); |
| 32 | |
| 33 | TEST_ASSERT( result == mbedtls_cipher_cmac( cipher_info, key, key_size, |
Simon Butcher | 69283e5 | 2016-10-06 12:49:58 +0100 | [diff] [blame] | 34 | buf, 16, tmp ) ); |
Simon Butcher | d812fa6 | 2016-10-05 14:13:31 +0100 | [diff] [blame] | 35 | } |
| 36 | /* END_CASE */ |
| 37 | |