aboutsummaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2008-12-05 16:31:39 +0000
committerWerner Koch <[email protected]>2008-12-05 16:31:39 +0000
commit5bc9948f699b70c76dc0c7c406817d077b61317d (patch)
tree2c59e77471cbf6f02fea58466c4b5544a9b74cad /sm
parentAdd option --card-timeout. (diff)
downloadgnupg-5bc9948f699b70c76dc0c7c406817d077b61317d.tar.gz
gnupg-5bc9948f699b70c76dc0c7c406817d077b61317d.zip
Add a custom prompt for the CSR generation.
Add a new percent escape fucntion.
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog11
-rw-r--r--sm/certdump.c31
-rw-r--r--sm/certreqgen.c26
3 files changed, 34 insertions, 34 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 37ef9e836..67e35f0b5 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,14 @@
+2008-12-05 Werner Koch <[email protected]>
+
+ * certreqgen.c (create_request): Provide a custom prompt for the
+ signing.
+
+ * certdump.c (gpgsm_format_keydesc): Remove debug output.
+ (gpgsm_format_keydesc): Remove saving of errno as xfree is
+ supposed not to change it. Use the new percent_plus_escape
+ function which also fixes the issue that we did not escaped a
+ percent in the past.
+
2008-11-18 Werner Koch <[email protected]>
* gpgsm.c (make_libversion): New.
diff --git a/sm/certdump.c b/sm/certdump.c
index ddfc1d120..71907d188 100644
--- a/sm/certdump.c
+++ b/sm/certdump.c
@@ -924,13 +924,12 @@ gpgsm_fpr_and_name_for_status (ksba_cert_t cert)
/* Create a key description for the CERT, this may be passed to the
- pinentry. The caller must free the returned string. NULL may be
+ pinentry. The caller must free the returned string. NULL may be
returned on error. */
char *
gpgsm_format_keydesc (ksba_cert_t cert)
{
- char *name, *subject, *buffer, *p;
- const char *s;
+ char *name, *subject, *buffer;
ksba_isotime_t t;
char created[20];
char expires[20];
@@ -939,10 +938,8 @@ gpgsm_format_keydesc (ksba_cert_t cert)
char *orig_codeset;
name = ksba_cert_get_subject (cert, 0);
- log_printhex ("XXXX NAME: ", name, strlen (name));
subject = name? gpgsm_format_name2 (name, 0) : NULL;
ksba_free (name); name = NULL;
- log_printhex ("YYYY NAME: ", subject, strlen (subject));
sexp = ksba_cert_get_serial (cert);
sn = sexp? gpgsm_format_serial (sexp) : NULL;
@@ -975,38 +972,16 @@ gpgsm_format_keydesc (ksba_cert_t cert)
if (!name)
{
- int save_errno = errno;
xfree (subject);
xfree (sn);
- errno = save_errno;
return NULL;
}
xfree (subject);
xfree (sn);
- buffer = p = xtrymalloc (strlen (name) * 3 + 1);
- for (s=name; *s; s++)
- {
- /* We also escape the quote character to work around a bug in
- the mingw32 runtime which does not correcty handle command
- line quoting. We correctly double the quote mark when
- calling a program (i.e. gpg-protect-tool), but the pre-main
- code does not notice the double quote as an escaped
- quote. */
- if (*s < ' ' || *s == '+' || *s == '\"')
- {
- sprintf (p, "%%%02X", *(unsigned char *)s);
- p += 3;
- }
- else if (*s == ' ')
- *p++ = '+';
- else
- *p++ = *s;
- }
- *p = 0;
+ buffer = percent_plus_escape (name);
xfree (name);
-
return buffer;
}
diff --git a/sm/certreqgen.c b/sm/certreqgen.c
index 30b8179fd..ca791aab8 100644
--- a/sm/certreqgen.c
+++ b/sm/certreqgen.c
@@ -788,6 +788,8 @@ create_request (ctrl_t ctrl,
gcry_sexp_release (s_pkey);
bin2hex (grip, 20, hexgrip);
+ log_info ("about to sign CSR for key: &%s\n", hexgrip);
+
if (carddirect)
rc = gpgsm_scd_pksign (ctrl, carddirect, NULL,
gcry_md_read(md, GCRY_MD_SHA1),
@@ -795,11 +797,23 @@ create_request (ctrl_t ctrl,
GCRY_MD_SHA1,
&sigval, &siglen);
else
- rc = gpgsm_agent_pksign (ctrl, hexgrip, NULL,
- gcry_md_read(md, GCRY_MD_SHA1),
- gcry_md_get_algo_dlen (GCRY_MD_SHA1),
- GCRY_MD_SHA1,
- &sigval, &siglen);
+ {
+ char *orig_codeset;
+ char *desc;
+
+ orig_codeset = i18n_switchto_utf8 ();
+ desc = percent_plus_escape
+ (_("To complete this certificate request please enter"
+ " the passphrase for the key you just created once"
+ " more.\n"));
+ i18n_switchback (orig_codeset);
+ rc = gpgsm_agent_pksign (ctrl, hexgrip, desc,
+ gcry_md_read(md, GCRY_MD_SHA1),
+ gcry_md_get_algo_dlen (GCRY_MD_SHA1),
+ GCRY_MD_SHA1,
+ &sigval, &siglen);
+ xfree (desc);
+ }
if (rc)
{
log_error ("signing failed: %s\n", gpg_strerror (rc));
@@ -818,7 +832,7 @@ create_request (ctrl_t ctrl,
}
}
while (stopreason != KSBA_SR_READY);
-
+
leave:
gcry_md_close (md);