diff options
author | Werner Koch <[email protected]> | 2017-11-06 13:20:03 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-11-06 14:11:24 +0000 |
commit | 3607ab2cf382296cb398a92d5ec792239960bf7b (patch) | |
tree | 731aa73c483a0bdb8faa38346c82e6df488cc38e /agent/protect.c | |
parent | agent: New option --s2k-count. (diff) | |
download | gnupg-3607ab2cf382296cb398a92d5ec792239960bf7b.tar.gz gnupg-3607ab2cf382296cb398a92d5ec792239960bf7b.zip |
agent: New GETINFO sub-commands "s2k_count_cal" and "s2k_time".
* agent/command.c (cmd_getinfo): New sub-commands.
* agent/protect.c (get_standard_s2k_count): Factor some code out to ...
(get_calibrated_s2k_count): new.
(get_standard_s2k_time): New.
Signed-off-by: Werner Koch <[email protected]>
(cherry picked from commit 52d41c8b0f4af6278d18d8935399ddad16a26856)
Diffstat (limited to 'agent/protect.c')
-rw-r--r-- | agent/protect.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/agent/protect.c b/agent/protect.c index ab26220f5..3073fc4de 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -191,16 +191,13 @@ calibrate_s2k_count (void) } - -/* Return the standard S2K count. */ +/* Return the calibrated S2K count. This is only public for the use + * of the Assuan getinfo s2k_count_cal command. */ unsigned long -get_standard_s2k_count (void) +get_calibrated_s2k_count (void) { static unsigned long count; - if (opt.s2k_count) - return opt.s2k_count < 65536 ? 65536 : opt.s2k_count; - if (!count) count = calibrate_s2k_count (); @@ -209,6 +206,26 @@ get_standard_s2k_count (void) } +/* Return the standard S2K count. */ +unsigned long +get_standard_s2k_count (void) +{ + if (opt.s2k_count) + return opt.s2k_count < 65536 ? 65536 : opt.s2k_count; + + return get_calibrated_s2k_count (); +} + + +/* Return the milliseconds required for the standard S2K + * operation. */ +unsigned long +get_standard_s2k_time (void) +{ + return calibrate_s2k_count_one (get_standard_s2k_count ()); +} + + /* Same as get_standard_s2k_count but return the count in the encoding as described by rfc4880. */ unsigned char |