From 297b46e65415c7d032844b39e7504bb862e2ea28 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 7 Aug 2017 10:05:53 -0700 Subject: actions: calculate password hash difficulty correctly 'fscrypt setup' is supposed to calibrate the Argon2 password hashing difficulty to 1s by default, but actually it was setting it to only 1s / num_cpus because the hashing is done with all CPUs and it is timed using the CLOCK_PROCESS_CPUTIME_ID clock, which measures the time spent by all threads in the process. Fix this by dividing the elapsed time by HashingCosts.Parallelism, which is used as the number of threads. --- actions/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/config.go b/actions/config.go index 55010a5..81f6e4f 100644 --- a/actions/config.go +++ b/actions/config.go @@ -230,7 +230,7 @@ func timeHashingCosts(costs *metadata.HashingCosts) (time.Duration, error) { } end := cpuTimeInNanoseconds() - return time.Duration(end - begin), nil + return time.Duration((end - begin) / costs.Parallelism), nil } // cpuTimeInNanoseconds returns the nanosecond count based on the process's CPU usage. -- cgit v1.2.3