X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-xmlsec.c;h=fe1a5818d3cdfff2fce49ce644a8c28ed69ff95d;hb=2a319cf90daa6e3b01e8139923f7073e1c9bcf28;hp=31223cac9a4e7df8e2b0b8a324f59ef575f0f267;hpb=41e3ea4dbae634ca13941d134e990d953b741c4b;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-xmlsec.c b/src/wgtpkg-xmlsec.c index 31223ca..fe1a581 100644 --- a/src/wgtpkg-xmlsec.c +++ b/src/wgtpkg-xmlsec.c @@ -1,5 +1,7 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2019 IoT.bzh + + author: José Bollo Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -33,15 +35,15 @@ #include "verbose.h" -#include "wgtpkg.h" +#include "wgtpkg-files.h" +#include "wgtpkg-workdir.h" +#include "wgtpkg-xmlsec.h" static int initstatus; static int initdone; static xmlSecKeysMngrPtr keymgr; -#ifndef CA_ROOT_DIRECTORY -#define CA_ROOT_DIRECTORY "./ca-certificates" -#endif +static const char trusted_certificates_directory[] = WGTPKG_TRUSTED_CERT_DIR; /* checks if a file match uri (should not be a distributor signature) */ static int file_match_cb(const char *uri) @@ -78,7 +80,7 @@ static void *file_open_cb(const char *file) /* read the opened file */ static int file_read_cb(void *context, char *buffer, int len) { - size_t r = fread(buffer, 1, len, (FILE*)context); + size_t r = fread(buffer, 1, (unsigned)len, (FILE*)context); return r ? (int)r : feof((FILE*)context) ? 0 : - 1; } @@ -190,7 +192,7 @@ int xmlsec_init() ERROR("xmlSecCryptoAppDefaultKeysMngrInit failed."); goto end; } - fill_trusted_keys_dir(CA_ROOT_DIRECTORY); + fill_trusted_keys_dir(trusted_certificates_directory); initstatus = 0; end: @@ -272,7 +274,7 @@ static const struct { const char *id; const char *xml; } properties[2] = { /* 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 */ -xmlDocPtr xmlsec_create(int index, const char *key, const char **certs) +xmlDocPtr xmlsec_create(unsigned int index, const char *key, const char **certs) { unsigned int i, fc, mask; struct filedesc *fdesc;