summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2021-11-29 14:01:39 +0200
committerPanu Matilainen <pmatilai@redhat.com>2021-12-02 10:39:38 +0200
commit0c1ad364d65c4144ff71c376e0b49fbc322b686d (patch)
tree7505498450c7294c6a2defe319abe7b1d92fef80 /python
parent0df9abd174147c8f20bbb5b190fbb6c572d03207 (diff)
downloadrpm-0c1ad364d65c4144ff71c376e0b49fbc322b686d.tar.gz
Add Python bindings for rpmfilesFSignature() and rpmfilesVSignature()
Only, use more descriptive names than the C-side counterparts. Python has nice facilities for dealing with binary data so return it as such rather than converting to hex.
Diffstat (limited to 'python')
-rw-r--r--python/rpmfiles-py.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/python/rpmfiles-py.c b/python/rpmfiles-py.c
index 84f3dc72f..2d8c2111a 100644
--- a/python/rpmfiles-py.c
+++ b/python/rpmfiles-py.c
@@ -152,6 +152,29 @@ static PyObject *rpmfile_digest(rpmfileObject *s)
Py_RETURN_NONE;
}
+static PyObject *bytebuf(const unsigned char *buf, size_t len)
+{
+ if (buf) {
+ PyObject *o = PyBytes_FromStringAndSize((const char *)buf, len);
+ return o;
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *rpmfile_imasig(rpmfileObject *s)
+{
+ size_t len = 0;
+ const unsigned char *sig = rpmfilesFSignature(s->files, s->ix, &len);
+ return bytebuf(sig, len);
+}
+
+static PyObject *rpmfile_veritysig(rpmfileObject *s)
+{
+ size_t len = 0;
+ const unsigned char *sig = rpmfilesVSignature(s->files, s->ix, &len, NULL);
+ return bytebuf(sig, len);
+}
+
static PyObject *rpmfile_class(rpmfileObject *s)
{
return utf8FromString(rpmfilesFClass(s->files, s->ix));
@@ -278,6 +301,10 @@ static PyGetSetDef rpmfile_getseters[] = {
"language the file provides (typically for doc files)" },
{ "caps", (getter) rpmfile_caps, NULL,
"file capabilities" },
+ { "imasig", (getter) rpmfile_imasig, NULL,
+ "IMA signature" },
+ { "veritysig", (getter) rpmfile_veritysig, NULL,
+ "Verity signature" },
{ NULL, NULL, NULL, NULL }
};