1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd:p15: Rename some variables and functions for clarity.

* scd/app-p15.c: Rename keyinfo to prkdf.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-04-02 12:39:56 +02:00
parent 5b7b42e2b2
commit 8149742ddf
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -522,20 +522,20 @@ parse_certid (app_t app, const char *certid,
if (certid[0] != 'P' && strlen (certid) == 40) /* This is a keygrip. */ if (certid[0] != 'P' && strlen (certid) == 40) /* This is a keygrip. */
{ {
prkdf_object_t keyinfo; prkdf_object_t prkdf;
for (keyinfo = app->app_local->private_key_info; for (prkdf = app->app_local->private_key_info;
keyinfo; keyinfo = keyinfo->next) prkdf; prkdf = prkdf->next)
if (!keygrip_from_prkdf (app, keyinfo) if (!keygrip_from_prkdf (app, prkdf)
&& !strcmp (certid, keyinfo->keygrip)) && !strcmp (certid, prkdf->keygrip))
break; break;
if (!keyinfo || !keyinfo->objidlen || !keyinfo->objid) if (!prkdf || !prkdf->objidlen || !prkdf->objid)
return gpg_error (GPG_ERR_NOT_FOUND); return gpg_error (GPG_ERR_NOT_FOUND);
objidlen = keyinfo->objidlen; objidlen = prkdf->objidlen;
objid = xtrymalloc (objidlen); objid = xtrymalloc (objidlen);
if (!objid) if (!objid)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
memcpy (objid, keyinfo->objid, keyinfo->objidlen); memcpy (objid, prkdf->objid, prkdf->objidlen);
} }
else /* This is a usual keyref. */ else /* This is a usual keyref. */
{ {
@ -2675,14 +2675,14 @@ keygrip_from_prkdf (app_t app, prkdf_object_t prkdf)
} }
/* Return a malloced keyref string for KEYINFO. Returns NULL on /* Return a malloced keyref string for PRKDF. Returns NULL on
* malloc failure. */ * malloc failure. */
static char * static char *
keyref_from_keyinfo (app_t app, prkdf_object_t keyinfo) keyref_from_prkdf (app_t app, prkdf_object_t prkdf)
{ {
char *buf, *p; char *buf, *p;
buf = xtrymalloc (4 + 5 + keyinfo->objidlen*2 + 1); buf = xtrymalloc (4 + 5 + prkdf->objidlen*2 + 1);
if (!buf) if (!buf)
return NULL; return NULL;
p = stpcpy (buf, "P15"); p = stpcpy (buf, "P15");
@ -2693,7 +2693,7 @@ keyref_from_keyinfo (app_t app, prkdf_object_t keyinfo)
p += 5; p += 5;
} }
p = stpcpy (p, "."); p = stpcpy (p, ".");
bin2hex (keyinfo->objid, keyinfo->objidlen, p); bin2hex (prkdf->objid, prkdf->objidlen, p);
return buf; return buf;
} }
@ -2702,32 +2702,32 @@ keyref_from_keyinfo (app_t app, prkdf_object_t keyinfo)
keypairs back. FIXME: much code duplication from keypairs back. FIXME: much code duplication from
send_certinfo(). */ send_certinfo(). */
static gpg_error_t static gpg_error_t
send_keypairinfo (app_t app, ctrl_t ctrl, prkdf_object_t keyinfo) send_keypairinfo (app_t app, ctrl_t ctrl, prkdf_object_t prkdf)
{ {
gpg_error_t err; gpg_error_t err;
for (; keyinfo; keyinfo = keyinfo->next) for (; prkdf; prkdf = prkdf->next)
{ {
char *buf; char *buf;
int j; int j;
buf = keyref_from_keyinfo (app, keyinfo); buf = keyref_from_prkdf (app, prkdf);
if (!buf) if (!buf)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
err = keygrip_from_prkdf (app, keyinfo); err = keygrip_from_prkdf (app, prkdf);
if (err) if (err)
{ {
log_error ("p15: error getting keygrip from "); log_error ("p15: error getting keygrip from ");
for (j=0; j < keyinfo->pathlen; j++) for (j=0; j < prkdf->pathlen; j++)
log_printf ("%s%04hX", j?"/":"", keyinfo->path[j]); log_printf ("%s%04hX", j?"/":"", prkdf->path[j]);
log_printf (": %s\n", gpg_strerror (err)); log_printf (": %s\n", gpg_strerror (err));
} }
else else
{ {
log_assert (strlen (keyinfo->keygrip) == 40); log_assert (strlen (prkdf->keygrip) == 40);
send_status_info (ctrl, "KEYPAIRINFO", send_status_info (ctrl, "KEYPAIRINFO",
keyinfo->keygrip, 2*KEYGRIP_LEN, prkdf->keygrip, 2*KEYGRIP_LEN,
buf, strlen (buf), buf, strlen (buf),
NULL, (size_t)0); NULL, (size_t)0);
} }
@ -3722,7 +3722,7 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action,
gpg_error_t err; gpg_error_t err;
char *serialno = NULL; char *serialno = NULL;
int as_data = 0; int as_data = 0;
prkdf_object_t keyinfo; prkdf_object_t prkdf;
/* First a quick check for valid parameters. */ /* First a quick check for valid parameters. */
switch (action) switch (action)
@ -3755,36 +3755,36 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action,
} }
} }
for (keyinfo = app->app_local->private_key_info; for (prkdf = app->app_local->private_key_info;
keyinfo; keyinfo = keyinfo->next) prkdf; prkdf = prkdf->next)
{ {
if (keygrip_from_prkdf (app, keyinfo)) if (keygrip_from_prkdf (app, prkdf))
continue; continue;
if (action == KEYGRIP_ACTION_LOOKUP) if (action == KEYGRIP_ACTION_LOOKUP)
{ {
if (!strcmp (keyinfo->keygrip, want_keygripstr)) if (!strcmp (prkdf->keygrip, want_keygripstr))
{ {
err = 0; /* Found */ err = 0; /* Found */
goto leave; goto leave;
} }
} }
else if (!want_keygripstr || !strcmp (keyinfo->keygrip, want_keygripstr)) else if (!want_keygripstr || !strcmp (prkdf->keygrip, want_keygripstr))
{ {
char *keyref; char *keyref;
/* FIXME: Consider ... */ /* FIXME: Consider ... */
(void)capability; (void)capability;
keyref = keyref_from_keyinfo (app, keyinfo); keyref = keyref_from_prkdf (app, prkdf);
if (!keyref) if (!keyref)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
send_keyinfo (ctrl, as_data, keyinfo->keygrip, serialno, keyref); send_keyinfo (ctrl, as_data, prkdf->keygrip, serialno, keyref);
if (want_keygripstr) if (want_keygripstr)
{ {
err = 0; /* Found */ err = 0; /* Found */