gnupg/g10 (ChangeLog app-common.h app-openpgp.c cardglue.c)
cvs user wk
cvs at cvs.gnupg.org
Mon May 23 21:56:10 CEST 2005
Date: Monday, May 23, 2005 @ 22:16:21
Author: wk
Path: /cvs/gnupg/gnupg/g10
Modified: ChangeLog app-common.h app-openpgp.c cardglue.c
* app-openpgp.c, app-common.h: Again updated from gnupg 1.9 CVS.
* cardglue.c (open_card): Check USE_AGENT.
(agent_scd_checkpin): Implemented Assuan part.
(agent_scd_change_pin): Ditto.
---------------+
ChangeLog | 4 +
app-common.h | 19 ----
app-openpgp.c | 214 --------------------------------------------------------
cardglue.c | 21 ++++-
4 files changed, 24 insertions(+), 234 deletions(-)
Index: gnupg/g10/ChangeLog
diff -u gnupg/g10/ChangeLog:1.739 gnupg/g10/ChangeLog:1.740
--- gnupg/g10/ChangeLog:1.739 Mon May 23 16:38:05 2005
+++ gnupg/g10/ChangeLog Mon May 23 22:16:21 2005
@@ -1,6 +1,10 @@
2005-05-23 Werner Koch <wk at g10code.com>
+ * app-openpgp.c, app-common.h: Again updated from gnupg 1.9 CVS.
+
* cardglue.c (open_card): Check USE_AGENT.
+ (agent_scd_checkpin): Implemented Assuan part.
+ (agent_scd_change_pin): Ditto.
* g10.c (main): Option --debug-ccid-driver may now be given
several times increase the debug level.
Index: gnupg/g10/app-common.h
diff -u gnupg/g10/app-common.h:1.9 gnupg/g10/app-common.h:1.10
--- gnupg/g10/app-common.h:1.9 Sat May 21 16:04:31 2005
+++ gnupg/g10/app-common.h Mon May 23 22:16:21 2005
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: app-common.h,v 1.9 2005/05/21 14:04:31 wk Exp $
+ * $Id: app-common.h,v 1.10 2005/05/23 20:16:21 wk Exp $
*/
#ifndef GNUPG_SCD_APP_COMMON_H
@@ -176,23 +176,6 @@
/*-- app-openpgp.c --*/
gpg_error_t app_select_openpgp (app_t app);
-gpg_error_t app_openpgp_cardinfo (app_t app,
- char **serialno,
- char **disp_name,
- char **pubkey_url,
- unsigned char **fpr1,
- unsigned char **fpr2,
- unsigned char **fpr3);
-gpg_error_t app_openpgp_storekey (app_t app, int keyno,
- unsigned char *template, size_t template_len,
- time_t created_at,
- const unsigned char *m, size_t mlen,
- const unsigned char *e, size_t elen,
- gpg_error_t (*pincb)(void*, const char *, char **),
- void *pincb_arg);
-gpg_error_t app_openpgp_readkey (app_t app, int keyno,
- unsigned char **m, size_t *mlen,
- unsigned char **e, size_t *elen);
/*-- app-nks.c --*/
gpg_error_t app_select_nks (app_t app);
Index: gnupg/g10/app-openpgp.c
diff -u gnupg/g10/app-openpgp.c:1.27 gnupg/g10/app-openpgp.c:1.28
--- gnupg/g10/app-openpgp.c:1.27 Sat May 21 16:04:31 2005
+++ gnupg/g10/app-openpgp.c Mon May 23 22:16:21 2005
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: app-openpgp.c,v 1.27 2005/05/21 14:04:31 wk Exp $
+ * $Id: app-openpgp.c,v 1.28 2005/05/23 20:16:21 wk Exp $
*/
#include <config.h>
@@ -2521,215 +2521,3 @@
-/* This function is a hack to retrieve essential information about the
- card to be displayed by simple tools. It mostly resembles what the
- LEARN command returns. All parameters return allocated strings or
- buffers or NULL if the data object is not available. All returned
- values are sanitized. */
-gpg_error_t
-app_openpgp_cardinfo (app_t app,
- char **serialno,
- char **disp_name,
- char **pubkey_url,
- unsigned char **fpr1,
- unsigned char **fpr2,
- unsigned char **fpr3)
-{
- int rc;
- void *relptr;
- unsigned char *value;
- size_t valuelen;
-
- if (serialno)
- {
- time_t dummy;
-
- *serialno = NULL;
- rc = app_get_serial_and_stamp (app, serialno, &dummy);
- if (rc)
- {
- log_error (_("error getting serial number: %s\n"),
- gpg_strerror (rc));
- return rc;
- }
- }
-
- if (disp_name)
- {
- *disp_name = NULL;
- relptr = get_one_do (app, 0x005B, &value, &valuelen, NULL);
- if (relptr)
- {
- *disp_name = make_printable_string (value, valuelen, 0);
- xfree (relptr);
- }
- }
-
- if (pubkey_url)
- {
- *pubkey_url = NULL;
- relptr = get_one_do (app, 0x5F50, &value, &valuelen, NULL);
- if (relptr)
- {
- *pubkey_url = make_printable_string (value, valuelen, 0);
- xfree (relptr);
- }
- }
-
- if (fpr1)
- *fpr1 = NULL;
- if (fpr2)
- *fpr2 = NULL;
- if (fpr3)
- *fpr3 = NULL;
- relptr = get_one_do (app, 0x00C5, &value, &valuelen, NULL);
- if (relptr && valuelen >= 60)
- {
- if (fpr1)
- {
- *fpr1 = xmalloc (20);
- memcpy (*fpr1, value + 0, 20);
- }
- if (fpr2)
- {
- *fpr2 = xmalloc (20);
- memcpy (*fpr2, value + 20, 20);
- }
- if (fpr3)
- {
- *fpr3 = xmalloc (20);
- memcpy (*fpr3, value + 40, 20);
- }
- }
- xfree (relptr);
-
- return 0;
-}
-
-
-
-/* This function is currently only used by the sc-copykeys program to
- store a key on the smartcard. app_t ist the application handle,
- KEYNO is the number of the key and PINCB, PINCB_ARG are used to ask
- for the SO PIN. TEMPLATE and TEMPLATE_LEN describe a buffer with
- the key template to store. CREATED_AT is the timestamp used to
- create the fingerprint. M, MLEN is the RSA modulus and E, ELEN the
- RSA public exponent. This function silently overwrites an existing
- key.*/
-gpg_error_t
-app_openpgp_storekey (app_t app, int keyno,
- unsigned char *template, size_t template_len,
- time_t created_at,
- const unsigned char *m, size_t mlen,
- const unsigned char *e, size_t elen,
- gpg_error_t (*pincb)(void*, const char *, char **),
- void *pincb_arg)
-{
- int rc;
- unsigned char fprbuf[20];
-
- if (keyno < 1 || keyno > 3)
- return gpg_error (GPG_ERR_INV_ID);
- keyno--;
-
- rc = verify_chv3 (app, pincb, pincb_arg);
- if (rc)
- goto leave;
-
- flush_cache (app);
-
- xfree (app->app_local->pk[keyno].key);
- app->app_local->pk[keyno].key = NULL;
- app->app_local->pk[keyno].keylen = 0;
- app->app_local->pk[keyno].read_done = 0;
-
- rc = iso7816_put_data (app->slot,
- (app->card_version > 0x0007? 0xE0 : 0xE9) + keyno,
- template, template_len);
- if (rc)
- {
- log_error (_("failed to store the key: %s\n"), gpg_strerror (rc));
- rc = gpg_error (GPG_ERR_CARD);
- goto leave;
- }
-
-/* log_printhex ("RSA n:", m, mlen); */
-/* log_printhex ("RSA e:", e, elen); */
-
- rc = store_fpr (app->slot, keyno, (u32)created_at,
- m, mlen, e, elen, fprbuf, app->card_version);
-
- leave:
- return rc;
-}
-
-
-/* Utility function for external tools: Read the public RSA key at
- KEYNO and return modulus and exponent in (M,MLEN) and (E,ELEN). */
-gpg_error_t
-app_openpgp_readkey (app_t app, int keyno, unsigned char **m, size_t *mlen,
- unsigned char **e, size_t *elen)
-{
- int rc;
- const unsigned char *keydata, *a;
- unsigned char *buffer;
- size_t buflen, keydatalen, alen;
-
- *m = NULL;
- *e = NULL;
-
- if (keyno < 1 || keyno > 3)
- return gpg_error (GPG_ERR_INV_ID);
- keyno--;
-
- rc = iso7816_read_public_key(app->slot,
- keyno == 0? "\xB6" :
- keyno == 1? "\xB8" : "\xA4",
- 2,
- &buffer, &buflen);
- if (rc)
- {
- rc = gpg_error (GPG_ERR_CARD);
- log_error (_("reading the key failed\n"));
- goto leave;
- }
-
- keydata = find_tlv (buffer, buflen, 0x7F49, &keydatalen);
- if (!keydata)
- {
- log_error (_("response does not contain the public key data\n"));
- rc = gpg_error (GPG_ERR_CARD);
- goto leave;
- }
-
- a = find_tlv (keydata, keydatalen, 0x0081, &alen);
- if (!a)
- {
- log_error (_("response does not contain the RSA modulus\n"));
- rc = gpg_error (GPG_ERR_CARD);
- goto leave;
- }
- *mlen = alen;
- *m = xmalloc (alen);
- memcpy (*m, a, alen);
-
- a = find_tlv (keydata, keydatalen, 0x0082, &alen);
- if (!a)
- {
- log_error (_("response does not contain the RSA public exponent\n"));
- rc = gpg_error (GPG_ERR_CARD);
- goto leave;
- }
- *elen = alen;
- *e = xmalloc (alen);
- memcpy (*e, a, alen);
-
- leave:
- xfree (buffer);
- if (rc)
- {
- xfree (*m); *m = NULL;
- xfree (*e); *e = NULL;
- }
- return rc;
-}
Index: gnupg/g10/cardglue.c
diff -u gnupg/g10/cardglue.c:1.29 gnupg/g10/cardglue.c:1.30
--- gnupg/g10/cardglue.c:1.29 Mon May 23 16:38:05 2005
+++ gnupg/g10/cardglue.c Mon May 23 22:16:21 2005
@@ -1293,7 +1293,6 @@
agent_scd_change_pin (int chvno)
{
app_t app;
- char chvnostr[20];
int reset = 0;
int rc;
@@ -1306,10 +1305,19 @@
if (app->assuan_ctx)
{
- rc = gpg_error (GPG_ERR_CARD);
+ char line[ASSUAN_LINELENGTH];
+
+ snprintf (line, DIM(line)-1, "SCD PASSWD%s %d",
+ reset? " --reset":"", chvno);
+ line[DIM(line)-1] = 0;
+ rc = test_transact (assuan_transact (app->assuan_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL),
+ "SCD PASSWD");
}
else
{
+ char chvnostr[50];
+
sprintf (chvnostr, "%d", chvno);
rc = app->fnc.change_pin (app, NULL, chvnostr, reset,
pin_cb, NULL);
@@ -1335,7 +1343,14 @@
if (app->assuan_ctx)
{
- rc = gpg_error (GPG_ERR_CARD);
+ char line[ASSUAN_LINELENGTH];
+
+ if (15 + strlen (serialnobuf) > DIM(line)-1)
+ return gpg_error (GPG_ERR_CARD);
+ stpcpy (stpcpy (line, "SCD CHECKPIN "), serialnobuf);
+ rc = test_transact (assuan_transact (app->assuan_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL),
+ "SCD CHECKPIN");
}
else
{
More information about the Gnupg-commits
mailing list