Change PBKDF insterface to allow forced iterations (time cost) count.

Also move functions to separate utils_pbkdf.c file.

PBKDF can be now set for any context.

TODO: new setting is not covered by tests.
This commit is contained in:
Milan Broz
2017-09-24 11:04:12 +02:00
parent a73bb733ff
commit 66db5b39bb
9 changed files with 325 additions and 207 deletions

View File

@@ -292,10 +292,15 @@ int crypt_benchmark_pbkdf_internal(struct crypt_device *cd,
/* Already benchmarked */
if (pbkdf->iterations) {
log_dbg("Reusing PBKDF benchmark values.");
log_dbg("Reusing PBKDF values.");
return 0;
}
if (pbkdf->flags & CRYPT_PBKDF_NO_BENCHMARK) {
log_err(cd, _("PBKDF benchmark disabled but iterations not set.\n"));
return -EINVAL;
}
if (!strcmp(pbkdf->type, CRYPT_KDF_PBKDF2)) {
/*
* For PBKDF2 it is enouch to run benchmark for only 1 second