wgtpkg-digsig: Fix digital signature check
[src/app-framework-main.git] / src / wgtpkg-digsig.c
index a146741..a1cb55f 100644 (file)
@@ -1,5 +1,7 @@
 /*
- Copyright 2015 IoT.bzh
+ Copyright (C) 2015-2018 IoT.bzh
+
+ author: José Bollo <jose.bollo@iot.bzh>
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
 
 
 #include "verbose.h"
-#include "wgtpkg.h"
+#include "wgtpkg-files.h"
+#include "wgtpkg-workdir.h"
+#include "wgtpkg-certs.h"
+#include "wgtpkg-xmlsec.h"
+#include "wgtpkg-digsig.h"
 
 
 
@@ -341,7 +347,7 @@ int check_all_signatures()
        for (i = n ; i-- > 0 ; ) {
                fdesc = signature_of_index(i);
                irc = verify_digsig(fdesc);
-               if (!irc)
+               if (irc < 0)
                        rc = irc;
        }
 
@@ -351,11 +357,12 @@ int check_all_signatures()
 /* create a signature of 'index' (0 for author, other values for distributors)
 using the private 'key' (filename) and the certificates 'certs' (filenames)
 as trusted chain */
-int create_digsig(int index, const char *key, const char **certs)
+int create_digsig(unsigned int index, const char *key, const char **certs)
 {
        struct filedesc *fdesc;
        xmlDocPtr doc;
-       int rc, len, fd;
+       int rc, fd;
+       long len;
        xmlSaveCtxtPtr ctx;
 
        rc = -1;