@@ -53,9 +53,36 @@ static int check_hash(const char *hash)
5353 return EXIT_SUCCESS ;
5454}
5555
56+ static int check_pbkdf (const char * pbkdf )
57+ {
58+ const char * hash ;
59+ uint32_t iterations , memory , parallel ;
60+ char out [32 ];
61+
62+ if (!strcmp (pbkdf , "pbkdf2" )) {
63+ hash = "sha256" ;
64+ iterations = 1000 ;
65+ memory = 0 ;
66+ parallel = 0 ;
67+ } else if (!strncmp (pbkdf , "argon2" , 6 )) {
68+ hash = NULL ;
69+ iterations = 3 ;
70+ memory = 256 ;
71+ parallel = 1 ;
72+ } else
73+ return EXIT_FAILURE ;
74+
75+ if (!crypt_pbkdf (pbkdf , hash , "01234567890abcdef01234567890abcdef" , 32 ,
76+ "11234567890abcdef11234567890abcdef" , 32 , out , sizeof (out ),
77+ iterations , memory , parallel ))
78+ return EXIT_SUCCESS ;
79+
80+ return EXIT_FAILURE ;
81+ }
82+
5683static void __attribute__((noreturn )) exit_help (bool destroy_backend )
5784{
58- printf ("Use: crypto_check version | fips_mode | fips_mode_kernel | hash <alg> | cipher[-kernel] <alg> <mode> [key_bits]\n" );
85+ printf ("Use: crypto_check version | fips_mode | fips_mode_kernel | hash <alg> | cipher[-kernel] <alg> <mode> [key_bits] | pbkdf <alg> \n" );
5986 if (destroy_backend )
6087 crypt_backend_destroy ();
6188 exit (EXIT_FAILURE );
@@ -102,6 +129,10 @@ int main(int argc, char *argv[])
102129 r = check_cipher (argv [2 ], argv [3 ], ul );
103130 else
104131 r = check_cipher_kernel (argv [2 ], argv [3 ], ul );
132+ } else if (!strcmp (argv [1 ], "pbkdf" )) {
133+ if (argc != 3 )
134+ exit_help (true);
135+ r = check_pbkdf (argv [2 ]);
105136 }
106137
107138 crypt_backend_destroy ();
0 commit comments