Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 1 | BEGIN_HEADER |
| 2 | #include <polarssl/pkcs5.h> |
| 3 | END_HEADER |
| 4 | |
| 5 | BEGIN_DEPENDENCIES |
| 6 | depends_on:POLARSSL_PKCS5_C |
| 7 | END_DEPENDENCIES |
| 8 | |
| 9 | BEGIN_CASE |
| 10 | pbkdf2_hmac:hash:hex_password_string:hex_salt_string:it_cnt:key_len:result_key_string |
| 11 | { |
| 12 | unsigned char pw_str[100]; |
| 13 | unsigned char salt_str[100]; |
| 14 | unsigned char dst_str[100]; |
| 15 | |
| 16 | md_context_t ctx; |
| 17 | const md_info_t *info; |
| 18 | |
| 19 | int pw_len, salt_len; |
| 20 | unsigned char key[100]; |
| 21 | |
| 22 | memset(pw_str, 0x00, 100); |
| 23 | memset(salt_str, 0x00, 100); |
| 24 | memset(dst_str, 0x00, 100); |
| 25 | |
| 26 | pw_len = unhexify( pw_str, {hex_password_string} ); |
| 27 | salt_len = unhexify( salt_str, {hex_salt_string} ); |
| 28 | |
| 29 | |
| 30 | info = md_info_from_type( {hash} ); |
| 31 | TEST_ASSERT( info != NULL ); |
| 32 | TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 ); |
| 33 | TEST_ASSERT( pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len, |
| 34 | {it_cnt}, {key_len}, key ) == 0 ); |
Paul Bakker | 92b8dc0 | 2013-07-03 14:45:46 +0200 | [diff] [blame^] | 35 | TEST_ASSERT( md_free_ctx( &ctx ) == 0 ); |
Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 36 | |
| 37 | hexify( dst_str, key, {key_len} ); |
| 38 | TEST_ASSERT( strcmp( (char *) dst_str, {result_key_string} ) == 0 ); |
| 39 | } |
| 40 | END_CASE |