Axe pgpDig and related APIs

These haven't been used by rpm in years but have been left to linger,
perhaps for too long. Bye now.
This commit is contained in:
Panu Matilainen 2022-04-07 14:46:06 +03:00
parent ae7ef1a433
commit 87c4eee816
3 changed files with 0 additions and 157 deletions

View File

@ -25,10 +25,6 @@
extern "C" { extern "C" {
#endif #endif
/** \ingroup rpmpgp
*/
typedef struct pgpDig_s * pgpDig;
/** \ingroup rpmpgp /** \ingroup rpmpgp
*/ */
typedef struct pgpDigParams_s * pgpDigParams; typedef struct pgpDigParams_s * pgpDigParams;
@ -1025,17 +1021,6 @@ int pgpPrtParams(const uint8_t *pkts, size_t pktlen, unsigned int pkttype,
int pgpPrtParamsSubkeys(const uint8_t *pkts, size_t pktlen, int pgpPrtParamsSubkeys(const uint8_t *pkts, size_t pktlen,
pgpDigParams mainkey, pgpDigParams **subkeys, pgpDigParams mainkey, pgpDigParams **subkeys,
int *subkeysCount); int *subkeysCount);
/** \ingroup rpmpgp
* Print/parse a OpenPGP packet(s).
* @deprecated Obsolete, do not use.
*
* @param pkts OpenPGP packet(s)
* @param pktlen OpenPGP packet(s) length (no. of bytes)
* @param[out] dig parsed output of signature/pubkey packet parameters
* @param printing should packets be printed?
* @return -1 on error, 0 on success
*/
int pgpPrtPkts(const uint8_t *pkts, size_t pktlen, pgpDig dig, int printing);
/** \ingroup rpmpgp /** \ingroup rpmpgp
* Parse armored OpenPGP packets from a file. * Parse armored OpenPGP packets from a file.
@ -1078,39 +1063,6 @@ int pgpPubKeyCertLen(const uint8_t *pkts, size_t pktslen, size_t *certlen);
*/ */
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns); char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns);
/** \ingroup rpmpgp
* Create a container for parsed OpenPGP packet(s).
* @deprecated Obsolete, do not use.
*
* @return container
*/
pgpDig pgpNewDig(void);
/** \ingroup rpmpgp
* Release (malloc'd) data from container.
* @deprecated Obsolete, do not use.
*
* @param dig container
*/
void pgpCleanDig(pgpDig dig);
/** \ingroup rpmpgp
* Destroy a container for parsed OpenPGP packet(s).
* @deprecated Obsolete, do not use.
*
* @param dig container
* @return NULL always
*/
pgpDig pgpFreeDig(pgpDig dig);
/** \ingroup rpmpgp
* Retrieve parameters for parsed OpenPGP packet(s).
* @param dig container
* @param pkttype type of params to retrieve (signature / pubkey)
* @return pointer to OpenPGP parameters, NULL on error/not found
*/
pgpDigParams pgpDigGetParams(pgpDig dig, unsigned int pkttype);
/** \ingroup rpmpgp /** \ingroup rpmpgp
* Compare OpenPGP packet parameters * Compare OpenPGP packet parameters
* param p1 1st parameter container * param p1 1st parameter container
@ -1208,16 +1160,6 @@ pgpDigParams pgpDigParamsFree(pgpDigParams digp);
*/ */
rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx); rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx);
/** \ingroup rpmpgp
* Verify a PGP signature.
* @deprecated use pgpVerifySignature() instead
*
* @param dig container
* @param hashctx digest context
* @return RPMRC_OK on success
*/
rpmRC pgpVerifySig(pgpDig dig, DIGEST_CTX hashctx);
/** \ingroup rpmpgp /** \ingroup rpmpgp
* Return the type of a PGP signature. If `sig` is NULL, or is not a signature, * Return the type of a PGP signature. If `sig` is NULL, or is not a signature,
* returns -1. * returns -1.

View File

@ -451,26 +451,6 @@ rpmts_HdrCheck(rpmtsObject * s, PyObject *obj)
return Py_BuildValue("(iN)", rpmrc, utf8FromString(msg)); return Py_BuildValue("(iN)", rpmrc, utf8FromString(msg));
} }
static PyObject *
rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args, PyObject * kwds)
{
PyObject * blob;
unsigned char * pkt;
unsigned int pktlen;
int rc;
char * kwlist[] = {"octets", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:PgpPrtPkts", kwlist, &blob))
return NULL;
pkt = (unsigned char *)PyBytes_AsString(blob);
pktlen = PyBytes_Size(blob);
rc = pgpPrtPkts(pkt, pktlen, NULL, 1);
return Py_BuildValue("i", rc);
}
static PyObject * static PyObject *
rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args, PyObject * kwds) rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args, PyObject * kwds)
{ {
@ -834,8 +814,6 @@ Remove all elements from the transaction set\n" },
"the digest or signature is verified.\n\n" "the digest or signature is verified.\n\n"
"\thdrblob : unloaded header blob\n" "\thdrblob : unloaded header blob\n"
"Return tuple (int status, message string)"}, "Return tuple (int status, message string)"},
{"pgpPrtPkts", (PyCFunction) rpmts_PgpPrtPkts, METH_VARARGS|METH_KEYWORDS,
"pgpPrtPkts(octets) -- Print/parse a OpenPGP packet(s).\n\nReturn 0 on success." },
{"pgpImportPubkey", (PyCFunction) rpmts_PgpImportPubkey, METH_VARARGS|METH_KEYWORDS, {"pgpImportPubkey", (PyCFunction) rpmts_PgpImportPubkey, METH_VARARGS|METH_KEYWORDS,
"pgpImportPubkey(pubkey) -- Import public key packet." }, "pgpImportPubkey(pubkey) -- Import public key packet." },
{"getKeyring", (PyCFunction) rpmts_getKeyring, METH_VARARGS|METH_KEYWORDS, {"getKeyring", (PyCFunction) rpmts_getKeyring, METH_VARARGS|METH_KEYWORDS,

View File

@ -993,13 +993,6 @@ static int pgpPrtPkt(struct pgpPkt *p, pgpDigParams _digp)
return rc; return rc;
} }
pgpDig pgpNewDig(void)
{
pgpDig dig = xcalloc(1, sizeof(*dig));
return dig;
}
pgpDigParams pgpDigParamsFree(pgpDigParams digp) pgpDigParams pgpDigParamsFree(pgpDigParams digp)
{ {
if (digp) { if (digp) {
@ -1012,43 +1005,6 @@ pgpDigParams pgpDigParamsFree(pgpDigParams digp)
return NULL; return NULL;
} }
void pgpCleanDig(pgpDig dig)
{
if (dig != NULL) {
pgpDigParamsFree(dig->signature);
pgpDigParamsFree(dig->pubkey);
memset(dig, 0, sizeof(*dig));
}
return;
}
pgpDig pgpFreeDig(pgpDig dig)
{
if (dig != NULL) {
/* DUmp the signature/pubkey data. */
pgpCleanDig(dig);
dig = _free(dig);
}
return dig;
}
pgpDigParams pgpDigGetParams(pgpDig dig, unsigned int pkttype)
{
pgpDigParams params = NULL;
if (dig) {
switch (pkttype) {
case PGPTAG_SIGNATURE:
params = dig->signature;
break;
case PGPTAG_PUBLIC_KEY:
params = dig->pubkey;
break;
}
}
return params;
}
int pgpDigParamsCmp(pgpDigParams p1, pgpDigParams p2) int pgpDigParamsCmp(pgpDigParams p1, pgpDigParams p2)
{ {
int rc = 1; /* assume different, eg if either is NULL */ int rc = 1; /* assume different, eg if either is NULL */
@ -1349,30 +1305,6 @@ int pgpPrtParamsSubkeys(const uint8_t *pkts, size_t pktlen,
return rc; return rc;
} }
int pgpPrtPkts(const uint8_t * pkts, size_t pktlen, pgpDig dig, int printing)
{
int rc;
pgpDigParams digp = NULL;
_print = printing;
rc = pgpPrtParams(pkts, pktlen, 0, &digp);
if (dig && rc == 0) {
if (digp->tag == PGPTAG_SIGNATURE) {
pgpDigParamsFree(dig->signature);
dig->signature = digp;
} else {
pgpDigParamsFree(dig->pubkey);
dig->pubkey = digp;
}
} else {
pgpDigParamsFree(digp);
}
return rc;
}
char *pgpIdentItem(pgpDigParams digp) char *pgpIdentItem(pgpDigParams digp)
{ {
char *id = NULL; char *id = NULL;
@ -1447,15 +1379,6 @@ exit:
} }
rpmRC pgpVerifySig(pgpDig dig, DIGEST_CTX hashctx)
{
if (dig == NULL || hashctx == NULL)
return RPMRC_FAIL;
return pgpVerifySignature(pgpDigGetParams(dig, PGPTAG_PUBLIC_KEY),
pgpDigGetParams(dig, PGPTAG_SIGNATURE), hashctx);
}
static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen) static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen)
{ {
const char * enc = NULL; const char * enc = NULL;