diff options
author | Werner Koch <wk@gnupg.org> | 2017-11-06 14:20:03 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2017-11-06 15:03:06 +0100 |
commit | 52d41c8b0f4af6278d18d8935399ddad16a26856 (patch) | |
tree | 01b301ebe37b13766e2cd190e7e8b11400d7fe7e /agent/protect.c | |
parent | agent: New option --s2k-count. (diff) | |
download | gnupg2-52d41c8b0f4af6278d18d8935399ddad16a26856.tar.xz gnupg2-52d41c8b0f4af6278d18d8935399ddad16a26856.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 <wk@gnupg.org>
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 9b4ba9143..fe44f18c3 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 |