Add beginnings of a real API to librpmsign
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 13 Oct 2010 10:11:54 +0000 (13:11 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 13 Oct 2010 10:23:40 +0000 (13:23 +0300)
lib/rpmgensig.c
lib/rpmsign.h

index 88946e5..aa0fb7f 100644 (file)
@@ -608,6 +608,29 @@ exit:
     return res;
 }
 
+int rpmPkgSign(const char *path,
+               const struct rpmSignArgs * args, const char *passPhrase)
+{
+    int rc;
+
+    if (args && args->keyid) {
+       addMacro(NULL, "_gpg_name", NULL, args->keyid, RMIL_GLOBAL);
+    }
+
+    rc = rpmSign(path, 0, passPhrase);
+
+    if (args && args->keyid) {
+       delMacro(NULL, "_gpg_name");
+    }
+
+    return rc;
+}
+
+int rpmPkgDelSign(const char *path)
+{
+    return rpmSign(path, 1, NULL);
+}
+
 int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase)
 {
     int res = 0;
index f961b19..43b9654 100644 (file)
@@ -2,6 +2,7 @@
 #define _RPMSIGN_H
 
 #include <rpm/argv.h>
+#include <rpm/rpmpgp.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -16,6 +17,29 @@ extern "C" {
  */
 int rpmcliSign(ARGV_const_t argv, int deleting, const char *passPhrase);
 
+struct rpmSignArgs {
+    char *keyid;
+    pgpHashAlgo hashalgo;
+    /* ... what else? */
+};
+
+/** \ingroup rpmsign
+ * Sign a package
+ * @param path         path to package
+ * @param args         signing parameters (or NULL for defaults)
+ * @param passphrase   passphrase for the signing key
+ * @return             0 on success
+ */
+int rpmPkgSign(const char *path,
+              const struct rpmSignArgs * args, const char *passPhrase);
+
+/** \ingroup rpmsign
+ * Delete signature(s) from a package
+ * @param path         path to package
+ * @return             0 on success
+ */
+int rpmPkgDelSign(const char *path);
+
 #ifdef __cplusplus
 }
 #endif