From b40aa9f6f936e65a0e357a866da6198eb33d88bc Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 27 Nov 2024 12:27:08 +0100 Subject: [PATCH] Add rpmPubkeyRawData() Don't make stuffing this into a rpmPubkey object a one-way street. --- include/rpm/rpmkeyring.h | 9 +++++++++ rpmio/rpmkeyring.cc | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/rpm/rpmkeyring.h b/include/rpm/rpmkeyring.h index cfcbe59342..7da8febe84 100644 --- a/include/rpm/rpmkeyring.h +++ b/include/rpm/rpmkeyring.h @@ -134,6 +134,15 @@ rpmPubkey rpmPubkeyFree(rpmPubkey key); */ rpmPubkey rpmPubkeyLink(rpmPubkey key); + +/** \ingroup rpmkeyring + * Return pubkey as raw bytes + * @param key Pubkey + * @param pkt key data + * @param pktlen Length of key data + */ +void rpmPubkeyRawData(rpmPubkey key, unsigned const char ** pkt, size_t * pktlen); + /** \ingroup rpmkeyring * Return base64 encoding of pubkey * @param key Pubkey diff --git a/rpmio/rpmkeyring.cc b/rpmio/rpmkeyring.cc index 4b872869c7..4e08e97f76 100644 --- a/rpmio/rpmkeyring.cc +++ b/rpmio/rpmkeyring.cc @@ -366,6 +366,17 @@ rpmPubkey rpmPubkeyLink(rpmPubkey key) return key; } +void rpmPubkeyRawData(rpmPubkey key, unsigned const char ** pkt, size_t * pktlen) +{ + if (key) { + *pkt = key->pkt.data(); + *pktlen = key->pkt.size(); + } else { + *pkt = NULL; + *pktlen = 0; + } +} + char * rpmPubkeyBase64(rpmPubkey key) { char *enc = NULL;