summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2022-03-29 13:41:18 +0200
committerPanu Matilainen <pmatilai@redhat.com>2022-08-17 13:50:46 +0300
commit6cf5f07958889e2ee99ce04dd203ef7db4700eb3 (patch)
tree802fe47b209a3f15debc557249334e4c0f4039a1 /include
parentbb5a196f7b94a156a20c13ab64e4e89e84c038eb (diff)
downloadrpm-6cf5f07958889e2ee99ce04dd203ef7db4700eb3.tar.gz
Before importing an OpenPGP certificate, lint it
When importing an OpenPGP certificate, lint the certificate to show the user possible issues. Fail if the certificate is completely unusable. Using the Sequoia backend, this yields, for instance: $ ./rpmkeys --import tests/data/keys/alice-revoked-subkey.asc Certificate B3A771BFEB04E625: Subkey 1F71177215217EE0 was revoked: Key material has been compromised, it was the maid Certificate does not have any usable signing keys Fixes #1974. (cherry pick d703160334ff545ce8bf7475da5689422f43dacc)
Diffstat (limited to 'include')
-rw-r--r--include/rpm/rpmpgp.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/rpm/rpmpgp.h b/include/rpm/rpmpgp.h
index 7e0daf5ab..a3238a643 100644
--- a/include/rpm/rpmpgp.h
+++ b/include/rpm/rpmpgp.h
@@ -1070,6 +1070,32 @@ pgpArmor pgpParsePkts(const char *armor, uint8_t ** pkt, size_t * pktlen);
int pgpPubKeyCertLen(const uint8_t *pkts, size_t pktslen, size_t *certlen);
/** \ingroup rpmpgp
+ * Lints the certificate.
+ *
+ * There are four cases:
+ *
+ * The packets do not describe a certificate: returns an error and
+ * sets *explanation to NULL.
+ *
+ * The packets describe a certificate and the certificate is
+ * completely unusable: returns an error and sets *explanation to a
+ * human readable explanation.
+ *
+ * The packets describe a certificate and some components are not
+ * usable: returns success, and sets *explanation to a human readable
+ * explanation.
+ *
+ * The packets describe a certificate and there are no lints: returns
+ * success, and sets *explanation to NULL.
+ *
+ * @param pkts OpenPGP pointer to a buffer with certificates
+ * @param pktslen length of the buffer with certificates
+ * @param[out] explanation An optional lint to display to the user.
+ * @return RPMRC_OK on success
+ */
+rpmRC pgpPubKeyLint(const uint8_t *pkts, size_t pktslen, char **explanation);
+
+/** \ingroup rpmpgp
* Wrap a OpenPGP packets in ascii armor for transport.
* @param atype type of armor
* @param s binary pkt data