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