mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +01:00
PKCS#5 module added. Moved PBKDF2 functionality inside and deprecated
old PBKDF2 module. (cherry picked from commit 19bd297dc896410e0d859729f9e8d4b1e107e6c8) Conflicts: include/polarssl/error.h scripts/generate_errors.pl
This commit is contained in:
parent
fc4f46fa9a
commit
b0c19a4b3d
14 changed files with 388 additions and 165 deletions
39
tests/suites/test_suite_pkcs5.function
Normal file
39
tests/suites/test_suite_pkcs5.function
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
BEGIN_HEADER
|
||||
#include <polarssl/pkcs5.h>
|
||||
END_HEADER
|
||||
|
||||
BEGIN_DEPENDENCIES
|
||||
depends_on:POLARSSL_PKCS5_C
|
||||
END_DEPENDENCIES
|
||||
|
||||
BEGIN_CASE
|
||||
pbkdf2_hmac:hash:hex_password_string:hex_salt_string:it_cnt:key_len:result_key_string
|
||||
{
|
||||
unsigned char pw_str[100];
|
||||
unsigned char salt_str[100];
|
||||
unsigned char dst_str[100];
|
||||
|
||||
md_context_t ctx;
|
||||
const md_info_t *info;
|
||||
|
||||
int pw_len, salt_len;
|
||||
unsigned char key[100];
|
||||
|
||||
memset(pw_str, 0x00, 100);
|
||||
memset(salt_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
|
||||
pw_len = unhexify( pw_str, {hex_password_string} );
|
||||
salt_len = unhexify( salt_str, {hex_salt_string} );
|
||||
|
||||
|
||||
info = md_info_from_type( {hash} );
|
||||
TEST_ASSERT( info != NULL );
|
||||
TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
|
||||
TEST_ASSERT( pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len,
|
||||
{it_cnt}, {key_len}, key ) == 0 );
|
||||
|
||||
hexify( dst_str, key, {key_len} );
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, {result_key_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
Loading…
Add table
Add a link
Reference in a new issue