aboutsummaryrefslogtreecommitdiffstats
path: root/g10/call-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r--g10/call-agent.c138
1 files changed, 0 insertions, 138 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 6333586fb..03ea1685f 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -914,144 +914,6 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length)
}
-/* Helper returning a command option to describe the used hash
- algorithm. See scd/command.c:cmd_pksign. */
-static const char *
-hash_algo_option (int algo)
-{
- switch (algo)
- {
- case GCRY_MD_RMD160: return "--hash=rmd160";
- case GCRY_MD_SHA1 : return "--hash=sha1";
- case GCRY_MD_SHA224: return "--hash=sha224";
- case GCRY_MD_SHA256: return "--hash=sha256";
- case GCRY_MD_SHA384: return "--hash=sha384";
- case GCRY_MD_SHA512: return "--hash=sha512";
- case GCRY_MD_MD5 : return "--hash=md5";
- default: return "";
- }
-}
-
-
-/* Send a sign command to the scdaemon via gpg-agent's pass thru
- mechanism. */
-int
-agent_scd_pksign (const char *serialno, int hashalgo,
- const unsigned char *indata, size_t indatalen,
- unsigned char **r_buf, size_t *r_buflen)
-{
- int rc;
- char line[ASSUAN_LINELENGTH];
- membuf_t data;
- size_t len;
-
- /* Note, hashalgo is not yet used but hardwired to SHA1 in SCdaemon. */
-
- *r_buf = NULL;
- *r_buflen = 0;
-
- rc = start_agent (NULL, 1);
- if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT
- || gpg_err_code (rc) == GPG_ERR_NOT_SUPPORTED)
- rc = 0; /* We check later. */
- if (rc)
- return rc;
-
- if (indatalen*2 + 50 > DIM(line))
- return gpg_error (GPG_ERR_GENERAL);
-
- rc = select_openpgp (serialno);
- if (rc)
- return rc;
-
- strcpy (line, "SCD SETDATA ");
- bin2hex (indata, indatalen, line + strlen (line));
-
- rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
- if (rc)
- return rc;
-
- init_membuf (&data, 1024);
- /* if (!hashalgo) /\* Temporary test hack. *\/ */
- /* snprintf (line, DIM(line)-1, "SCD PKAUTH %s", serialno); */
- /* else */
- snprintf (line, DIM(line)-1, "SCD PKSIGN %s %s",
- hash_algo_option (hashalgo), serialno);
- line[DIM(line)-1] = 0;
- rc = assuan_transact (agent_ctx, line, membuf_data_cb, &data,
- default_inq_cb, NULL, NULL, NULL);
- if (rc)
- {
- xfree (get_membuf (&data, &len));
- }
- else
- *r_buf = get_membuf (&data, r_buflen);
-
- status_sc_op_failure (rc);
- return rc;
-}
-
-
-/* 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,
- unsigned char **r_buf, size_t *r_buflen)
-{
- int rc;
- char line[ASSUAN_LINELENGTH];
- membuf_t data;
- size_t len;
-
- *r_buf = NULL;
- rc = start_agent (NULL, 1);
- if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT
- || gpg_err_code (rc) == GPG_ERR_NOT_SUPPORTED)
- rc = 0; /* We check later. */
- if (rc)
- return rc;
-
- /* FIXME: use secure memory where appropriate */
- if (indatalen*2 + 50 > DIM(line))
- return gpg_error (GPG_ERR_GENERAL);
-
- rc = select_openpgp (serialno);
- if (rc)
- return rc;
-
- strcpy (line, "SCD SETDATA ");
- bin2hex (indata, indatalen, line + strlen (line));
-
- rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
- if (rc)
- return 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,
- default_inq_cb, NULL, NULL, NULL);
- if (rc)
- {
- xfree (get_membuf (&data, &len));
- }
- else
- {
- *r_buf = get_membuf (&data, r_buflen);
- if (!*r_buf)
- rc = gpg_error (GPG_ERR_ENOMEM);
- }
-
- status_sc_op_failure (rc);
- return rc;
-}
-
/* Send a READCERT command to the SCdaemon. */