Rename pgpHexStr() to rpmhex(), but preserve ABI for now

Fixup internal callers to use rpmhex(), deprecate pgpHexStr().
pgpHexStr() should be dropped at next soname bump, whenever that
happens.
This commit is contained in:
Panu Matilainen 2022-02-24 14:50:59 +02:00 committed by Florian Festi
parent dcfa7323a0
commit d44be2cbc1
13 changed files with 28 additions and 15 deletions

View File

@ -63,7 +63,7 @@ static char * stringFormat(rpmtd td, char **emsg)
break;
}
case RPM_BINARY_CLASS:
val = pgpHexStr(td->data, td->count);
val = rpmhex(td->data, td->count);
break;
default:
*emsg = xstrdup("(unknown type)");
@ -345,7 +345,7 @@ static char * pgpsigFormat(rpmtd td, char **emsg)
*emsg = xstrdup(_("(not an OpenPGP signature)"));
} else {
char dbuf[BUFSIZ];
char *keyid = pgpHexStr(sigp->signid, sizeof(sigp->signid));
char *keyid = rpmhex(sigp->signid, sizeof(sigp->signid));
unsigned int dateint = sigp->time;
time_t date = dateint;
struct tm _tm, * tms = localtime_r(&date, &_tm);

View File

@ -578,7 +578,7 @@ char * rpmfiFDigestHex(rpmfi fi, int *algo)
char *fdigest = NULL;
const unsigned char *digest = rpmfiFDigest(fi, algo, &diglen);
if (digest) {
fdigest = pgpHexStr(digest, diglen);
fdigest = rpmhex(digest, diglen);
}
return fdigest;
}

View File

@ -417,7 +417,7 @@ struct pgpdata_s {
static void initPgpData(pgpDigParams pubp, struct pgpdata_s *pd)
{
memset(pd, 0, sizeof(*pd));
pd->signid = pgpHexStr(pubp->signid, sizeof(pubp->signid));
pd->signid = rpmhex(pubp->signid, sizeof(pubp->signid));
pd->shortid = pd->signid + 8;
pd->userid = pubp->userid ? pubp->userid : "none";
pd->time = pubp->time;

View File

@ -202,7 +202,7 @@ static void rpmsinfoInit(const struct vfyinfo_s *vinfo,
sinfo->keyid = pgpGrab(sinfo->sig->signid+4, 4);
} else if (sinfo->type == RPMSIG_DIGEST_TYPE) {
if (td->type == RPM_BIN_TYPE) {
sinfo->dig = pgpHexStr(data, dlen);
sinfo->dig = rpmhex(data, dlen);
} else {
if (!validHex(data, dlen)) {
rasprintf(&sinfo->msg,

View File

@ -93,7 +93,7 @@ static rpmRC fsverity_fsm_file_prepare(rpmPlugin plugin, rpmfi fi, int fd,
arg.sig_ptr = (uintptr_t)signature;
arg.sig_size = len;
buffer = pgpHexStr(signature, arg.sig_size);
buffer = rpmhex(signature, arg.sig_size);
rpmlog(RPMLOG_DEBUG, "applying signature: %s\n", buffer);
free(buffer);

View File

@ -144,7 +144,7 @@ static PyObject *rpmfile_digest(rpmfileObject *s)
const unsigned char *digest = rpmfilesFDigest(s->files, s->ix,
NULL, &diglen);
if (digest) {
char * hex = pgpHexStr(digest, diglen);
char * hex = rpmhex(digest, diglen);
PyObject *o = utf8FromString(hex);
free(hex);
return o;

View File

@ -114,7 +114,7 @@ int rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
if (lenp)
*lenp = 2 * digestlen + 1;
if (datap) {
*datap = pgpHexStr((const uint8_t *)digest, digestlen);
*datap = rpmhex((const uint8_t *)digest, digestlen);
}
}
gcry_md_close(ctx->h);

View File

@ -259,7 +259,7 @@ int rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
if (lenp) *lenp = (2*digestlen) + 1;
if (datap) {
const uint8_t * s = (const uint8_t *) digest;
*datap = pgpHexStr(s, digestlen);
*datap = rpmhex(s, digestlen);
}
}

View File

@ -236,7 +236,7 @@ static void pgpPrtHex(const char *pre, const uint8_t *p, size_t plen)
if (!_print) return;
if (pre && *pre)
fprintf(stderr, "%s", pre);
hex = pgpHexStr(p, plen);
hex = rpmhex(p, plen);
fprintf(stderr, " %s", hex);
free(hex);
}
@ -1256,7 +1256,7 @@ char *pgpIdentItem(pgpDigParams digp)
char *id = NULL;
if (digp) {
char *signid = pgpHexStr(digp->signid+4, sizeof(digp->signid)-4);
char *signid = rpmhex(digp->signid+4, sizeof(digp->signid)-4);
rasprintf(&id, _("V%d %s/%s %s, key ID %s"),
digp->version,
pgpValStr(pgpPubkeyTbl, digp->pubkey_algo),

View File

@ -10,7 +10,7 @@
#include <rpm/rpmstring.h>
#include "debug.h"
char * pgpHexStr(const uint8_t *p, size_t plen)
char *rpmhex(const uint8_t *p, size_t plen)
{
char *t, *str;
str = t = xmalloc(plen * 2 + 1);
@ -25,6 +25,10 @@ char * pgpHexStr(const uint8_t *p, size_t plen)
return str;
}
char *pgpHexStr(const uint8_t *p, size_t plen)
{
return rpmhex(p, plen);
}
int rstrcasecmp(const char * s1, const char * s2)
{

View File

@ -193,6 +193,15 @@ unsigned int rstrhash(const char * string);
* @param plen no. of bytes
* @return hex formatted string (malloc'ed)
*/
char * rpmhex(const uint8_t *p, size_t plen);
/** \ingroup rpmstring
* Deprecated, do not use.
* @param p bytes
* @param plen no. of bytes
* @return hex formatted string (malloc'ed)
*/
RPM_GNUC_DEPRECATED
char * pgpHexStr(const uint8_t *p, size_t plen);
#ifdef __cplusplus

View File

@ -59,7 +59,7 @@ const char *key, char *keypass, uint32_t *siglenp)
*siglenp = siglen + 1;
/* convert file signature binary to hex */
fsignature = pgpHexStr(signature, siglen+1);
fsignature = rpmhex(signature, siglen+1);
return fsignature;
}

View File

@ -63,7 +63,7 @@ static char *rpmVeritySignFile(rpmfi fi, size_t *sig_size, char *key,
goto out;
}
digest_hex = pgpHexStr(digest->digest, digest->digest_size);
digest_hex = rpmhex(digest->digest, digest->digest_size);
digest_base64 = rpmBase64Encode(digest->digest, digest->digest_size, -1);
rpmlog(RPMLOG_DEBUG, _("file(size %li): %s: digest(%i): %s, idx %i\n"),
file_size, rpmfiFN(fi), digest->digest_size, digest_hex,
@ -82,7 +82,7 @@ static char *rpmVeritySignFile(rpmfi fi, size_t *sig_size, char *key,
goto out;
}
sig_hex = pgpHexStr(sig, *sig_size);
sig_hex = rpmhex(sig, *sig_size);
sig_base64 = rpmBase64Encode(sig, *sig_size, -1);
rpmlog(RPMLOG_DEBUG, _("%s: sig_size(%li), base64_size(%li), idx %i: signature:\n%s\n"),
rpmfiFN(fi), *sig_size, strlen(sig_base64), rpmfiFX(fi), sig_hex);