aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-06-15 10:28:55 +0000
committerWerner Koch <[email protected]>2023-07-05 10:04:08 +0000
commitbd545346b50a88cb72484488a3a9602f31b508b4 (patch)
tree32536c8fdcc82a947a637959e1c9cbabb7558118
parentgpgsm: Print PROGRESS status lines. (diff)
downloadgnupg-bd545346b50a88cb72484488a3a9602f31b508b4.tar.gz
gnupg-bd545346b50a88cb72484488a3a9602f31b508b4.zip
gpgsm: New option --input-size-hint.
* sm/gpgsm.c (oInputSizeHint): New. (opts): Add "--input-size-hint". (main): Set option. * sm/server.c (option_handler): Add option "input-size-hint". * sm/gpgsm.h (struct server_control_s): Add field input_size_hint. * sm/encrypt.c (gpgsm_encrypt): Set the toatl file size. * sm/decrypt.c (gpgsm_decrypt): Ditto. * sm/sign.c (gpgsm_sign): Ditto. * sm/verify.c (gpgsm_verify): Ditto. -- This option allows to set a value for the progress output line. Note that as of now there is no other way to set the file size. GnuPG-bug-id: 6534
-rw-r--r--NEWS3
-rw-r--r--doc/gpgsm.texi10
-rw-r--r--sm/decrypt.c2
-rw-r--r--sm/encrypt.c2
-rw-r--r--sm/gpgsm.c6
-rw-r--r--sm/gpgsm.h5
-rw-r--r--sm/server.c4
-rw-r--r--sm/sign.c2
-rw-r--r--sm/verify.c2
9 files changed, 35 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index c13006e9c..a3058e931 100644
--- a/NEWS
+++ b/NEWS
@@ -19,7 +19,8 @@ Noteworthy changes in version 2.2.42 (unreleased)
* gpgsm: Support ECC certificates. [T6253]
- * gpg: Make progress work for large files on Windows. [T6534]
+ * gpgsm: Print PROGRESS status lines. Add new --input-size-hint.
+ [T6534]
* gpgsm: Also announce AES256-CBC in signatures. [rGaa397fdcdb21]
diff --git a/doc/gpgsm.texi b/doc/gpgsm.texi
index 82450d2b1..ce689cffd 100644
--- a/doc/gpgsm.texi
+++ b/doc/gpgsm.texi
@@ -536,6 +536,13 @@ Assume the input data is plain base-64 encoded.
@opindex assume-binary
Assume the input data is binary encoded.
+@item --input-size-hint @var{n}
+@opindex input-size-hint
+This option can be used to tell GPGSM the size of the input data in
+bytes. @var{n} must be a positive base-10 number. It is used by the
+@option{--status-fd} line ``PROGRESS'' to provide a value for
+``total'' if that is not available by other means.
+
@anchor{option --p12-charset}
@item --p12-charset @var{name}
@opindex p12-charset
@@ -1702,6 +1709,9 @@ If @var{value} is true or @var{value} is not given all network access
is disabled for this session. This is the same as the command line
option @option{--disable-dirmngr}.
+@item input-size-hint
+This is the same as the @option{--input-size-hint} command line option.
+
@end table
@mansect see also
diff --git a/sm/decrypt.c b/sm/decrypt.c
index 9f8175c75..99422425c 100644
--- a/sm/decrypt.c
+++ b/sm/decrypt.c
@@ -1117,6 +1117,8 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
}
gnupg_ksba_set_progress_cb (b64writer, gpgsm_progress_cb, ctrl);
+ if (ctrl->input_size_hint)
+ gnupg_ksba_set_total (b64writer, ctrl->input_size_hint);
rc = ksba_cms_new (&cms);
if (rc)
diff --git a/sm/encrypt.c b/sm/encrypt.c
index ed5cd2f90..fc104db1d 100644
--- a/sm/encrypt.c
+++ b/sm/encrypt.c
@@ -673,6 +673,8 @@ gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int data_fd, estream_t out_fp)
}
gnupg_ksba_set_progress_cb (b64writer, gpgsm_progress_cb, ctrl);
+ if (ctrl->input_size_hint)
+ gnupg_ksba_set_total (b64writer, ctrl->input_size_hint);
err = ksba_cms_new (&cms);
if (err)
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index ffa5a55a7..4606c5aa9 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -134,6 +134,7 @@ enum cmd_and_opt_values {
oAssumeArmor,
oAssumeBase64,
oAssumeBinary,
+ oInputSizeHint,
oBase64,
oNoArmor,
@@ -310,6 +311,7 @@ static ARGPARSE_OPTS opts[] = {
N_("assume input is in base-64 format")),
ARGPARSE_s_n (oAssumeBinary, "assume-binary",
N_("assume input is in binary format")),
+ ARGPARSE_s_s (oInputSizeHint, "input-size-hint", "@"),
ARGPARSE_header ("Output", N_("Options controlling the output")),
@@ -1148,6 +1150,10 @@ main ( int argc, char **argv)
ctrl.is_base64 = 0;
break;
+ case oInputSizeHint:
+ ctrl.input_size_hint = string_to_u64 (pargs.r.ret_str);
+ break;
+
case oDisableCRLChecks:
opt.no_crl_check = 1;
break;
diff --git a/sm/gpgsm.h b/sm/gpgsm.h
index 5790a64f4..a7cbb2381 100644
--- a/sm/gpgsm.h
+++ b/sm/gpgsm.h
@@ -211,6 +211,11 @@ struct server_control_s
int is_pem; /* Is in PEM format */
int is_base64; /* is in plain base-64 format */
+ /* If > 0 a hint with the expected number of input data bytes. This
+ * is not necessary an exact number but intended to be used for
+ * progress info and to decide on how to allocate buffers. */
+ uint64_t input_size_hint;
+
int create_base64; /* Create base64 encoded output */
int create_pem; /* create PEM output */
const char *pem_name; /* PEM name to use */
diff --git a/sm/server.c b/sm/server.c
index dc1bce246..6503217bc 100644
--- a/sm/server.c
+++ b/sm/server.c
@@ -301,6 +301,10 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
opt.request_origin = i;
}
}
+ else if (!strcmp (key, "input-size-hint"))
+ {
+ ctrl->input_size_hint = string_to_u64 (value);
+ }
else
err = gpg_error (GPG_ERR_UNKNOWN_OPTION);
diff --git a/sm/sign.c b/sm/sign.c
index 5b442b9a7..0dfd15864 100644
--- a/sm/sign.c
+++ b/sm/sign.c
@@ -362,6 +362,8 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
}
gnupg_ksba_set_progress_cb (b64writer, gpgsm_progress_cb, ctrl);
+ if (ctrl->input_size_hint)
+ gnupg_ksba_set_total (b64writer, ctrl->input_size_hint);
err = ksba_cms_new (&cms);
if (err)
diff --git a/sm/verify.c b/sm/verify.c
index 8fc073c2f..6840ed16b 100644
--- a/sm/verify.c
+++ b/sm/verify.c
@@ -154,6 +154,8 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp)
}
gnupg_ksba_set_progress_cb (b64writer, gpgsm_progress_cb, ctrl);
+ if (ctrl->input_size_hint)
+ gnupg_ksba_set_total (b64writer, ctrl->input_size_hint);
rc = ksba_cms_new (&cms);
if (rc)