mbedtls/tests/suites/test_suite_cmac.function
Simon Butcher 69283e51d5 Clean up and minor fixes following review
Minor fixes following review including:
    * formatting changes including indentation and code style
    * corrections
    * removal of debug code
    * clarification of code through variable renaming
    * memory leak
    * compiler warnings
2016-10-06 12:49:58 +01:00

37 lines
934 B
Text

/* BEGIN_HEADER */
#include "mbedtls/cipher.h"
#include "mbedtls/cmac.h"
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_CMAC_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void mbedtls_cmac_self_test( )
{
TEST_ASSERT( mbedtls_cmac_self_test( 1 ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE */
void mbedtls_cmac_setkey( int cipher_type, int key_size,
int result )
{
const mbedtls_cipher_info_t *cipher_info;
unsigned char key[32];
unsigned char buf[16];
unsigned char tmp[16];
memset( key, 0x2A, sizeof( key ) );
TEST_ASSERT( (unsigned) key_size <= 8 * sizeof( key ) );
TEST_ASSERT( ( cipher_info = mbedtls_cipher_info_from_type( cipher_type ) )
!= NULL );
TEST_ASSERT( result == mbedtls_cipher_cmac( cipher_info, key, key_size,
buf, 16, tmp ) );
}
/* END_CASE */