diff options
author | Werner Koch <[email protected]> | 2003-07-03 18:08:16 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2003-07-03 18:08:16 +0000 |
commit | 1753a2f3b0ec8c1eda54d9de7b17fa62c43fef39 (patch) | |
tree | ec11dfed93129b924a14e921ea110ddcc7506d64 /g10/call-agent.c | |
parent | * app-openpgp.c (store_fpr): Fixed fingerprint calculation. (diff) | |
download | gnupg-1753a2f3b0ec8c1eda54d9de7b17fa62c43fef39.tar.gz gnupg-1753a2f3b0ec8c1eda54d9de7b17fa62c43fef39.zip |
* options.h (DBG_CIPHER): Reintroduced it.
* seskey.c (encode_session_key): Debug output of the session key.
* pubkey-enc.c (get_it): Handle card case.
* call-agent.c (agent_scd_pkdecrypt): New.
* pkglue.c (pk_encrypt): Add RSA support.
* g10.c (main): Default to --use-agent.
* keygen.c (show_smartcard): Print info about the public key.
(check_smartcard): Check for existing key here.
(gen_card_key): And not anymore here.
(fpr_is_zero): New.
(generate_keypair): Generate both keys for a card.
(smartcard_change_url): Nw.
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r-- | g10/call-agent.c | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c index d38e4c0fc..ca4236538 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -456,7 +456,6 @@ learn_status_cb (void *opaque, const char *line) const char *keyword = line; int keywordlen; - log_debug ("got status line `%s'\n", line); for (keywordlen=0; *line && !spacep (line); line++, keywordlen++) ; while (spacep (line)) @@ -470,7 +469,7 @@ learn_status_cb (void *opaque, const char *line) { parm->disp_name = unescape_status_string (line); } - else if (keywordlen == 10 && !memcmp (keyword, "PUBKEY_URL", keywordlen)) + else if (keywordlen == 10 && !memcmp (keyword, "PUBKEY-URL", keywordlen)) { parm->pubkey_url = unescape_status_string (line); } @@ -670,7 +669,7 @@ agent_scd_pksign (const char *serialno, int hashalgo, sprintf (p, "%02X", indata[i]); rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); if (rc) - return rc; + return map_assuan_err (rc); init_membuf (&data, 1024); snprintf (line, DIM(line)-1, "SCD PKSIGN %s", serialno); @@ -680,9 +679,62 @@ agent_scd_pksign (const char *serialno, int hashalgo, if (rc) { xfree (get_membuf (&data, &len)); - return rc; + return map_assuan_err (rc); } *r_buf = get_membuf (&data, r_buflen); return 0; } + + +/* Decrypt INDATA of length INDATALEN using the card identified by + SERIALNO. Return the plaintext in a nwly allocated buffer stored + at the address of R_BUF. + + Note, we currently support only RSA or more exactly algorithms + taking one input data element. */ +int +agent_scd_pkdecrypt (const char *serialno, + const unsigned char *indata, size_t indatalen, + char **r_buf, size_t *r_buflen) +{ + int rc, i; + char *p, line[ASSUAN_LINELENGTH]; + membuf_t data; + size_t len; + + *r_buf = NULL; + rc = start_agent (); + if (rc) + return rc; + + /* FIXME: use secure memory where appropriate */ + if (indatalen*2 + 50 > DIM(line)) + return gpg_error (GPG_ERR_GENERAL); + + sprintf (line, "SCD SETDATA "); + p = line + strlen (line); + for (i=0; i < indatalen ; i++, p += 2 ) + sprintf (p, "%02X", indata[i]); + rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); + if (rc) + return map_assuan_err (rc); + + init_membuf (&data, 1024); + snprintf (line, DIM(line)-1, "SCD PKDECRYPT %s", serialno); + line[DIM(line)-1] = 0; + rc = assuan_transact (agent_ctx, line, + membuf_data_cb, &data, + NULL, NULL, NULL, NULL); + if (rc) + { + xfree (get_membuf (&data, &len)); + return map_assuan_err (rc); + } + *r_buf = get_membuf (&data, r_buflen); + if (!*r_buf) + return gpg_error (GPG_ERR_ENOMEM); + + return 0; +} + |