1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

agent: compile-time configuration of s2k calibration.

* configure.ac: add --with-agent-s2k-calibration=MSEC, introduces
AGENT_S2K_CALIBRATION (measured in milliseconds)
* agent/protect.c (calibrate_s2k_count): Calibrate based on
AGENT_S2K_CALIBRATION.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
GnuPG-bug-id: 3399
(cherry picked from commit 926d07c5fa)
This commit is contained in:
Daniel Kahn Gillmor 2017-09-08 17:08:57 -04:00 committed by Werner Koch
parent e5abdb6da7
commit 0cf0f3aaf8
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 12 additions and 4 deletions

View file

@ -163,7 +163,7 @@ calibrate_s2k_count_one (unsigned long count)
/* Measure the time we need to do the hash operations and deduce an
S2K count which requires about 100ms of time. */
S2K count which requires roughly some targeted amount of time. */
static unsigned long
calibrate_s2k_count (void)
{
@ -175,11 +175,11 @@ calibrate_s2k_count (void)
ms = calibrate_s2k_count_one (count);
if (opt.verbose > 1)
log_info ("S2K calibration: %lu -> %lums\n", count, ms);
if (ms > 100)
if (ms > AGENT_S2K_CALIBRATION)
break;
}
count = (unsigned long)(((double)count / ms) * 100);
count = (unsigned long)(((double)count / ms) * AGENT_S2K_CALIBRATION);
count /= 1024;
count *= 1024;
if (count < 65536)