aboutsummaryrefslogtreecommitdiffstats
path: root/g10/call-agent.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-08-26 15:29:54 +0000
committerWerner Koch <[email protected]>2013-08-28 15:40:32 +0000
commit780ba3233618393835970bac4cf8aab713f4d7fa (patch)
tree646f0a60cff18fb3743abeecc46bb2a21877937c /g10/call-agent.c
parentagent: Fix two compiler warnings. (diff)
downloadgnupg-780ba3233618393835970bac4cf8aab713f4d7fa.tar.gz
gnupg-780ba3233618393835970bac4cf8aab713f4d7fa.zip
gpg: Make decryption with the OpenPGP card work.
* scd/app-common.h (APP_DECIPHER_INFO_NOPAD): New. * scd/app-openpgp.c (do_decipher): Add arg R_INFO. * scd/app-nks.c (do_decipher): Add arg R_INFO as a dummy. * scd/app.c (app_decipher): Add arg R_INFO. * scd/command.c (cmd_pkdecrypt): Print status line "PADDING". * agent/call-scd.c (padding_info_cb): New. (agent_card_pkdecrypt): Add arg R_PADDING. * agent/divert-scd.c (divert_pkdecrypt): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Ditto. * agent/command.c (cmd_pkdecrypt): Print status line "PADDING". * g10/call-agent.c (padding_info_cb): New. (agent_pkdecrypt): Add arg R_PADDING. * g10/pubkey-enc.c (get_it): Use padding info. -- Decryption using a card never worked in gpg 2.1 because the information whether the pkcs#1 padding needs to be removed was not available. Gpg < 2.1 too this info from the secret sub key but that has gone in 2.1. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r--g10/call-agent.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 17290ec1a..4ce6a06ab 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -1816,17 +1816,34 @@ inq_ciphertext_cb (void *opaque, const char *line)
}
+/* Check whether there is any padding info from the agent. */
+static gpg_error_t
+padding_info_cb (void *opaque, const char *line)
+{
+ int *r_padding = opaque;
+ const char *s;
+
+ if ((s=has_leading_keyword (line, "PADDING")))
+ {
+ *r_padding = atoi (s);
+ }
+
+ return 0;
+}
+
+
/* Call the agent to do a decrypt operation using the key identified
by the hex string KEYGRIP and the input data S_CIPHERTEXT. On the
success the decoded value is stored verbatim at R_BUF and its
length at R_BUF; the callers needs to release it. KEYID, MAINKEYID
and PUBKEY_ALGO are used to construct additional promots or status
- messages. */
+ messages. The padding information is stored at R_PADDING with -1
+ for not known. */
gpg_error_t
agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
u32 *keyid, u32 *mainkeyid, int pubkey_algo,
gcry_sexp_t s_ciphertext,
- unsigned char **r_buf, size_t *r_buflen)
+ unsigned char **r_buf, size_t *r_buflen, int *r_padding)
{
gpg_error_t err;
char line[ASSUAN_LINELENGTH];
@@ -1841,9 +1858,12 @@ agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
dfltparm.keyinfo.mainkeyid = mainkeyid;
dfltparm.keyinfo.pubkey_algo = pubkey_algo;
- if (!keygrip || strlen(keygrip) != 40 || !s_ciphertext || !r_buf || !r_buflen)
+ if (!keygrip || strlen(keygrip) != 40
+ || !s_ciphertext || !r_buf || !r_buflen || !r_padding)
return gpg_error (GPG_ERR_INV_VALUE);
+
*r_buf = NULL;
+ *r_padding = -1;
err = start_agent (ctrl, 0);
if (err)
@@ -1881,7 +1901,8 @@ agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
return err;
err = assuan_transact (agent_ctx, "PKDECRYPT",
membuf_data_cb, &data,
- inq_ciphertext_cb, &parm, NULL, NULL);
+ inq_ciphertext_cb, &parm,
+ padding_info_cb, r_padding);
xfree (parm.ciphertext);
}
if (err)