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

gpg: Rename functions with an "fprint" part to "fpr"

--

The fprint is too uncommon in our code base and to similar to fprintf.
This commit is contained in:
Werner Koch 2024-06-04 15:25:51 +02:00
parent 8624482160
commit 04ce6765f4
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
15 changed files with 104 additions and 110 deletions

View File

@ -699,7 +699,7 @@ current_card_status (ctrl_t ctrl, estream_t fp,
/* If the fingerprint is all 0xff, the key has no associated
OpenPGP certificate. */
if ( thefpr && !fpr_is_ff (thefpr, thefprlen)
&& !get_pubkey_byfprint (ctrl, pk, &keyblock, thefpr, thefprlen))
&& !get_pubkey_byfpr (ctrl, pk, &keyblock, thefpr, thefprlen))
{
print_key_info (ctrl, fp, 0, pk, 0);
print_card_key_info (fp, keyblock);
@ -917,7 +917,7 @@ fetch_url (ctrl_t ctrl)
}
else if (info.fpr1len)
{
rc = keyserver_import_fprint (ctrl, info.fpr1, info.fpr1len,
rc = keyserver_import_fpr (ctrl, info.fpr1, info.fpr1len,
opt.keyserver, 0);
}
}

View File

@ -326,7 +326,7 @@ get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig,
/* First try the ISSUER_FPR info. */
fpr = issuer_fpr_raw (sig, &fprlen);
if (fpr && !get_pubkey_byfprint (ctrl, pk, NULL, fpr, fprlen))
if (fpr && !get_pubkey_byfpr (ctrl, pk, NULL, fpr, fprlen))
return 0;
/* Fallback to use the ISSUER_KEYID. */
@ -571,7 +571,7 @@ get_pubkeyblock_for_sig (ctrl_t ctrl, PKT_signature *sig)
/* First try the ISSUER_FPR info. */
fpr = issuer_fpr_raw (sig, &fprlen);
if (fpr && !get_pubkey_byfprint (ctrl, NULL, &keyblock, fpr, fprlen))
if (fpr && !get_pubkey_byfpr (ctrl, NULL, &keyblock, fpr, fprlen))
return keyblock;
/* Fallback to use the ISSUER_KEYID. */
@ -1194,7 +1194,7 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
mechanism_string = "NTDS";
glo_ctrl.in_auto_key_retrieve++;
if (is_fpr)
rc = keyserver_import_fprint_ntds (ctrl,
rc = keyserver_import_fpr_ntds (ctrl,
fprbuf.u.fpr, fprbuf.fprlen);
else
rc = keyserver_import_ntds (ctrl, name, &fpr, &fpr_len);
@ -1212,7 +1212,7 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
glo_ctrl.in_auto_key_retrieve++;
if (is_fpr)
{
rc = keyserver_import_fprint (ctrl,
rc = keyserver_import_fpr (ctrl,
fprbuf.u.fpr, fprbuf.fprlen,
opt.keyserver,
KEYSERVER_IMPORT_FLAG_LDAP);
@ -1247,7 +1247,7 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
glo_ctrl.in_auto_key_retrieve++;
if (is_fpr)
{
rc = keyserver_import_fprint (ctrl,
rc = keyserver_import_fpr (ctrl,
fprbuf.u.fpr, fprbuf.fprlen,
opt.keyserver,
KEYSERVER_IMPORT_FLAG_LDAP);
@ -1831,8 +1831,8 @@ get_pubkey_from_buffer (ctrl_t ctrl, PKT_public_key *pkbuf,
* returned in *R_KEYBLOCK. This should be freed using
* release_kbnode().
*
* FPRINT is a byte array whose contents is the fingerprint to use as
* the search term. FPRINT_LEN specifies the length of the
* FPR is a byte array whose contents is the fingerprint to use as
* the search term. FPRLEN specifies the length of the
* fingerprint (in bytes). Currently, only 16, 20, and 32-byte
* fingerprints are supported.
*
@ -1840,15 +1840,15 @@ get_pubkey_from_buffer (ctrl_t ctrl, PKT_public_key *pkbuf,
* be done by creating a userID conforming to the unified fingerprint
* style. */
int
get_pubkey_byfprint (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
const byte * fprint, size_t fprint_len)
get_pubkey_byfpr (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
const byte *fpr, size_t fprlen)
{
int rc;
if (r_keyblock)
*r_keyblock = NULL;
if (fprint_len == 32 || fprint_len == 20 || fprint_len == 16)
if (fprlen == 32 || fprlen == 20 || fprlen == 16)
{
struct getkey_ctx_s ctx;
KBNODE kb = NULL;
@ -1865,8 +1865,8 @@ get_pubkey_byfprint (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
ctx.nitems = 1;
ctx.items[0].mode = KEYDB_SEARCH_MODE_FPR;
memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
ctx.items[0].fprlen = fprint_len;
memcpy (ctx.items[0].u.fpr, fpr, fprlen);
ctx.items[0].fprlen = fprlen;
if (pk)
ctx.req_usage = pk->req_usage;
rc = lookup (ctrl, &ctx, 0, &kb, &found_key);
@ -1886,7 +1886,7 @@ get_pubkey_byfprint (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
}
/* This function is similar to get_pubkey_byfprint, but it doesn't
/* This function is similar to get_pubkey_byfpr, but it doesn't
* merge the self-signed data into the public key and subkeys or into
* the user ids. It also doesn't add the key to the user id cache.
* Further, this function ignores PK->REQ_USAGE.
@ -1894,17 +1894,16 @@ get_pubkey_byfprint (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
* This function is intended to avoid recursion and, as such, should
* only be used in very specific situations.
*
* Like get_pubkey_byfprint, PK may be NULL. In that case, this
* Like get_pubkey_byfpr, PK may be NULL. In that case, this
* function effectively just checks for the existence of the key. */
gpg_error_t
get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key * pk,
const byte * fprint, size_t fprint_len)
get_pubkey_byfpr_fast (ctrl_t ctrl, PKT_public_key * pk,
const byte *fpr, size_t fprlen)
{
gpg_error_t err;
KBNODE keyblock;
err = get_keyblock_byfprint_fast (ctrl,
&keyblock, NULL, fprint, fprint_len, 0);
err = get_keyblock_byfpr_fast (ctrl, &keyblock, NULL, fpr, fprlen, 0);
if (!err)
{
if (pk)
@ -1916,7 +1915,7 @@ get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key * pk,
}
/* This function is similar to get_pubkey_byfprint_fast but returns a
/* This function is similar to get_pubkey_byfpr_fast but returns a
* keydb handle at R_HD and the keyblock at R_KEYBLOCK. R_KEYBLOCK or
* R_HD may be NULL. If LOCK is set the handle has been opend in
* locked mode and keydb_disable_caching () has been called. On error
@ -1924,9 +1923,9 @@ get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key * pk,
* it may have a value of NULL, though. This allows one to do an insert
* operation on a locked keydb handle. */
gpg_error_t
get_keyblock_byfprint_fast (ctrl_t ctrl,
get_keyblock_byfpr_fast (ctrl_t ctrl,
kbnode_t *r_keyblock, KEYDB_HANDLE *r_hd,
const byte *fprint, size_t fprint_len, int lock)
const byte *fpr, size_t fprlen, int lock)
{
gpg_error_t err;
KEYDB_HANDLE hd;
@ -1939,8 +1938,8 @@ get_keyblock_byfprint_fast (ctrl_t ctrl,
if (r_hd)
*r_hd = NULL;
for (i = 0; i < MAX_FINGERPRINT_LEN && i < fprint_len; i++)
fprbuf[i] = fprint[i];
for (i = 0; i < MAX_FINGERPRINT_LEN && i < fprlen; i++)
fprbuf[i] = fpr[i];
hd = keydb_new (ctrl);
if (!hd)
@ -1964,7 +1963,7 @@ get_keyblock_byfprint_fast (ctrl_t ctrl,
if (r_hd)
*r_hd = hd;
err = keydb_search_fpr (hd, fprbuf, fprint_len);
err = keydb_search_fpr (hd, fprbuf, fprlen);
if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
{
if (!r_hd)
@ -4081,16 +4080,16 @@ get_seckey_default_or_card (ctrl_t ctrl, PKT_public_key *pk,
add_to_strlist (&namelist, def_secret_key);
else if (fpr_card)
{
err = get_pubkey_byfprint (ctrl, pk, NULL, fpr_card, fpr_len);
err = get_pubkey_byfpr (ctrl, pk, NULL, fpr_card, fpr_len);
if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY)
{
if (opt.debug)
log_debug ("using LDAP to find public key for current card\n");
err = keyserver_import_fprint (ctrl, fpr_card, fpr_len,
err = keyserver_import_fpr (ctrl, fpr_card, fpr_len,
opt.keyserver,
KEYSERVER_IMPORT_FLAG_LDAP);
if (!err)
err = get_pubkey_byfprint (ctrl, pk, NULL, fpr_card, fpr_len);
err = get_pubkey_byfpr (ctrl, pk, NULL, fpr_card, fpr_len);
else if (gpg_err_code (err) == GPG_ERR_NO_DATA
|| gpg_err_code (err) == GPG_ERR_NO_KEYSERVER)
{
@ -4273,7 +4272,7 @@ get_user_id_byfpr (ctrl_t ctrl, const byte *fpr, size_t fprlen, size_t *rn)
if (!name)
{
/* Get it so that the cache will be filled. */
if (!get_pubkey_byfprint (ctrl, NULL, NULL, fpr, fprlen))
if (!get_pubkey_byfpr (ctrl, NULL, NULL, fpr, fprlen))
name = cache_get_uid_byfpr (fpr, fprlen, rn);
}

View File

@ -464,7 +464,7 @@ keyserver_import_keyid (u32 *keyid, void *dummy, unsigned int flags)
}
int
keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
keyserver_import_fpr (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
struct keyserver_spec *keyserver, unsigned int flags)
{
(void)ctrl;
@ -476,7 +476,7 @@ keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
}
int
keyserver_import_fprint_ntds (ctrl_t ctrl,
keyserver_import_fpr_ntds (ctrl_t ctrl,
const byte *fprint, size_t fprint_len)
{
(void)ctrl;

View File

@ -2199,7 +2199,7 @@ import_one_real (ctrl_t ctrl,
goto leave;
/* Do we have this key already in one of our pubrings ? */
err = get_keyblock_byfprint_fast (ctrl, &keyblock_orig, &hd,
err = get_keyblock_byfpr_fast (ctrl, &keyblock_orig, &hd,
fpr2, fpr2len, 1/*locked*/);
if ((err
&& gpg_err_code (err) != GPG_ERR_NO_PUBKEY
@ -3071,7 +3071,7 @@ import_matching_seckeys (ctrl_t ctrl, kbnode_t seckeys,
/* Get the entire public key block from our keystore and put all its
* fingerprints into an array. */
err = get_pubkey_byfprint (ctrl, NULL, &pub_keyblock, mainfpr, mainfprlen);
err = get_pubkey_byfpr (ctrl, NULL, &pub_keyblock, mainfpr, mainfprlen);
if (err)
goto leave;
log_assert (pub_keyblock && pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
@ -3309,7 +3309,7 @@ import_secret_one (ctrl_t ctrl, kbnode_t keyblock,
{
/* Read the keyblock again to get the effects of a merge for
* the public key. */
err = get_pubkey_byfprint (ctrl, NULL, &node, fpr, fprlen);
err = get_pubkey_byfpr (ctrl, NULL, &node, fpr, fprlen);
if (err || !node)
log_error ("key %s: failed to re-lookup public key: %s\n",
keystr_from_pk (pk), gpg_strerror (err));
@ -4403,7 +4403,7 @@ revocation_present (ctrl_t ctrl, kbnode_t keyblock)
* itself? */
gpg_error_t err;
err = get_pubkey_byfprint_fast (ctrl, NULL,
err = get_pubkey_byfpr_fast (ctrl, NULL,
sig->revkey[idx].fpr,
sig->revkey[idx].fprlen);
if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY
@ -4419,13 +4419,13 @@ revocation_present (ctrl_t ctrl, kbnode_t keyblock)
log_info(_("WARNING: key %s may be revoked:"
" fetching revocation key %s\n"),
tempkeystr,keystr(keyid));
keyserver_import_fprint (ctrl,
keyserver_import_fpr (ctrl,
sig->revkey[idx].fpr,
sig->revkey[idx].fprlen,
opt.keyserver, 0);
/* Do we have it now? */
err = get_pubkey_byfprint_fast (ctrl, NULL,
err = get_pubkey_byfpr_fast (ctrl, NULL,
sig->revkey[idx].fpr,
sig->revkey[idx].fprlen);
}

View File

@ -404,22 +404,22 @@ gpg_error_t get_pubkey_from_buffer (ctrl_t ctrl, PKT_public_key *pkbuf,
gpg_error_t get_seckey (ctrl_t ctrl, PKT_public_key *pk, u32 *keyid);
/* Lookup a key with the specified fingerprint. */
int get_pubkey_byfprint (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
const byte *fprint, size_t fprint_len);
int get_pubkey_byfpr (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock,
const byte *fpr, size_t fprlen);
/* This function is similar to get_pubkey_byfpr, but it doesn't
merge the self-signed data into the public key and subkeys or into
the user ids. */
gpg_error_t get_pubkey_byfpr_fast (ctrl_t ctrl, PKT_public_key *pk,
const byte *fpr, size_t fprlen);
/* This function is similar to get_pubkey_byfprint, but it doesn't
merge the self-signed data into the public key and subkeys or into
the user ids. */
gpg_error_t get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key *pk,
const byte *fprint, size_t fprint_len);
/* This function is similar to get_pubkey_byfprint, but it doesn't
merge the self-signed data into the public key and subkeys or into
the user ids. */
gpg_error_t get_keyblock_byfprint_fast (ctrl_t ctrl,
gpg_error_t get_keyblock_byfpr_fast (ctrl_t ctrl,
kbnode_t *r_keyblock,
KEYDB_HANDLE *r_hd,
const byte *fprint, size_t fprint_len,
const byte *fpr, size_t fprlen,
int lock);

View File

@ -778,25 +778,24 @@ keyid_from_pk (PKT_public_key *pk, u32 *keyid)
* keyid is not part of the fingerprint.
*/
u32
keyid_from_fingerprint (ctrl_t ctrl, const byte *fprint,
size_t fprint_len, u32 *keyid)
keyid_from_fingerprint (ctrl_t ctrl, const byte *fpr, size_t fprlen, u32 *keyid)
{
u32 dummy_keyid[2];
if( !keyid )
keyid = dummy_keyid;
if (fprint_len != 20 && fprint_len != 32)
if (fprlen != 20 && fprlen != 32)
{
/* This is special as we have to lookup the key first. */
PKT_public_key pk;
int rc;
memset (&pk, 0, sizeof pk);
rc = get_pubkey_byfprint (ctrl, &pk, NULL, fprint, fprint_len);
rc = get_pubkey_byfpr (ctrl, &pk, NULL, fpr, fprlen);
if( rc )
{
log_printhex (fprint, fprint_len,
log_printhex (fpr, fprlen,
"Oops: keyid_from_fingerprint: no pubkey; fpr:");
keyid[0] = 0;
keyid[1] = 0;
@ -806,8 +805,8 @@ keyid_from_fingerprint (ctrl_t ctrl, const byte *fprint,
}
else
{
const byte *dp = fprint;
if (fprint_len == 20) /* v4 key */
const byte *dp = fpr;
if (fprlen == 20) /* v4 key */
{
keyid[0] = buf32_to_u32 (dp+12);
keyid[1] = buf32_to_u32 (dp+16);

View File

@ -37,10 +37,10 @@ struct keyserver_spec *parse_preferred_keyserver(PKT_signature *sig);
int keyserver_any_configured (ctrl_t ctrl);
int keyserver_export (ctrl_t ctrl, strlist_t users);
int keyserver_import (ctrl_t ctrl, strlist_t users);
int keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
int keyserver_import_fpr (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
struct keyserver_spec *keyserver,
unsigned int flags);
int keyserver_import_fprint_ntds (ctrl_t ctrl,
int keyserver_import_fpr_ntds (ctrl_t ctrl,
const byte *fprint, size_t fprint_len);
int keyserver_import_keyid (ctrl_t ctrl, u32 *keyid,
struct keyserver_spec *keyserver,

View File

@ -976,33 +976,31 @@ keyserver_import_ntds (ctrl_t ctrl, const char *mbox,
int
keyserver_import_fprint (ctrl_t ctrl, const byte *fprint, size_t fprint_len,
struct keyserver_spec *keyserver,
unsigned int flags)
keyserver_import_fpr (ctrl_t ctrl, const byte *fpr, size_t fprlen,
struct keyserver_spec *keyserver, unsigned int flags)
{
KEYDB_SEARCH_DESC desc;
memset (&desc, 0, sizeof(desc));
if (fprint_len == 16 || fprint_len == 20 || fprint_len == 32)
if (fprlen == 16 || fprlen == 20 || fprlen == 32)
desc.mode = KEYDB_SEARCH_MODE_FPR;
else
return gpg_error (GPG_ERR_INV_ARG);
memcpy (desc.u.fpr, fprint, fprint_len);
desc.fprlen = fprint_len;
memcpy (desc.u.fpr, fpr, fprlen);
desc.fprlen = fprlen;
return keyserver_get (ctrl, &desc, 1, keyserver, flags, NULL, NULL);
}
int
keyserver_import_fprint_ntds (ctrl_t ctrl,
const byte *fprint, size_t fprint_len)
keyserver_import_fpr_ntds (ctrl_t ctrl, const byte *fpr, size_t fprlen)
{
struct keyserver_spec keyserver = { NULL, "ldap:///" };
return keyserver_import_fprint (ctrl, fprint, fprint_len,
return keyserver_import_fpr (ctrl, fpr, fprlen,
&keyserver, KEYSERVER_IMPORT_FLAG_LDAP);
}
@ -1779,7 +1777,7 @@ keyserver_import_cert (ctrl_t ctrl, const char *name, int dane_mode,
spec = parse_keyserver_uri (url, 1);
if(spec)
{
err = keyserver_import_fprint (ctrl, *fpr, *fpr_len, spec, 0);
err = keyserver_import_fpr (ctrl, *fpr, *fpr_len, spec, 0);
free_keyserver_spec(spec);
}
}
@ -1788,8 +1786,7 @@ keyserver_import_cert (ctrl_t ctrl, const char *name, int dane_mode,
/* If only a fingerprint is provided, try and fetch it from
the configured keyserver. */
err = keyserver_import_fprint (ctrl,
*fpr, *fpr_len, opt.keyserver, 0);
err = keyserver_import_fpr (ctrl, *fpr, *fpr_len, opt.keyserver, 0);
}
else
log_info(_("no keyserver known\n"));

View File

@ -2192,7 +2192,7 @@ check_sig_and_print (CTX c, kbnode_t node)
free_public_key (pk);
pk = NULL;
glo_ctrl.in_auto_key_retrieve++;
res = keyserver_import_fprint (c->ctrl, p, n, opt.keyserver,
res = keyserver_import_fpr (c->ctrl, p, n, opt.keyserver,
KEYSERVER_IMPORT_FLAG_QUICK);
glo_ctrl.in_auto_key_retrieve--;
if (!res)

View File

@ -130,7 +130,7 @@ show_revocation_reason (ctrl_t ctrl, PKT_public_key *pk, int mode)
/* get the keyblock */
fingerprint_from_pk (pk, fingerprint, &fingerlen);
rc = get_pubkey_byfprint (ctrl, NULL, &keyblock, fingerprint, fingerlen);
rc = get_pubkey_byfpr (ctrl, NULL, &keyblock, fingerprint, fingerlen);
if( rc ) { /* that should never happen */
log_debug( "failed to get the keyblock\n");
return;

View File

@ -294,7 +294,7 @@ gen_desig_revoke (ctrl_t ctrl, const char *uname, strlist_t locusr)
else
{
pk2 = xmalloc_clear (sizeof *pk2);
rc = get_pubkey_byfprint (ctrl, pk2, NULL,
rc = get_pubkey_byfpr (ctrl, pk2, NULL,
pk->revkey[i].fpr, pk->revkey[i].fprlen);
}

View File

@ -510,7 +510,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
if (opt.debug)
log_debug ("using LDAP to find public key"
" for current card\n");
if (!keyserver_import_fprint
if (!keyserver_import_fpr
(ctrl, cinfo.fpr2, cinfo.fpr2len, opt.keyserver,
KEYSERVER_IMPORT_FLAG_LDAP))
{

View File

@ -202,7 +202,7 @@ keyserver_import_keyid (u32 *keyid, void *dummy, unsigned int flags)
}
int
keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
keyserver_import_fpr (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
struct keyserver_spec *keyserver, unsigned int flags)
{
(void)ctrl;
@ -214,7 +214,7 @@ keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
}
int
keyserver_import_fprint_ntds (ctrl_t ctrl,
keyserver_import_fpr_ntds (ctrl_t ctrl,
const byte *fprint, size_t fprint_len)
{
(void)ctrl;

View File

@ -2493,9 +2493,8 @@ get_policy (ctrl_t ctrl, tofu_dbs_t dbs, PKT_public_key *pk,
int lookup_err;
kbnode_t kb;
lookup_err = get_pubkey_byfprint (ctrl, NULL, &kb,
fingerprint_raw,
fingerprint_raw_len);
lookup_err = get_pubkey_byfpr (ctrl, NULL, &kb,
fingerprint_raw, fingerprint_raw_len);
if (lookup_err)
{
if (DBG_TRUST)

View File

@ -112,7 +112,7 @@ keyid_from_fpr20 (ctrl_t ctrl, const byte *fpr, u32 *keyid)
int rc;
memset (&pk, 0, sizeof pk);
rc = get_pubkey_byfprint (ctrl, &pk, NULL, fpr, fprlen);
rc = get_pubkey_byfpr (ctrl, &pk, NULL, fpr, fprlen);
if (rc)
{
log_printhex (fpr, fprlen,