/* gcc -o verify verify.c -I/usr/include/libxml2 $(pkg-config --cflags --libs xmlsec1) && ./verify */ #include #include #include #include #include #include #include #include #include int main() { xmlSecInit(); xmlSecCryptoAppInit(0); xmlSecCryptoInit(); //int const size = 9218; //FILE* f = fopen("test.xml", "r"); int const size = 8785; FILE* f = fopen("test2.xml", "r"); char* buffer = malloc(size); fread(buffer, 1, size, f); fclose(f); xmlDocPtr doc = xmlReadMemory(buffer, size, "noname.xml", NULL, 0); if (!doc) { fprintf(stderr, "parse\n"); exit(1); } xmlNodePtr node = xmlSecFindNode(xmlDocGetRootElement(doc), xmlSecNodeSignature, xmlSecDSigNs); if (!node) { fprintf(stderr, "find the node\n"); exit(1); } xmlSecKeysMngrPtr keys_manager = xmlSecKeysMngrCreate(); xmlSecDSigCtxPtr dsig_context = xmlSecDSigCtxCreate(keys_manager); if (!dsig_context) { fprintf(stderr, "make context\n"); exit(1); } if (xmlSecDSigCtxVerify(dsig_context, node) < 0) { fprintf(stderr, "nope\n"); exit(1); } }