experimental: facho-signer: xml layout
FossilOrigin-Name: 6fda6ceb8a3fd6d45cd68601b4608b9ce3a8f8af0eb79b99f9ec73a20a8023b3
This commit is contained in:
parent
1a302f605f
commit
dd445b59f0
7
experimental/facho-signer/xades/Makefile
Normal file
7
experimental/facho-signer/xades/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
.PHONY: test
|
||||
|
||||
CC=gcc
|
||||
|
||||
test: xmlsec1/errors.c xmlsec1/xmltree.c xades.c xades_test.c
|
||||
$(CC) -o $@ -Wall $(shell pkg-config libxml-2.0 --cflags --libs) $(shell pkg-config xmlsec1 --cflags --libs) $^
|
||||
./test
|
391
experimental/facho-signer/xades/minunit.h
Normal file
391
experimental/facho-signer/xades/minunit.h
Normal file
@ -0,0 +1,391 @@
|
||||
/*
|
||||
* Copyright (c) 2012 David Siñuela Pastor, siu.4coders@gmail.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef MINUNIT_MINUNIT_H
|
||||
#define MINUNIT_MINUNIT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
|
||||
|
||||
/* Change POSIX C SOURCE version for pure c99 compilers */
|
||||
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
|
||||
#include <unistd.h> /* POSIX flags */
|
||||
#include <time.h> /* clock_gettime(), time() */
|
||||
#include <sys/time.h> /* gethrtime(), gettimeofday() */
|
||||
#include <sys/resource.h>
|
||||
#include <sys/times.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__MACH__) && defined(__APPLE__)
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 5 && !defined(__STDC_VERSION__)
|
||||
#define __func__ __extension__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "Unable to define timers for an unknown OS."
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Maximum length of last message */
|
||||
#define MINUNIT_MESSAGE_LEN 1024
|
||||
/* Accuracy with which floats are compared */
|
||||
#define MINUNIT_EPSILON 1E-12
|
||||
|
||||
/* Misc. counters */
|
||||
static int minunit_run = 0;
|
||||
static int minunit_assert = 0;
|
||||
static int minunit_fail = 0;
|
||||
static int minunit_status = 0;
|
||||
|
||||
/* Timers */
|
||||
static double minunit_real_timer = 0;
|
||||
static double minunit_proc_timer = 0;
|
||||
|
||||
/* Last message */
|
||||
static char minunit_last_message[MINUNIT_MESSAGE_LEN];
|
||||
|
||||
/* Test setup and teardown function pointers */
|
||||
static void (*minunit_setup)(void) = NULL;
|
||||
static void (*minunit_teardown)(void) = NULL;
|
||||
|
||||
/* Definitions */
|
||||
#define MU_TEST(method_name) static void method_name(void)
|
||||
#define MU_TEST_SUITE(suite_name) static void suite_name(void)
|
||||
|
||||
#define MU__SAFE_BLOCK(block) do {\
|
||||
block\
|
||||
} while(0)
|
||||
|
||||
/* Run test suite and unset setup and teardown functions */
|
||||
#define MU_RUN_SUITE(suite_name) MU__SAFE_BLOCK(\
|
||||
suite_name();\
|
||||
minunit_setup = NULL;\
|
||||
minunit_teardown = NULL;\
|
||||
)
|
||||
|
||||
/* Configure setup and teardown functions */
|
||||
#define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) MU__SAFE_BLOCK(\
|
||||
minunit_setup = setup_fun;\
|
||||
minunit_teardown = teardown_fun;\
|
||||
)
|
||||
|
||||
/* Test runner */
|
||||
#define MU_RUN_TEST(test) MU__SAFE_BLOCK(\
|
||||
if (minunit_real_timer==0 && minunit_proc_timer==0) {\
|
||||
minunit_real_timer = mu_timer_real();\
|
||||
minunit_proc_timer = mu_timer_cpu();\
|
||||
}\
|
||||
if (minunit_setup) (*minunit_setup)();\
|
||||
minunit_status = 0;\
|
||||
test();\
|
||||
minunit_run++;\
|
||||
if (minunit_status) {\
|
||||
minunit_fail++;\
|
||||
printf("F");\
|
||||
printf("\n%s\n", minunit_last_message);\
|
||||
}\
|
||||
fflush(stdout);\
|
||||
if (minunit_teardown) (*minunit_teardown)();\
|
||||
)
|
||||
|
||||
/* Report */
|
||||
#define MU_REPORT() MU__SAFE_BLOCK(\
|
||||
double minunit_end_real_timer;\
|
||||
double minunit_end_proc_timer;\
|
||||
printf("\n\n%d tests, %d assertions, %d failures\n", minunit_run, minunit_assert, minunit_fail);\
|
||||
minunit_end_real_timer = mu_timer_real();\
|
||||
minunit_end_proc_timer = mu_timer_cpu();\
|
||||
printf("\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n",\
|
||||
minunit_end_real_timer - minunit_real_timer,\
|
||||
minunit_end_proc_timer - minunit_proc_timer);\
|
||||
)
|
||||
#define MU_EXIT_CODE minunit_fail
|
||||
|
||||
/* Assertions */
|
||||
#define mu_check(test) MU__SAFE_BLOCK(\
|
||||
minunit_assert++;\
|
||||
if (!(test)) {\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, #test);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
} else {\
|
||||
printf(".");\
|
||||
}\
|
||||
)
|
||||
|
||||
#define mu_fail(message) MU__SAFE_BLOCK(\
|
||||
minunit_assert++;\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
)
|
||||
|
||||
#define mu_assert(test, message) MU__SAFE_BLOCK(\
|
||||
minunit_assert++;\
|
||||
if (!(test)) {\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
} else {\
|
||||
printf(".");\
|
||||
}\
|
||||
)
|
||||
|
||||
#define mu_assert_int_eq(expected, result) MU__SAFE_BLOCK(\
|
||||
int minunit_tmp_e;\
|
||||
int minunit_tmp_r;\
|
||||
minunit_assert++;\
|
||||
minunit_tmp_e = (expected);\
|
||||
minunit_tmp_r = (result);\
|
||||
if (minunit_tmp_e != minunit_tmp_r) {\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d expected but was %d", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
} else {\
|
||||
printf(".");\
|
||||
}\
|
||||
)
|
||||
|
||||
#define mu_assert_double_eq(expected, result) MU__SAFE_BLOCK(\
|
||||
double minunit_tmp_e;\
|
||||
double minunit_tmp_r;\
|
||||
minunit_assert++;\
|
||||
minunit_tmp_e = (expected);\
|
||||
minunit_tmp_r = (result);\
|
||||
if (fabs(minunit_tmp_e-minunit_tmp_r) > MINUNIT_EPSILON) {\
|
||||
int minunit_significant_figures = 1 - log10(MINUNIT_EPSILON);\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %.*g expected but was %.*g", __func__, __FILE__, __LINE__, minunit_significant_figures, minunit_tmp_e, minunit_significant_figures, minunit_tmp_r);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
} else {\
|
||||
printf(".");\
|
||||
}\
|
||||
)
|
||||
|
||||
#define mu_assert_string_eq(expected, result) MU__SAFE_BLOCK(\
|
||||
const char* minunit_tmp_e = expected;\
|
||||
const char* minunit_tmp_r = result;\
|
||||
minunit_assert++;\
|
||||
if (!minunit_tmp_e) {\
|
||||
minunit_tmp_e = "<null pointer>";\
|
||||
}\
|
||||
if (!minunit_tmp_r) {\
|
||||
minunit_tmp_r = "<null pointer>";\
|
||||
}\
|
||||
if(strcmp(minunit_tmp_e, minunit_tmp_r)) {\
|
||||
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: '%s' expected but was '%s'", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\
|
||||
minunit_status = 1;\
|
||||
return;\
|
||||
} else {\
|
||||
printf(".");\
|
||||
}\
|
||||
)
|
||||
|
||||
/*
|
||||
* The following two functions were written by David Robert Nadeau
|
||||
* from http://NadeauSoftware.com/ and distributed under the
|
||||
* Creative Commons Attribution 3.0 Unported License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the real time, in seconds, or -1.0 if an error occurred.
|
||||
*
|
||||
* Time is measured since an arbitrary and OS-dependent start time.
|
||||
* The returned real time is only useful for computing an elapsed time
|
||||
* between two calls to this function.
|
||||
*/
|
||||
static double mu_timer_real(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* Windows 2000 and later. ---------------------------------- */
|
||||
LARGE_INTEGER Time;
|
||||
LARGE_INTEGER Frequency;
|
||||
|
||||
QueryPerformanceFrequency(&Frequency);
|
||||
QueryPerformanceCounter(&Time);
|
||||
|
||||
Time.QuadPart *= 1000000;
|
||||
Time.QuadPart /= Frequency.QuadPart;
|
||||
|
||||
return (double)Time.QuadPart / 1000000.0;
|
||||
|
||||
#elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
|
||||
/* HP-UX, Solaris. ------------------------------------------ */
|
||||
return (double)gethrtime( ) / 1000000000.0;
|
||||
|
||||
#elif defined(__MACH__) && defined(__APPLE__)
|
||||
/* OSX. ----------------------------------------------------- */
|
||||
static double timeConvert = 0.0;
|
||||
if ( timeConvert == 0.0 )
|
||||
{
|
||||
mach_timebase_info_data_t timeBase;
|
||||
(void)mach_timebase_info( &timeBase );
|
||||
timeConvert = (double)timeBase.numer /
|
||||
(double)timeBase.denom /
|
||||
1000000000.0;
|
||||
}
|
||||
return (double)mach_absolute_time( ) * timeConvert;
|
||||
|
||||
#elif defined(_POSIX_VERSION)
|
||||
/* POSIX. --------------------------------------------------- */
|
||||
struct timeval tm;
|
||||
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
|
||||
{
|
||||
struct timespec ts;
|
||||
#if defined(CLOCK_MONOTONIC_PRECISE)
|
||||
/* BSD. --------------------------------------------- */
|
||||
const clockid_t id = CLOCK_MONOTONIC_PRECISE;
|
||||
#elif defined(CLOCK_MONOTONIC_RAW)
|
||||
/* Linux. ------------------------------------------- */
|
||||
const clockid_t id = CLOCK_MONOTONIC_RAW;
|
||||
#elif defined(CLOCK_HIGHRES)
|
||||
/* Solaris. ----------------------------------------- */
|
||||
const clockid_t id = CLOCK_HIGHRES;
|
||||
#elif defined(CLOCK_MONOTONIC)
|
||||
/* AIX, BSD, Linux, POSIX, Solaris. ----------------- */
|
||||
const clockid_t id = CLOCK_MONOTONIC;
|
||||
#elif defined(CLOCK_REALTIME)
|
||||
/* AIX, BSD, HP-UX, Linux, POSIX. ------------------- */
|
||||
const clockid_t id = CLOCK_REALTIME;
|
||||
#else
|
||||
const clockid_t id = (clockid_t)-1; /* Unknown. */
|
||||
#endif /* CLOCK_* */
|
||||
if ( id != (clockid_t)-1 && clock_gettime( id, &ts ) != -1 )
|
||||
return (double)ts.tv_sec +
|
||||
(double)ts.tv_nsec / 1000000000.0;
|
||||
/* Fall thru. */
|
||||
}
|
||||
#endif /* _POSIX_TIMERS */
|
||||
|
||||
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, POSIX, Solaris. ----- */
|
||||
gettimeofday( &tm, NULL );
|
||||
return (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0;
|
||||
#else
|
||||
return -1.0; /* Failed. */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of CPU time used by the current process,
|
||||
* in seconds, or -1.0 if an error occurred.
|
||||
*/
|
||||
static double mu_timer_cpu(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* Windows -------------------------------------------------- */
|
||||
FILETIME createTime;
|
||||
FILETIME exitTime;
|
||||
FILETIME kernelTime;
|
||||
FILETIME userTime;
|
||||
|
||||
/* This approach has a resolution of 1/64 second. Unfortunately, Windows' API does not offer better */
|
||||
if ( GetProcessTimes( GetCurrentProcess( ),
|
||||
&createTime, &exitTime, &kernelTime, &userTime ) != 0 )
|
||||
{
|
||||
ULARGE_INTEGER userSystemTime;
|
||||
memcpy(&userSystemTime, &userTime, sizeof(ULARGE_INTEGER));
|
||||
return (double)userSystemTime.QuadPart / 10000000.0;
|
||||
}
|
||||
|
||||
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
|
||||
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, and Solaris --------- */
|
||||
|
||||
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
|
||||
/* Prefer high-res POSIX timers, when available. */
|
||||
{
|
||||
clockid_t id;
|
||||
struct timespec ts;
|
||||
#if _POSIX_CPUTIME > 0
|
||||
/* Clock ids vary by OS. Query the id, if possible. */
|
||||
if ( clock_getcpuclockid( 0, &id ) == -1 )
|
||||
#endif
|
||||
#if defined(CLOCK_PROCESS_CPUTIME_ID)
|
||||
/* Use known clock id for AIX, Linux, or Solaris. */
|
||||
id = CLOCK_PROCESS_CPUTIME_ID;
|
||||
#elif defined(CLOCK_VIRTUAL)
|
||||
/* Use known clock id for BSD or HP-UX. */
|
||||
id = CLOCK_VIRTUAL;
|
||||
#else
|
||||
id = (clockid_t)-1;
|
||||
#endif
|
||||
if ( id != (clockid_t)-1 && clock_gettime( id, &ts ) != -1 )
|
||||
return (double)ts.tv_sec +
|
||||
(double)ts.tv_nsec / 1000000000.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(RUSAGE_SELF)
|
||||
{
|
||||
struct rusage rusage;
|
||||
if ( getrusage( RUSAGE_SELF, &rusage ) != -1 )
|
||||
return (double)rusage.ru_utime.tv_sec +
|
||||
(double)rusage.ru_utime.tv_usec / 1000000.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_SC_CLK_TCK)
|
||||
{
|
||||
const double ticks = (double)sysconf( _SC_CLK_TCK );
|
||||
struct tms tms;
|
||||
if ( times( &tms ) != (clock_t)-1 )
|
||||
return (double)tms.tms_utime / ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CLOCKS_PER_SEC)
|
||||
{
|
||||
clock_t cl = clock( );
|
||||
if ( cl != (clock_t)-1 )
|
||||
return (double)cl / (double)CLOCKS_PER_SEC;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return -1; /* Failed. */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MINUNIT_MINUNIT_H */
|
13
experimental/facho-signer/xades/minunit_ext.h
Normal file
13
experimental/facho-signer/xades/minunit_ext.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef MINUNIT_EXT_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "minunit.h"
|
||||
|
||||
// cuando escribe esto el compilar me arrojo que si no era
|
||||
// mejor usar mu_assert_string_eq increble a
|
||||
//int mu_assert_string_equals(const char *a, const char *b) {
|
||||
// return mu_assert(strcmp(a, b) == 0, "string not equals");
|
||||
//}
|
||||
|
||||
#endif //MINUNIT_EXT_H
|
115
experimental/facho-signer/xades/xades.c
Normal file
115
experimental/facho-signer/xades/xades.c
Normal file
@ -0,0 +1,115 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "xades.h"
|
||||
|
||||
#define xmlXadesAssert2(p, ret) \
|
||||
xmlSecAssert2(p, ret)
|
||||
|
||||
#define xmlXadesNodeNotFoundError(errorFunction, startNode, targetNodeName, errorObject) \
|
||||
xmlSecNodeNotFoundError(errorFunction, startNode, targetNodeName, errorObject)
|
||||
|
||||
#define xmlXadesError2(errorFunction, errorObject, msg, param) \
|
||||
xmlSecXmlError2(errorFunction, errorObject, msg, param)
|
||||
|
||||
#define xmlXadesErrorsSafeString(msg) \
|
||||
xmlSecErrorsSafeString(msg)
|
||||
|
||||
#define xmlXadesInternalError(errorFunction, errorObject) \
|
||||
xmlSecInternalError(errorFunction, errorObject)
|
||||
|
||||
|
||||
xmlNodePtr
|
||||
xmlXadesTmplQualifyingPropertiesCreateNsPref(xmlDocPtr doc, const xmlChar* id, const xmlChar* nsPrefix) {
|
||||
xmlNodePtr qualifyingPropertiesNode;
|
||||
xmlNodePtr cur;
|
||||
xmlNsPtr ns;
|
||||
|
||||
// crear nodo
|
||||
qualifyingPropertiesNode = xmlNewDocNode(doc, NULL, xmlXadesNodeQualifyingProperties, NULL);
|
||||
if (qualifyingPropertiesNode == NULL) {
|
||||
xmlXadesError2("xmlNewDocNode", NULL, "node=%s", xmlXadesErrorsSafeString(xmlXadesNodeQualifyingProperties));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// crear namespace y asignar
|
||||
ns = xmlNewNs(qualifyingPropertiesNode, xmlXadesDSigNs, nsPrefix);
|
||||
if (ns == NULL) {
|
||||
xmlXadesError2("xmlNewNs", NULL,
|
||||
"ns=%s", xmlXadesErrorsSafeString(xmlXadesDSigNs));
|
||||
xmlFreeNode(qualifyingPropertiesNode);
|
||||
return(NULL);
|
||||
}
|
||||
xmlSetNs(qualifyingPropertiesNode, ns);
|
||||
|
||||
if (id != NULL) {
|
||||
xmlSetProp(qualifyingPropertiesNode, BAD_CAST "id", id);
|
||||
}
|
||||
|
||||
// add SignedProperties
|
||||
cur = xmlSecAddChild(qualifyingPropertiesNode, xmlXadesNodeSignedProperties, xmlXadesDSigNs);
|
||||
if (cur == NULL) {
|
||||
xmlXadesInternalError("xmlSecAddChild(xmlXadesNodeSignedProperties)", NULL);
|
||||
xmlFreeNode(qualifyingPropertiesNode);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
return (qualifyingPropertiesNode);
|
||||
}
|
||||
|
||||
xmlNodePtr
|
||||
xmlXadesTmplAddSignedSignatureProperties(xmlNodePtr parentNode, const xmlChar* id, struct tm* signingTime) {
|
||||
xmlNodePtr cur;
|
||||
xmlNodePtr node;
|
||||
xmlNodePtr signedPropertiesNode;
|
||||
|
||||
xmlXadesAssert2(parentNode != NULL, NULL);
|
||||
|
||||
signedPropertiesNode = xmlSecFindChild(parentNode, xmlXadesNodeSignedProperties, xmlXadesDSigNs);
|
||||
if (signedPropertiesNode == NULL) {
|
||||
xmlXadesNodeNotFoundError("xmlSecFindChild", parentNode,
|
||||
xmlXadesNodeSignedProperties, NULL);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// add SignedSignatureProperties
|
||||
node = xmlSecAddChild(signedPropertiesNode, xmlXadesNodeSignedSignatureProperties, xmlXadesDSigNs);
|
||||
if (node == NULL) {
|
||||
xmlXadesInternalError("xmlSecAddChild(xmlXadesNodeSignedSignatureProperties)", NULL);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (id != NULL) {
|
||||
xmlSetProp(node, BAD_CAST "id", id);
|
||||
}
|
||||
|
||||
// add SignigTime
|
||||
cur = xmlSecAddChild(node, xmlXadesNodeSigningTime, xmlXadesDSigNs);
|
||||
if (cur == NULL) {
|
||||
xmlXadesInternalError("xmlSecAddChild(xmlXadesNodeSigningTime)", NULL);
|
||||
xmlFreeNode(node);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
{
|
||||
int ret;
|
||||
char strtime[200];
|
||||
|
||||
if (strftime(strtime, sizeof(strtime), "%Y-%m-%dT%T", signingTime) == 0) {
|
||||
xmlXadesInternalError("strftime", NULL);
|
||||
xmlFreeNode(cur);
|
||||
xmlFreeNode(node);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ret = xmlSecNodeEncodeAndSetContent(cur, BAD_CAST strtime);
|
||||
if (ret < 0) {
|
||||
xmlXadesInternalError("xmlSecNodeEncodeAndSetContent", NULL);
|
||||
xmlFreeNode(cur);
|
||||
xmlFreeNode(node);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(node);
|
||||
}
|
22
experimental/facho-signer/xades/xades.h
Normal file
22
experimental/facho-signer/xades/xades.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef XADES_H
|
||||
#define XADES_H
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include <xmlsec/xmltree.h>
|
||||
|
||||
#include "xmlsec1/errors_helpers.h"
|
||||
|
||||
static const xmlChar xmlXadesNodeQualifyingProperties[] = "QualifyingProperties";
|
||||
static const xmlChar xmlXadesNodeSignedProperties[] = "SignedProperties";
|
||||
|
||||
static const xmlChar xmlXadesNodeSignedSignatureProperties[] = "SignedSignatureProperties";
|
||||
static const xmlChar xmlXadesNodeSigningTime[] = "SigningTime";
|
||||
|
||||
static const xmlChar xmlXadesDSigNs[] = "http://uri.etsi.org/01903/v1.3.2#";
|
||||
|
||||
xmlNodePtr
|
||||
xmlXadesTmplQualifyingPropertiesCreateNsPref(xmlDocPtr doc, const xmlChar* id, const xmlChar* nsPrefix);
|
||||
xmlNodePtr
|
||||
xmlXadesTmplAddSignedSignatureProperties(xmlNodePtr parentNode, const xmlChar* id, struct tm* signingTime);
|
||||
#endif //XADES_H
|
69
experimental/facho-signer/xades/xades_test.c
Normal file
69
experimental/facho-signer/xades/xades_test.c
Normal file
@ -0,0 +1,69 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include "minunit.h"
|
||||
|
||||
#include "xades.h"
|
||||
|
||||
|
||||
|
||||
|
||||
MU_TEST(test_qualifying_properties_layout) {
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr root;
|
||||
xmlNodePtr node;
|
||||
xmlChar* xmlbuff;
|
||||
int buffersize;
|
||||
struct tm tm;
|
||||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_year = 2021 - 1900;
|
||||
tm.tm_mon = 11;
|
||||
tm.tm_mday = 6;
|
||||
tm.tm_hour = 12;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 50;
|
||||
|
||||
|
||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
root = xmlNewNode(NULL, BAD_CAST "root");
|
||||
xmlDocSetRootElement(doc, root);
|
||||
|
||||
node = xmlXadesTmplQualifyingPropertiesCreateNsPref(doc, BAD_CAST "123", NULL);
|
||||
xmlXadesTmplAddSignedSignatureProperties(node, NULL, &tm);
|
||||
mu_check(node != NULL);
|
||||
|
||||
xmlSecAddChildNode(root, node);
|
||||
xmlDocDumpMemory(doc, &xmlbuff, &buffersize);
|
||||
|
||||
// bit4bit: no se como pasar el namespace al root
|
||||
mu_assert_string_eq("<?xml version=\"1.0\"?>\n"
|
||||
"<root>\n"
|
||||
"<QualifyingProperties xmlns=\"http://uri.etsi.org/01903/v1.3.2#\" id=\"123\">\n"
|
||||
"<SignedProperties>\n"
|
||||
"<SignedSignatureProperties>\n"
|
||||
"<SigningTime>2021-12-06T12:00:50</SigningTime>\n"
|
||||
"</SignedSignatureProperties>\n"
|
||||
"</SignedProperties>\n"
|
||||
"</QualifyingProperties>\n"
|
||||
"</root>\n"
|
||||
, (char *)xmlbuff);
|
||||
|
||||
xmlFree(xmlbuff);
|
||||
xmlFreeDoc(doc);
|
||||
}
|
||||
|
||||
MU_TEST(test_check) {
|
||||
mu_check(5 == 7);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_suite) {
|
||||
MU_RUN_TEST(test_check);
|
||||
MU_RUN_TEST(test_qualifying_properties_layout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MU_RUN_SUITE(test_suite);
|
||||
MU_REPORT();
|
||||
return MU_EXIT_CODE;
|
||||
}
|
259
experimental/facho-signer/xades/xmlsec1/errors.c
Normal file
259
experimental/facho-signer/xades/xmlsec1/errors.c
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
* XML Security Library (http://www.aleksey.com/xmlsec).
|
||||
*
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
|
||||
*/
|
||||
/**
|
||||
* SECTION:errors
|
||||
* @Short_description: Error reporting and logging functions.
|
||||
* @Stability: Stable
|
||||
*
|
||||
*/
|
||||
|
||||
#define XMLSEC_PRIVATE 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/xmltree.h>
|
||||
#include <xmlsec/private.h>
|
||||
#include <xmlsec/errors.h>
|
||||
|
||||
/* Must be bigger than fatal_error */
|
||||
#define XMLSEC_ERRORS_BUFFER_SIZE 1024
|
||||
|
||||
/* Must fit into xmlChar[XMLSEC_ERRORS_BUFFER_SIZE] */
|
||||
static const xmlChar fatal_error[] = "Can not format error message";
|
||||
|
||||
typedef struct _xmlSecErrorDescription xmlSecErrorDescription, *xmlSecErrorDescriptionPtr;
|
||||
struct _xmlSecErrorDescription {
|
||||
int errorCode;
|
||||
const char* errorMsg;
|
||||
};
|
||||
|
||||
static xmlSecErrorDescription xmlSecErrorsTable[XMLSEC_ERRORS_MAX_NUMBER + 1] = {
|
||||
{ XMLSEC_ERRORS_R_XMLSEC_FAILED, "xmlsec library function failed" },
|
||||
{ XMLSEC_ERRORS_R_MALLOC_FAILED, "malloc function failed" },
|
||||
{ XMLSEC_ERRORS_R_STRDUP_FAILED, "strdup function failed" },
|
||||
{ XMLSEC_ERRORS_R_CRYPTO_FAILED, "crypto library function failed" },
|
||||
{ XMLSEC_ERRORS_R_XML_FAILED, "libxml2 library function failed" },
|
||||
{ XMLSEC_ERRORS_R_XSLT_FAILED, "libxslt library function failed" },
|
||||
{ XMLSEC_ERRORS_R_IO_FAILED, "io function failed" },
|
||||
{ XMLSEC_ERRORS_R_DISABLED, "feature is disabled" },
|
||||
{ XMLSEC_ERRORS_R_NOT_IMPLEMENTED, "feature is not implemented" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_CONFIG, "invalid configuration" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_SIZE, "invalid size" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_DATA, "invalid data" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_RESULT, "invalid result" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_TYPE, "invalid type" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_OPERATION, "invalid operation" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_STATUS, "invalid status" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_FORMAT, "invalid format" },
|
||||
{ XMLSEC_ERRORS_R_DATA_NOT_MATCH, "data do not match" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_VERSION, "invalid version" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_NODE, "invalid node" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_NODE_CONTENT, "invalid node content" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_NODE_ATTRIBUTE, "invalid node attribute" },
|
||||
{ XMLSEC_ERRORS_R_MISSING_NODE_ATTRIBUTE, "missing node attribute" },
|
||||
{ XMLSEC_ERRORS_R_NODE_ALREADY_PRESENT, "node already present" },
|
||||
{ XMLSEC_ERRORS_R_UNEXPECTED_NODE, "unexpected node" },
|
||||
{ XMLSEC_ERRORS_R_NODE_NOT_FOUND, "node node found" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_TRANSFORM, "invalid transform" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_TRANSFORM_KEY, "invalid transform key" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_URI_TYPE, "invalid URI type" },
|
||||
{ XMLSEC_ERRORS_R_TRANSFORM_SAME_DOCUMENT_REQUIRED, "same document is required for transform" },
|
||||
{ XMLSEC_ERRORS_R_TRANSFORM_DISABLED, "transform is disabled" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_KEY_DATA, "invalid key data" },
|
||||
{ XMLSEC_ERRORS_R_KEY_DATA_NOT_FOUND, "key data is not found" },
|
||||
{ XMLSEC_ERRORS_R_KEY_DATA_ALREADY_EXIST, "key data already exist" },
|
||||
{ XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE, "invalid key data size" },
|
||||
{ XMLSEC_ERRORS_R_KEY_NOT_FOUND, "key is not found" },
|
||||
{ XMLSEC_ERRORS_R_KEYDATA_DISABLED, "key data is disabled" },
|
||||
{ XMLSEC_ERRORS_R_MAX_RETRIEVALS_LEVEL, "maximum key retrieval level" },
|
||||
{ XMLSEC_ERRORS_R_MAX_RETRIEVAL_TYPE_MISMATCH,"key retrieval type mismatch" },
|
||||
{ XMLSEC_ERRORS_R_MAX_ENCKEY_LEVEL, "maximum encrypted key level" },
|
||||
{ XMLSEC_ERRORS_R_CERT_VERIFY_FAILED, "certificate verification failed" },
|
||||
{ XMLSEC_ERRORS_R_CERT_NOT_FOUND, "certificate is not found" },
|
||||
{ XMLSEC_ERRORS_R_CERT_REVOKED, "certificate is revoked" },
|
||||
{ XMLSEC_ERRORS_R_CERT_ISSUER_FAILED, "certificate issuer check failed" },
|
||||
{ XMLSEC_ERRORS_R_CERT_NOT_YET_VALID, "certificate is not yet valid" },
|
||||
{ XMLSEC_ERRORS_R_CERT_HAS_EXPIRED, "certificate has expired" },
|
||||
{ XMLSEC_ERRORS_R_DSIG_NO_REFERENCES, "Reference nodes are not found" },
|
||||
{ XMLSEC_ERRORS_R_DSIG_INVALID_REFERENCE, "Reference verification failed" },
|
||||
{ XMLSEC_ERRORS_R_ASSERTION, "assertion" },
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
static xmlSecErrorsCallback xmlSecErrorsClbk = xmlSecErrorsDefaultCallback;
|
||||
static int xmlSecPrintErrorMessages = 1; /* whether the error messages will be printed immediately */
|
||||
|
||||
/**
|
||||
* xmlSecErrorsInit:
|
||||
*
|
||||
* Initializes the errors reporting. It is called from #xmlSecInit function.
|
||||
* and applications must not call this function directly.
|
||||
*/
|
||||
void
|
||||
xmlSecErrorsInit(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsShutdown:
|
||||
*
|
||||
* Cleanups the errors reporting. It is called from #xmlSecShutdown function.
|
||||
* and applications must not call this function directly.
|
||||
*/
|
||||
void
|
||||
xmlSecErrorsShutdown(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsSetCallback:
|
||||
* @callback: the new errors callback function.
|
||||
*
|
||||
* Sets the errors callback function to @callback that will be called
|
||||
* every time an error occurs.
|
||||
*/
|
||||
void
|
||||
xmlSecErrorsSetCallback(xmlSecErrorsCallback callback) {
|
||||
xmlSecErrorsClbk = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsDefaultCallback:
|
||||
* @file: the error location file name (__FILE__ macro).
|
||||
* @line: the error location line number (__LINE__ macro).
|
||||
* @func: the error location function name (__FUNCTION__ macro).
|
||||
* @errorObject: the error specific error object
|
||||
* @errorSubject: the error specific error subject.
|
||||
* @reason: the error code.
|
||||
* @msg: the additional error message.
|
||||
*
|
||||
* The default error reporting callback that utilizes LibXML
|
||||
* error reporting #xmlGenericError function.
|
||||
*/
|
||||
void
|
||||
xmlSecErrorsDefaultCallback(const char* file, int line, const char* func,
|
||||
const char* errorObject, const char* errorSubject,
|
||||
int reason, const char* msg) {
|
||||
if(xmlSecPrintErrorMessages) {
|
||||
const char* error_msg = NULL;
|
||||
xmlSecSize i;
|
||||
|
||||
for(i = 0; (i < XMLSEC_ERRORS_MAX_NUMBER) && (xmlSecErrorsGetMsg(i) != NULL); ++i) {
|
||||
if(xmlSecErrorsGetCode(i) == reason) {
|
||||
error_msg = xmlSecErrorsGetMsg(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"func=%s:file=%s:line=%d:obj=%s:subj=%s:error=%d:%s:%s\n",
|
||||
(func != NULL) ? func : "unknown",
|
||||
(file != NULL) ? file : "unknown",
|
||||
line,
|
||||
(errorObject != NULL) ? errorObject : "unknown",
|
||||
(errorSubject != NULL) ? errorSubject : "unknown",
|
||||
reason,
|
||||
(error_msg != NULL) ? error_msg : "",
|
||||
(msg != NULL) ? msg : "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsDefaultCallbackEnableOutput:
|
||||
* @enabled: the flag.
|
||||
*
|
||||
* Enables or disables calling LibXML2 callback from the default
|
||||
* errors callback.
|
||||
*/
|
||||
void
|
||||
xmlSecErrorsDefaultCallbackEnableOutput(int enabled) {
|
||||
xmlSecPrintErrorMessages = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsGetCode:
|
||||
* @pos: the error position.
|
||||
*
|
||||
* Gets the known error code at position @pos.
|
||||
*
|
||||
* Returns: the known error code or 0 if @pos is greater than
|
||||
* total number of known error codes.
|
||||
*/
|
||||
int
|
||||
xmlSecErrorsGetCode(xmlSecSize pos) {
|
||||
/* could not use asserts here! */
|
||||
if(pos < sizeof(xmlSecErrorsTable) / sizeof(xmlSecErrorsTable[0])) {
|
||||
return(xmlSecErrorsTable[pos].errorCode);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecErrorsGetMsg:
|
||||
* @pos: the error position.
|
||||
*
|
||||
* Gets the known error message at position @pos.
|
||||
*
|
||||
* Returns: the known error message or NULL if @pos is greater than
|
||||
* total number of known error codes.
|
||||
*/
|
||||
const char*
|
||||
xmlSecErrorsGetMsg(xmlSecSize pos) {
|
||||
/* could not use asserts here! */
|
||||
if(pos < sizeof(xmlSecErrorsTable) / sizeof(xmlSecErrorsTable[0])) {
|
||||
return(xmlSecErrorsTable[pos].errorMsg);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecError:
|
||||
* @file: the error location filename (__FILE__).
|
||||
* @line: the error location line number (__LINE__).
|
||||
* @func: the error location function (__FUNCTION__).
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @errorSubject: the error specific error subject (e.g. failed function name).
|
||||
* @reason: the error code.
|
||||
* @msg: the error message in printf format.
|
||||
* @...: the parameters for the @msg.
|
||||
*
|
||||
* Reports an error to the default (#xmlSecErrorsDefaultCallback) or
|
||||
* application specific callback installed using #xmlSecErrorsSetCallback
|
||||
* function.
|
||||
*/
|
||||
void
|
||||
xmlSecError(const char* file, int line, const char* func,
|
||||
const char* errorObject, const char* errorSubject,
|
||||
int reason, const char* msg, ...) {
|
||||
if(xmlSecErrorsClbk != NULL) {
|
||||
xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE];
|
||||
int ret;
|
||||
|
||||
if(msg != NULL) {
|
||||
va_list va;
|
||||
|
||||
va_start(va, msg);
|
||||
ret = xmlStrVPrintf(error_msg, sizeof(error_msg), msg, va);
|
||||
if(ret < 0) {
|
||||
/* Can't really report an error from an error callback */
|
||||
memcpy(error_msg, fatal_error, sizeof(fatal_error));
|
||||
}
|
||||
error_msg[sizeof(error_msg) - 1] = '\0'; /* just in case */
|
||||
va_end(va);
|
||||
} else {
|
||||
error_msg[0] = '\0';
|
||||
}
|
||||
xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg);
|
||||
}
|
||||
}
|
869
experimental/facho-signer/xades/xmlsec1/errors_helpers.h
Normal file
869
experimental/facho-signer/xades/xmlsec1/errors_helpers.h
Normal file
@ -0,0 +1,869 @@
|
||||
/*
|
||||
* XML Security Library (http://www.aleksey.com/xmlsec).
|
||||
*
|
||||
* Internal header only used during the compilation,
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __XMLSEC_ERROR_HELPERS_H__
|
||||
#define __XMLSEC_ERROR_HELPERS_H__
|
||||
|
||||
#include <errno.h>
|
||||
#include <xmlsec/errors.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Error handling macros.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**
|
||||
* xmlSecInternalError:
|
||||
* @errorFunction: the failed function name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting internal XMLSec errors.
|
||||
*/
|
||||
#define xmlSecInternalError(errorFunction, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED, \
|
||||
XMLSEC_ERRORS_NO_MESSAGE \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInternalError2:
|
||||
* @errorFunction: the failed function name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting internal XMLSec errors.
|
||||
*/
|
||||
#define xmlSecInternalError2(errorFunction, errorObject, msg, param) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED, \
|
||||
(msg), (param) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInternalError3:
|
||||
* @errorFunction: the failed function name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param1: the extra message param1.
|
||||
* @param2: the extra message param2.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting internal XMLSec errors.
|
||||
*/
|
||||
#define xmlSecInternalError3(errorFunction, errorObject, msg, param1, param2) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED, \
|
||||
(msg), (param1), (param2) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInternalError4:
|
||||
* @errorFunction: the failed function name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param1: the extra message param1.
|
||||
* @param2: the extra message param2.
|
||||
* @param3: the extra message param3.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting internal XMLSec errors.
|
||||
*/
|
||||
#define xmlSecInternalError4(errorFunction, errorObject, msg, param1, param2, param3) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED, \
|
||||
(msg), (param1), (param2), (param3) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecMallocError:
|
||||
* @allocSize: the failed allocation size.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting xmlMalloc() errors.
|
||||
*/
|
||||
#define xmlSecMallocError(allocSize, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
"xmlMalloc", \
|
||||
XMLSEC_ERRORS_R_MALLOC_FAILED, \
|
||||
"size=%lu", (unsigned long)(allocSize) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecStrdupError:
|
||||
* @str: the failed string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting xmlStrdup() errors.
|
||||
*/
|
||||
#define xmlSecStrdupError(str, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
"xmlStrdup", \
|
||||
XMLSEC_ERRORS_R_STRDUP_FAILED, \
|
||||
"size=%lu", (unsigned long)xmlStrlen(str) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecXmlError:
|
||||
* @errorFunction: the failed function.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting generic XML errors.
|
||||
*/
|
||||
#define xmlSecXmlError(errorFunction, errorObject) \
|
||||
{ \
|
||||
xmlErrorPtr error = xmlGetLastError(); \
|
||||
int code = (error != NULL) ? error->code : 0; \
|
||||
const char* message = (error != NULL) ? error->message : NULL; \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XML_FAILED, \
|
||||
"xml error: %lu: %s", \
|
||||
(unsigned long)code, \
|
||||
xmlSecErrorsSafeString(message) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecXmlError2:
|
||||
* @errorFunction: the failed function.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting generic XML errors.
|
||||
*/
|
||||
#define xmlSecXmlError2(errorFunction, errorObject, msg, param) \
|
||||
{ \
|
||||
xmlErrorPtr error = xmlGetLastError(); \
|
||||
int code = (error != NULL) ? error->code : 0; \
|
||||
const char* message = (error != NULL) ? error->message : NULL; \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XML_FAILED, \
|
||||
msg "; xml error: %lu: %s", \
|
||||
(param), \
|
||||
(unsigned long)code, \
|
||||
xmlSecErrorsSafeString(message) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecXmlParserError:
|
||||
* @errorFunction: the failed function.
|
||||
* @ctxt: the parser context.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting XML parser errors.
|
||||
*/
|
||||
#define xmlSecXmlParserError(errorFunction, ctxt, errorObject) \
|
||||
{ \
|
||||
xmlErrorPtr error = xmlCtxtGetLastError(ctxt);\
|
||||
int code = (error != NULL) ? error->code : 0; \
|
||||
const char* message = (error != NULL) ? error->message : NULL; \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XML_FAILED, \
|
||||
"xml error: %lu: %s", \
|
||||
(unsigned long)code, \
|
||||
xmlSecErrorsSafeString(message) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecXmlParserError2:
|
||||
* @errorFunction: the failed function.
|
||||
* @ctxt: the parser context.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting XML parser errors.
|
||||
*/
|
||||
#define xmlSecXmlParserError2(errorFunction, ctxt, errorObject, msg, param) \
|
||||
{ \
|
||||
xmlErrorPtr error = xmlCtxtGetLastError(ctxt);\
|
||||
int code = (error != NULL) ? error->code : 0; \
|
||||
const char* message = (error != NULL) ? error->message : NULL; \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XML_FAILED, \
|
||||
msg "; xml error: %lu: %s", \
|
||||
(param), \
|
||||
(unsigned long)code, \
|
||||
xmlSecErrorsSafeString(message) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecXsltError:
|
||||
* @errorFunction: the failed function.
|
||||
* @ctxt: the parser context.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting XSLT errors.
|
||||
*/
|
||||
#define xmlSecXsltError(errorFunction, ctxt, errorObject) \
|
||||
{ \
|
||||
xmlErrorPtr error = xmlGetLastError(); \
|
||||
int code = (error != NULL) ? error->code : 0; \
|
||||
const char* message = (error != NULL) ? error->message : NULL; \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_XSLT_FAILED, \
|
||||
"xslt error: %lu: %s", \
|
||||
(unsigned long)code, \
|
||||
xmlSecErrorsSafeString(message) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecIOError:
|
||||
* @errorFunction: the failed function.
|
||||
* @name: the filename, function name, uri, etc.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting IO errors.
|
||||
*/
|
||||
#define xmlSecIOError(errorFunction, name, errorObject) \
|
||||
{ \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_IO_FAILED, \
|
||||
"name=\"%s\"; errno=%d", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
errno \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecNotImplementedError:
|
||||
* @details: the additional details.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "not implemented" errors.
|
||||
*/
|
||||
#define xmlSecNotImplementedError(details) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_NOT_IMPLEMENTED, \
|
||||
"details=%s", \
|
||||
xmlSecErrorsSafeString(details) \
|
||||
)
|
||||
/**
|
||||
* xmlSecInvalidSizeError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value.
|
||||
* @expected: the expected value.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid size" errors when
|
||||
* we expect exact match.
|
||||
*/
|
||||
#define xmlSecInvalidSizeError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_SIZE, \
|
||||
"invalid size for '%s': actual=%lu is not equal to expected=%lu", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(unsigned long)(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidSizeLessThanError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value.
|
||||
* @expected: the expected value.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid size" errors when
|
||||
* we expect at least the expected size.
|
||||
*/
|
||||
#define xmlSecInvalidSizeLessThanError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_SIZE, \
|
||||
"invalid size for '%s': actual=%lu is less than expected=%lu", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(unsigned long)(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidSizeMoreThanError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value.
|
||||
* @expected: the expected value.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid size" errors when
|
||||
* we expect at most the expected size.
|
||||
*/
|
||||
#define xmlSecInvalidSizeMoreThanError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_NOT_IMPLEMENTED, \
|
||||
"invalid size for '%s': actual=%lu is more than expected=%lu", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(unsigned long)(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidSizeNotMultipleOfError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value.
|
||||
* @divider: the expected divider.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid size" errors when
|
||||
* we expect the size to be a multiple of the divider.
|
||||
*/
|
||||
#define xmlSecInvalidSizeNotMultipleOfError(name, actual, divider, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_NOT_IMPLEMENTED, \
|
||||
"invalid size for '%s': actual=%lu is not a multiple of %lu", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(unsigned long)(divider) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidSizeOtherError:
|
||||
* @msg: the message about the error.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid size" errors when
|
||||
* we expect exact match.
|
||||
*/
|
||||
#define xmlSecInvalidSizeOtherError(msg, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_SIZE, \
|
||||
"invalid size: %s", \
|
||||
xmlSecErrorsSafeString(msg) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidDataError:
|
||||
* @msg: the msg with explanation.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid data" errors.
|
||||
*/
|
||||
#define xmlSecInvalidDataError(msg, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_DATA, \
|
||||
"%s", \
|
||||
xmlSecErrorsSafeString(msg) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidStringDataError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value as a string.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid data" errors for string.
|
||||
*/
|
||||
#define xmlSecInvalidStringDataError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_DATA, \
|
||||
"invalid data for '%s': actual='%s' and expected %s", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
xmlSecErrorsSafeString(actual), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidIntegerDataError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value as an integer.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid data" errors for integers.
|
||||
*/
|
||||
#define xmlSecInvalidIntegerDataError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_DATA, \
|
||||
"invalid data for '%s': actual=%ld and expected %s", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidIntegerDataError2:
|
||||
* @name1: the name of the first variable, parameter, etc.
|
||||
* @actual1: the actual first value as an integer.
|
||||
* @name2: the name of the second variable, parameter, etc.
|
||||
* @actual2: the actual second value as an integer.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid data" errors for integers.
|
||||
*/
|
||||
#define xmlSecInvalidIntegerDataError2(name1, actual1, name2, actual2, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_DATA, \
|
||||
"invalid data: actual value '%s'=%ld, actual value '%s'=%ld and expected %s", \
|
||||
xmlSecErrorsSafeString(name1), \
|
||||
(unsigned long)(actual1), \
|
||||
xmlSecErrorsSafeString(name2), \
|
||||
(unsigned long)(actual2), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidTypeError:
|
||||
* @msg: the msg with explanation.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid type" errors.
|
||||
*/
|
||||
#define xmlSecInvalidTypeError(msg, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TYPE, \
|
||||
"%s", \
|
||||
xmlSecErrorsSafeString(msg) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidStringTypeError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value as a string.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid type" errors for string.
|
||||
*/
|
||||
#define xmlSecInvalidStringTypeError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TYPE, \
|
||||
"invalid type for '%s': actual='%s' and expected %s", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
xmlSecErrorsSafeString(actual), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidIntegerTypeError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value as an integer.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid type" errors for integers.
|
||||
*/
|
||||
#define xmlSecInvalidIntegerTypeError(name, actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TYPE, \
|
||||
"invalid type for '%s': actual=%ld and expected %s", \
|
||||
xmlSecErrorsSafeString(name), \
|
||||
(unsigned long)(actual), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidIntegerTypeError2:
|
||||
* @name1: the name of the first variable, parameter, etc.
|
||||
* @actual1: the actual first value as an integer.
|
||||
* @name2: the name of the second variable, parameter, etc.
|
||||
* @actual2: the actual second value as an integer.
|
||||
* @expected: the expected value(s) as a string.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid type" errors for integers.
|
||||
*/
|
||||
#define xmlSecInvalidIntegerTypeError2(name1, actual1, name2, actual2, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TYPE, \
|
||||
"invalid type: actual value '%s'=%ld, actual value '%s'=%ld and expected %s", \
|
||||
xmlSecErrorsSafeString(name1), \
|
||||
(unsigned long)(actual1), \
|
||||
xmlSecErrorsSafeString(name2), \
|
||||
(unsigned long)(actual2), \
|
||||
(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidNodeError:
|
||||
* @actualNode: the actual node.
|
||||
* @expectedNodeName: the expected node name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid node errors.
|
||||
*/
|
||||
#define xmlSecInvalidNodeError(actualNode, expectedNodeName, errorObject) \
|
||||
{ \
|
||||
const char* actualNodeName = xmlSecNodeGetName(actualNode); \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_NODE, \
|
||||
"actual=%s; expected=%s", \
|
||||
xmlSecErrorsSafeString(actualNodeName), \
|
||||
xmlSecErrorsSafeString(expectedNodeName) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidNodeContentError:
|
||||
* @node: the node.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @reason: the reason why node content is invalid.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid node content errors.
|
||||
*/
|
||||
#define xmlSecInvalidNodeContentError(node, errorObject, reason) \
|
||||
{ \
|
||||
const char* nName = xmlSecNodeGetName(node); \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_NODE_CONTENT, \
|
||||
"node=%s; reason=%s", \
|
||||
xmlSecErrorsSafeString(nName), \
|
||||
xmlSecErrorsSafeString(reason) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidNodeAttributeError:
|
||||
* @node: the node.
|
||||
* @attrName: the attribute name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @reason: the reason why node content is invalid.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid node attribute errors.
|
||||
*/
|
||||
#define xmlSecInvalidNodeAttributeError(node, attrName, errorObject, reason) \
|
||||
{ \
|
||||
const char* nName = xmlSecNodeGetName(node); \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_NODE_ATTRIBUTE, \
|
||||
"node=%s; attribute=%s; reason=%s",\
|
||||
xmlSecErrorsSafeString(nName), \
|
||||
xmlSecErrorsSafeString(attrName), \
|
||||
xmlSecErrorsSafeString(reason) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecNodeAlreadyPresentError:
|
||||
* @parent: the parent node.
|
||||
* @nodeName: the node name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting node already present errors.
|
||||
*/
|
||||
#define xmlSecNodeAlreadyPresentError(parent, nodeName, errorObject) \
|
||||
{ \
|
||||
const char* pName = xmlSecNodeGetName(parent);\
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_NODE_ALREADY_PRESENT, \
|
||||
"parent=%s; node=%s", \
|
||||
xmlSecErrorsSafeString(pName), \
|
||||
xmlSecErrorsSafeString(nodeName) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecUnexpectedNodeError:
|
||||
* @node: the node.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid node errors.
|
||||
*/
|
||||
#define xmlSecUnexpectedNodeError(node, errorObject) \
|
||||
{ \
|
||||
const char* nName = xmlSecNodeGetName(node); \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_UNEXPECTED_NODE, \
|
||||
"node=%s", \
|
||||
xmlSecErrorsSafeString(nName) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecNodeNotFoundError:
|
||||
* @errorFunction: the failed function.
|
||||
* @startNode: the search start node.
|
||||
* @targetNodeName: the expected child node name.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting node not found errors.
|
||||
*/
|
||||
#define xmlSecNodeNotFoundError(errorFunction, startNode, targetNodeName, errorObject) \
|
||||
{ \
|
||||
const char* startNodeName = xmlSecNodeGetName(startNode); \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
(errorFunction), \
|
||||
XMLSEC_ERRORS_R_NODE_NOT_FOUND, \
|
||||
"startNode=%s; target=%s", \
|
||||
xmlSecErrorsSafeString(startNodeName), \
|
||||
xmlSecErrorsSafeString(targetNodeName) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidTransfromError:
|
||||
* @transform: the transform.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid transform errors.
|
||||
*/
|
||||
#define xmlSecInvalidTransfromError(transform) \
|
||||
{ \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)xmlSecTransformGetName(transform), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TRANSFORM, \
|
||||
XMLSEC_ERRORS_NO_MESSAGE \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidTransfromError2:
|
||||
* @transform: the transform.
|
||||
* @msg: the extra message.
|
||||
* @param: the extra message param.
|
||||
*
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid transform errors.
|
||||
*/
|
||||
#define xmlSecInvalidTransfromError2(transform, msg, param) \
|
||||
{ \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)xmlSecTransformGetName(transform), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_TRANSFORM, \
|
||||
(msg), (param) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidTransfromStatusError:
|
||||
* @transform: the transform.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid transform status errors.
|
||||
*/
|
||||
#define xmlSecInvalidTransfromStatusError(transform) \
|
||||
{ \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)xmlSecTransformGetName(transform), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_STATUS, \
|
||||
"transformStatus=%d", \
|
||||
(int)((transform)->status) \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidTransfromStatusError2:
|
||||
* @transform: the transform.
|
||||
* @msg: the extra message.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting an invalid transform status errors.
|
||||
*/
|
||||
#define xmlSecInvalidTransfromStatusError2(transform, msg) \
|
||||
{ \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)xmlSecTransformGetName(transform), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_STATUS, \
|
||||
"transformStatus=%ld, msg=%s", \
|
||||
(long int)((transform)->status), \
|
||||
msg \
|
||||
); \
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSecInvalidKeyDataSizeError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @actual: the actual value.
|
||||
* @expected: the expected value(s).
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid keydata size" errors.
|
||||
*/
|
||||
#define xmlSecInvalidKeyDataSizeError(actual, expected, errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE, \
|
||||
"invalid key data size: actual=%ld and expected=%ld", \
|
||||
(unsigned long)(actual), \
|
||||
(unsigned long)(expected) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecInvalidZeroKeyDataSizeError:
|
||||
* @name: the name of the variable, parameter, etc.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting "invalid keydata size" errors.
|
||||
*/
|
||||
#define xmlSecInvalidZeroKeyDataSizeError(errorObject) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE, \
|
||||
"invalid zero key data size" \
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* xmlSecOtherError:
|
||||
* @code: the error code.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @details: the error message.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting other XMLSec errors.
|
||||
*/
|
||||
#define xmlSecOtherError(code, errorObject, details) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
(code), \
|
||||
"details=%s", \
|
||||
xmlSecErrorsSafeString(details) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecOtherError2:
|
||||
* @code: the error code.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting other XMLSec errors.
|
||||
*/
|
||||
#define xmlSecOtherError2(code, errorObject, msg, param) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
(code), \
|
||||
(msg), (param) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecOtherError3:
|
||||
* @code: the error code.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param1: the extra message param.
|
||||
* @param2: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting other XMLSec errors.
|
||||
*/
|
||||
#define xmlSecOtherError3(code, errorObject, msg, param1, param2) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
(code), \
|
||||
(msg), (param1), (param2) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecOtherError4:
|
||||
* @code: the error code.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param1: the extra message param.
|
||||
* @param2: the extra message param.
|
||||
* @param3: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting other XMLSec errors.
|
||||
*/
|
||||
#define xmlSecOtherError4(code, errorObject, msg, param1, param2, param3) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
(code), \
|
||||
(msg), (param1), (param2), (param3) \
|
||||
)
|
||||
|
||||
/**
|
||||
* xmlSecOtherError5:
|
||||
* @code: the error code.
|
||||
* @errorObject: the error specific error object (e.g. transform, key data, etc).
|
||||
* @msg: the extra message.
|
||||
* @param1: the extra message param.
|
||||
* @param2: the extra message param.
|
||||
* @param3: the extra message param.
|
||||
* @param4: the extra message param.
|
||||
*
|
||||
* Macro. The XMLSec library macro for reporting other XMLSec errors.
|
||||
*/
|
||||
#define xmlSecOtherError5(code, errorObject, msg, param1, param2, param3, param4) \
|
||||
xmlSecError(XMLSEC_ERRORS_HERE, \
|
||||
(const char*)(errorObject), \
|
||||
NULL, \
|
||||
(code), \
|
||||
(msg), (param1), (param2), (param3), (param4) \
|
||||
)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __XMLSEC_ERROR_HELPERS_H__ */
|
1950
experimental/facho-signer/xades/xmlsec1/xmltree.c
Normal file
1950
experimental/facho-signer/xades/xmlsec1/xmltree.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,14 +6,16 @@ tar xf libxml2-${LIBXML2_VERSION}.tar.gz
|
||||
|
||||
mv libxml2-${LIBXML2_VERSION} libxml2
|
||||
|
||||
cd libxml2
|
||||
pushd libxml2
|
||||
|
||||
wasiconfigure ./configure --enable-static --without-http --without-ftp --without-modules --without-python --without-zlib --without-lzma --without-threads --host=x86_64
|
||||
|
||||
wasimake make clean
|
||||
wasimake make -j4
|
||||
|
||||
mkdir -p ../vendor/libxml2/lib
|
||||
mkdir -p ../vendor/libxml2/include
|
||||
cp -r include/libxml2 ../vendor/libxml2/include
|
||||
cp -r .libs/libxml2.a ../vendor/libxml2/lib
|
||||
popd
|
||||
|
||||
mkdir -p vendor/libxml2/lib
|
||||
mkdir -p vendor/libxml2/include
|
||||
cp -r libxml2/include/libxml2 vendor/libxml2/include
|
||||
cp -r libxml2/.libs/libxml2.a vendor/libxml2/lib
|
||||
|
Loading…
Reference in New Issue
Block a user