Initial revision
authormarc <devnull@localhost>
Mon, 19 Feb 1996 02:19:18 +0000 (02:19 +0000)
committermarc <devnull@localhost>
Mon, 19 Feb 1996 02:19:18 +0000 (02:19 +0000)
CVS patchset: 303
CVS date: 1996/02/19 02:19:18

tools/rpmchecksig.c [new file with mode: 0644]
tools/rpmsignature.c [new file with mode: 0644]

diff --git a/tools/rpmchecksig.c b/tools/rpmchecksig.c
new file mode 100644 (file)
index 0000000..2ad4ae2
--- /dev/null
@@ -0,0 +1,40 @@
+/* rpmchecksig: verify the signature of an RPM */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "rpmlib.h"
+#include "rpmlead.h"
+#include "signature.h"
+
+int main(int argc, char **argv)
+{
+    int fd;
+    struct rpmlead lead;
+    char *sig;
+    char result[1024];
+    int res;
+    
+    if (argc == 1) {
+       fd = 0;
+    } else {
+       fd = open(argv[1], O_RDONLY, 0644);
+    }
+
+    /* Need this for any PGP settings */
+    if (readConfigFiles())
+       exit(-1);
+
+    readLead(fd, &lead);
+    readSignature(fd, lead.signature_type, (void **) &sig);
+    res = verifySignature(fd, lead.signature_type, sig, result);
+    printf("%s", result);
+    if (res) {
+       printf("Signature OK.\n");
+       return 0;
+    } else {
+       printf("Signature NOT OK!\n");
+       return 1;
+    }
+}
diff --git a/tools/rpmsignature.c b/tools/rpmsignature.c
new file mode 100644 (file)
index 0000000..7b4b1a1
--- /dev/null
@@ -0,0 +1,32 @@
+/* rpmsignature: spit out the signature portion of a package */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "rpmlead.h"
+#include "signature.h"
+
+int main(int argc, char **argv)
+{
+    int fd;
+    struct rpmlead lead;
+    char *sig;
+    
+    if (argc == 1) {
+       fd = 0;
+    } else {
+       fd = open(argv[1], O_RDONLY, 0644);
+    }
+
+    readLead(fd, &lead);
+    readSignature(fd, lead.signature_type, (void **) &sig);
+    switch (lead.signature_type) {
+    case RPMSIG_NONE:
+       break;
+    case RPMSIG_PGP262_1024:
+       write(1, sig, 152);
+    }
+    
+    return 0;
+}