blob: 95c4b1169b7b68af71eb515a0af550425be0b047 [file] [log] [blame]
Paul Bakker19bd2972013-06-14 12:06:45 +02001BEGIN_HEADER
2#include <polarssl/pkcs5.h>
3END_HEADER
4
5BEGIN_DEPENDENCIES
6depends_on:POLARSSL_PKCS5_C
7END_DEPENDENCIES
8
9BEGIN_CASE
10pbkdf2_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 );
35
36 hexify( dst_str, key, {key_len} );
37 TEST_ASSERT( strcmp( (char *) dst_str, {result_key_string} ) == 0 );
Manuel Pégourié-Gonnard309c7982014-11-17 11:56:08 +010038
39 md_free_ctx( &ctx );
Paul Bakker19bd2972013-06-14 12:06:45 +020040}
41END_CASE