Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame^] | 1 | /* BEGIN_HEADER */ |
| 2 | #include "mbedtls/poly1305.h" |
| 3 | #include <stddef.h> |
| 4 | /* END_HEADER */ |
| 5 | |
| 6 | /* BEGIN_CASE depends_on:MBEDTLS_POLY1305_C */ |
| 7 | void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src_string ) |
| 8 | { |
| 9 | unsigned char src_str[10000]; |
| 10 | unsigned char mac_str[100]; |
| 11 | unsigned char key[32]; |
| 12 | unsigned char mac[16]; |
| 13 | size_t src_len; |
| 14 | |
| 15 | memset(src_str, 0x00, 10000); |
| 16 | memset(mac_str, 0x00, 100); |
| 17 | memset(key, 0x00, 32); |
| 18 | memset(mac, 0x00, 16); |
| 19 | |
| 20 | src_len = unhexify( src_str, hex_src_string ); |
| 21 | unhexify( key, hex_key_string ); |
| 22 | |
| 23 | mbedtls_poly1305_mac( key, src_len, src_str, mac ); |
| 24 | hexify( mac_str, mac, 16 ); |
| 25 | |
| 26 | TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 ); |
| 27 | } |
| 28 | /* END_CASE */ |
| 29 | |
| 30 | /* BEGIN_CASE depends_on:MBEDTLS_POLY1305_C:MBEDTLS_SELF_TEST */ |
| 31 | void poly1305_selftest() |
| 32 | { |
| 33 | TEST_ASSERT( mbedtls_poly1305_self_test( 0 ) == 0 ); |
| 34 | } |
| 35 | /* END_CASE */ |