Change PBKDF interface API.

Prepare API for PBKDF that can set three costs
  - time (similar to iterations in PBKDF2)
  - memory (required memory for memory-hard function)
  - threads (required number of threads/CPUs).

This patch also removes wrongly designed API call
crypt_benchmark_kdf and replaces it with the new call
crypt_benchmark_pbkdf.

Two functions for PBKDF per context setting
are introduced: crypt_set_pbkdf_type and crypt_get_pbkdf_type.

The patch should be backward compatible when using
crypt_set_iteration_time function (works only for PBKDF2).

Signed-off-by: Milan Broz <gmazyland@gmail.com>
This commit is contained in:
Milan Broz
2017-08-05 20:34:50 +02:00
parent 09d14a0b6c
commit 0abf57be5d
13 changed files with 341 additions and 80 deletions

View File

@@ -60,7 +60,7 @@ int crypt_backend_rng(char *buffer, size_t length, int quality, int fips);
int crypt_pbkdf_check(const char *kdf, const char *hash,
const char *password, size_t password_length,
const char *salt, size_t salt_length,
size_t key_length, uint64_t *iter_secs);
size_t key_length, uint32_t *iter_secs);
int crypt_pbkdf(const char *kdf, const char *hash,
const char *password, size_t password_length,
const char *salt, size_t salt_length,

View File

@@ -55,7 +55,7 @@ static long time_ms(struct rusage *start, struct rusage *end)
int crypt_pbkdf_check(const char *kdf, const char *hash,
const char *password, size_t password_length,
const char *salt, size_t salt_length,
size_t key_length, uint64_t *iter_secs)
size_t key_length, uint32_t *iter_secs)
{
struct rusage rstart, rend;
int r = 0, step = 0;