Line data Source code
1 : /**
2 : * XML Security Library (http://www.aleksey.com/xmlsec).
3 : *
4 : * Canonicalization transforms.
5 : *
6 : * This is free software; see Copyright file in the source
7 : * distribution for preciese wording.
8 : *
9 : * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
10 : */
11 : #include "globals.h"
12 :
13 : #include <stdlib.h>
14 : #include <stdio.h>
15 : #include <string.h>
16 :
17 : #include <libxml/tree.h>
18 : #include <libxml/c14n.h>
19 :
20 : #include <xmlsec/xmlsec.h>
21 : #include <xmlsec/keys.h>
22 : #include <xmlsec/list.h>
23 : #include <xmlsec/transforms.h>
24 : #include <xmlsec/xmltree.h>
25 : #include <xmlsec/errors.h>
26 :
27 : /******************************************************************************
28 : *
29 : * C14N transforms
30 : *
31 : * Inclusive namespaces list for ExclC14N (xmlSecStringList) is located
32 : * after xmlSecTransform structure
33 : *
34 : *****************************************************************************/
35 : #define xmlSecTransformC14NSize \
36 : (sizeof(xmlSecTransform) + sizeof(xmlSecPtrList))
37 : #define xmlSecTransformC14NGetNsList(transform) \
38 : ((xmlSecTransformCheckSize((transform), xmlSecTransformC14NSize)) ? \
39 : (xmlSecPtrListPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)) : \
40 : (xmlSecPtrListPtr)NULL)
41 :
42 : #define xmlSecTransformC14NCheckId(transform) \
43 : (xmlSecTransformInclC14NCheckId((transform)) || \
44 : xmlSecTransformInclC14N11CheckId((transform)) || \
45 : xmlSecTransformExclC14NCheckId((transform)) || \
46 : xmlSecTransformCheckId((transform), xmlSecTransformRemoveXmlTagsC14NId))
47 : #define xmlSecTransformInclC14NCheckId(transform) \
48 : (xmlSecTransformCheckId((transform), xmlSecTransformInclC14NId) || \
49 : xmlSecTransformCheckId((transform), xmlSecTransformInclC14NWithCommentsId))
50 : #define xmlSecTransformInclC14N11CheckId(transform) \
51 : (xmlSecTransformCheckId((transform), xmlSecTransformInclC14N11Id) || \
52 : xmlSecTransformCheckId((transform), xmlSecTransformInclC14N11WithCommentsId))
53 : #define xmlSecTransformExclC14NCheckId(transform) \
54 : (xmlSecTransformCheckId((transform), xmlSecTransformExclC14NId) || \
55 : xmlSecTransformCheckId((transform), xmlSecTransformExclC14NWithCommentsId) )
56 :
57 :
58 : static int xmlSecTransformC14NInitialize (xmlSecTransformPtr transform);
59 : static void xmlSecTransformC14NFinalize (xmlSecTransformPtr transform);
60 : static int xmlSecTransformC14NNodeRead (xmlSecTransformPtr transform,
61 : xmlNodePtr node,
62 : xmlSecTransformCtxPtr transformCtx);
63 : static int xmlSecTransformC14NPushXml (xmlSecTransformPtr transform,
64 : xmlSecNodeSetPtr nodes,
65 : xmlSecTransformCtxPtr transformCtx);
66 : static int xmlSecTransformC14NPopBin (xmlSecTransformPtr transform,
67 : xmlSecByte* data,
68 : xmlSecSize maxDataSize,
69 : xmlSecSize* dataSize,
70 : xmlSecTransformCtxPtr transformCtx);
71 : static int xmlSecTransformC14NExecute (xmlSecTransformId id,
72 : xmlSecNodeSetPtr nodes,
73 : xmlChar** nsList,
74 : xmlOutputBufferPtr buf);
75 : static int
76 0 : xmlSecTransformC14NInitialize(xmlSecTransformPtr transform) {
77 : xmlSecPtrListPtr nsList;
78 : int ret;
79 :
80 0 : xmlSecAssert2(xmlSecTransformC14NCheckId(transform), -1);
81 :
82 0 : nsList = xmlSecTransformC14NGetNsList(transform);
83 0 : xmlSecAssert2(nsList != NULL, -1);
84 :
85 0 : ret = xmlSecPtrListInitialize(nsList, xmlSecStringListId);
86 0 : if(ret < 0) {
87 0 : xmlSecError(XMLSEC_ERRORS_HERE,
88 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
89 : "xmlSecPtrListInitialize",
90 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
91 : XMLSEC_ERRORS_NO_MESSAGE);
92 0 : return(-1);
93 : }
94 0 : return(0);
95 : }
96 :
97 : static void
98 0 : xmlSecTransformC14NFinalize(xmlSecTransformPtr transform) {
99 : xmlSecPtrListPtr nsList;
100 :
101 0 : xmlSecAssert(xmlSecTransformC14NCheckId(transform));
102 :
103 0 : nsList = xmlSecTransformC14NGetNsList(transform);
104 0 : xmlSecAssert(xmlSecPtrListCheckId(nsList, xmlSecStringListId));
105 :
106 0 : xmlSecPtrListFinalize(nsList);
107 : }
108 :
109 : static int
110 0 : xmlSecTransformC14NNodeRead(xmlSecTransformPtr transform, xmlNodePtr node, xmlSecTransformCtxPtr transformCtx) {
111 : xmlSecPtrListPtr nsList;
112 : xmlNodePtr cur;
113 : xmlChar *list;
114 : xmlChar *p, *n, *tmp;
115 : int ret;
116 :
117 : /* we have something to read only for exclusive c14n transforms */
118 0 : xmlSecAssert2(xmlSecTransformExclC14NCheckId(transform), -1);
119 0 : xmlSecAssert2(node != NULL, -1);
120 0 : xmlSecAssert2(transformCtx != NULL, -1);
121 :
122 0 : nsList = xmlSecTransformC14NGetNsList(transform);
123 0 : xmlSecAssert2(xmlSecPtrListCheckId(nsList, xmlSecStringListId), -1);
124 0 : xmlSecAssert2(xmlSecPtrListGetSize(nsList) == 0, -1);
125 :
126 : /* there is only one optional node */
127 0 : cur = xmlSecGetNextElementNode(node->children);
128 0 : if(cur != NULL) {
129 0 : if(!xmlSecCheckNodeName(cur, xmlSecNodeInclusiveNamespaces, xmlSecNsExcC14N)) {
130 0 : xmlSecError(XMLSEC_ERRORS_HERE,
131 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
132 0 : xmlSecErrorsSafeString(xmlSecNodeGetName(cur)),
133 : XMLSEC_ERRORS_R_INVALID_NODE,
134 : XMLSEC_ERRORS_NO_MESSAGE);
135 0 : return(-1);
136 : }
137 :
138 0 : list = xmlGetProp(cur, xmlSecAttrPrefixList);
139 0 : if(list == NULL) {
140 0 : xmlSecError(XMLSEC_ERRORS_HERE,
141 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
142 : xmlSecErrorsSafeString(xmlSecAttrPrefixList),
143 : XMLSEC_ERRORS_R_INVALID_NODE_ATTRIBUTE,
144 : "node=%s",
145 0 : xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
146 0 : return(-1);
147 : }
148 :
149 : /* the list of namespaces is space separated */
150 0 : for(p = n = list; ((p != NULL) && ((*p) != '\0')); p = n) {
151 0 : n = (xmlChar*)xmlStrchr(p, ' ');
152 0 : if(n != NULL) {
153 0 : *(n++) = '\0';
154 : }
155 :
156 0 : tmp = xmlStrdup(p);
157 0 : if(tmp == NULL) {
158 0 : xmlSecError(XMLSEC_ERRORS_HERE,
159 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
160 : NULL,
161 : XMLSEC_ERRORS_R_STRDUP_FAILED,
162 : "len=%d", xmlStrlen(p));
163 0 : xmlFree(list);
164 0 : return(-1);
165 : }
166 :
167 0 : ret = xmlSecPtrListAdd(nsList, tmp);
168 0 : if(ret < 0) {
169 0 : xmlSecError(XMLSEC_ERRORS_HERE,
170 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
171 : "xmlSecPtrListAdd",
172 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
173 : XMLSEC_ERRORS_NO_MESSAGE);
174 0 : xmlFree(tmp);
175 0 : xmlFree(list);
176 0 : return(-1);
177 : }
178 : }
179 0 : xmlFree(list);
180 :
181 : /* add NULL at the end */
182 0 : ret = xmlSecPtrListAdd(nsList, NULL);
183 0 : if(ret < 0) {
184 0 : xmlSecError(XMLSEC_ERRORS_HERE,
185 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
186 : "xmlSecPtrListAdd",
187 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
188 : XMLSEC_ERRORS_NO_MESSAGE);
189 0 : return(-1);
190 : }
191 :
192 0 : cur = xmlSecGetNextElementNode(cur->next);
193 : }
194 :
195 : /* check that we have nothing else */
196 0 : if(cur != NULL) {
197 0 : xmlSecError(XMLSEC_ERRORS_HERE,
198 : NULL,
199 0 : xmlSecErrorsSafeString(xmlSecNodeGetName(cur)),
200 : XMLSEC_ERRORS_R_UNEXPECTED_NODE,
201 : XMLSEC_ERRORS_NO_MESSAGE);
202 0 : return(-1);
203 : }
204 :
205 0 : return(0);
206 : }
207 :
208 : static int
209 0 : xmlSecTransformC14NPushXml(xmlSecTransformPtr transform, xmlSecNodeSetPtr nodes,
210 : xmlSecTransformCtxPtr transformCtx) {
211 : xmlOutputBufferPtr buf;
212 : xmlSecPtrListPtr nsList;
213 : int ret;
214 :
215 0 : xmlSecAssert2(xmlSecTransformC14NCheckId(transform), -1);
216 0 : xmlSecAssert2(nodes != NULL, -1);
217 0 : xmlSecAssert2(nodes->doc != NULL, -1);
218 0 : xmlSecAssert2(transformCtx != NULL, -1);
219 :
220 : /* check/update current transform status */
221 0 : switch(transform->status) {
222 : case xmlSecTransformStatusNone:
223 0 : transform->status = xmlSecTransformStatusWorking;
224 0 : break;
225 : case xmlSecTransformStatusWorking:
226 : case xmlSecTransformStatusFinished:
227 0 : return(0);
228 : default:
229 0 : xmlSecError(XMLSEC_ERRORS_HERE,
230 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
231 : NULL,
232 : XMLSEC_ERRORS_R_INVALID_STATUS,
233 0 : "status=%d", transform->status);
234 0 : return(-1);
235 : }
236 0 : xmlSecAssert2(transform->status == xmlSecTransformStatusWorking, -1);
237 :
238 : /* prepare output buffer: next transform or ourselves */
239 0 : if(transform->next != NULL) {
240 0 : buf = xmlSecTransformCreateOutputBuffer(transform->next, transformCtx);
241 0 : if(buf == NULL) {
242 0 : xmlSecError(XMLSEC_ERRORS_HERE,
243 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
244 : "xmlSecTransformCreateOutputBuffer",
245 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
246 : XMLSEC_ERRORS_NO_MESSAGE);
247 0 : return(-1);
248 : }
249 : } else {
250 0 : buf = xmlSecBufferCreateOutputBuffer(&(transform->outBuf));
251 0 : if(buf == NULL) {
252 0 : xmlSecError(XMLSEC_ERRORS_HERE,
253 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
254 : "xmlSecBufferCreateOutputBuffer",
255 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
256 : XMLSEC_ERRORS_NO_MESSAGE);
257 0 : return(-1);
258 : }
259 : }
260 :
261 : /* we are using a semi-hack here: we know that xmlSecPtrList keeps
262 : * all pointers in the big array */
263 0 : nsList = xmlSecTransformC14NGetNsList(transform);
264 0 : xmlSecAssert2(xmlSecPtrListCheckId(nsList, xmlSecStringListId), -1);
265 :
266 0 : ret = xmlSecTransformC14NExecute(transform->id, nodes, (xmlChar**)(nsList->data), buf);
267 0 : if(ret < 0) {
268 0 : xmlSecError(XMLSEC_ERRORS_HERE,
269 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
270 : "xmlSecTransformC14NExecute",
271 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
272 : XMLSEC_ERRORS_NO_MESSAGE);
273 0 : xmlOutputBufferClose(buf);
274 0 : return(-1);
275 : }
276 :
277 0 : ret = xmlOutputBufferClose(buf);
278 0 : if(ret < 0) {
279 0 : xmlSecError(XMLSEC_ERRORS_HERE,
280 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
281 : "xmlOutputBufferClose",
282 : XMLSEC_ERRORS_R_XML_FAILED,
283 : XMLSEC_ERRORS_NO_MESSAGE);
284 0 : return(-1);
285 : }
286 0 : transform->status = xmlSecTransformStatusFinished;
287 0 : return(0);
288 : }
289 :
290 : static int
291 0 : xmlSecTransformC14NPopBin(xmlSecTransformPtr transform, xmlSecByte* data,
292 : xmlSecSize maxDataSize, xmlSecSize* dataSize,
293 : xmlSecTransformCtxPtr transformCtx) {
294 : xmlSecPtrListPtr nsList;
295 : xmlSecBufferPtr out;
296 : int ret;
297 :
298 0 : xmlSecAssert2(xmlSecTransformC14NCheckId(transform), -1);
299 0 : xmlSecAssert2(data != NULL, -1);
300 0 : xmlSecAssert2(dataSize != NULL, -1);
301 0 : xmlSecAssert2(transformCtx != NULL, -1);
302 :
303 0 : out = &(transform->outBuf);
304 0 : if(transform->status == xmlSecTransformStatusNone) {
305 : xmlOutputBufferPtr buf;
306 :
307 0 : xmlSecAssert2(transform->inNodes == NULL, -1);
308 :
309 : /* todo: isn't it an error? */
310 0 : if(transform->prev == NULL) {
311 0 : (*dataSize) = 0;
312 0 : transform->status = xmlSecTransformStatusFinished;
313 0 : return(0);
314 : }
315 :
316 : /* get xml data from previous transform */
317 0 : ret = xmlSecTransformPopXml(transform->prev, &(transform->inNodes), transformCtx);
318 0 : if(ret < 0) {
319 0 : xmlSecError(XMLSEC_ERRORS_HERE,
320 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
321 : "xmlSecTransformPopXml",
322 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
323 : XMLSEC_ERRORS_NO_MESSAGE);
324 0 : return(-1);
325 : }
326 :
327 : /* dump everything to internal buffer */
328 0 : buf = xmlSecBufferCreateOutputBuffer(out);
329 0 : if(buf == NULL) {
330 0 : xmlSecError(XMLSEC_ERRORS_HERE,
331 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
332 : "xmlSecBufferCreateOutputBuffer",
333 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
334 : XMLSEC_ERRORS_NO_MESSAGE);
335 0 : return(-1);
336 : }
337 :
338 : /* we are using a semi-hack here: we know that xmlSecPtrList keeps
339 : * all pointers in the big array */
340 0 : nsList = xmlSecTransformC14NGetNsList(transform);
341 0 : xmlSecAssert2(xmlSecPtrListCheckId(nsList, xmlSecStringListId), -1);
342 :
343 0 : ret = xmlSecTransformC14NExecute(transform->id, transform->inNodes, (xmlChar**)(nsList->data), buf);
344 0 : if(ret < 0) {
345 0 : xmlSecError(XMLSEC_ERRORS_HERE,
346 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
347 : "xmlSecTransformC14NExecute",
348 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
349 : XMLSEC_ERRORS_NO_MESSAGE);
350 0 : xmlOutputBufferClose(buf);
351 0 : return(-1);
352 : }
353 0 : ret = xmlOutputBufferClose(buf);
354 0 : if(ret < 0) {
355 0 : xmlSecError(XMLSEC_ERRORS_HERE,
356 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
357 : "xmlOutputBufferClose",
358 : XMLSEC_ERRORS_R_XML_FAILED,
359 : XMLSEC_ERRORS_NO_MESSAGE);
360 0 : return(-1);
361 : }
362 0 : transform->status = xmlSecTransformStatusWorking;
363 : }
364 :
365 0 : if(transform->status == xmlSecTransformStatusWorking) {
366 : xmlSecSize outSize;
367 :
368 : /* return chunk after chunk */
369 0 : outSize = xmlSecBufferGetSize(out);
370 0 : if(outSize > maxDataSize) {
371 0 : outSize = maxDataSize;
372 : }
373 0 : if(outSize > XMLSEC_TRANSFORM_BINARY_CHUNK) {
374 0 : outSize = XMLSEC_TRANSFORM_BINARY_CHUNK;
375 : }
376 0 : if(outSize > 0) {
377 0 : xmlSecAssert2(xmlSecBufferGetData(&(transform->outBuf)), -1);
378 :
379 0 : memcpy(data, xmlSecBufferGetData(&(transform->outBuf)), outSize);
380 0 : ret = xmlSecBufferRemoveHead(&(transform->outBuf), outSize);
381 0 : if(ret < 0) {
382 0 : xmlSecError(XMLSEC_ERRORS_HERE,
383 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
384 : "xmlSecBufferRemoveHead",
385 : XMLSEC_ERRORS_R_XMLSEC_FAILED,
386 : "size=%d", outSize);
387 0 : return(-1);
388 : }
389 0 : } else if(xmlSecBufferGetSize(out) == 0) {
390 0 : transform->status = xmlSecTransformStatusFinished;
391 : }
392 0 : (*dataSize) = outSize;
393 0 : } else if(transform->status == xmlSecTransformStatusFinished) {
394 : /* the only way we can get here is if there is no output */
395 0 : xmlSecAssert2(xmlSecBufferGetSize(out) == 0, -1);
396 0 : (*dataSize) = 0;
397 : } else {
398 0 : xmlSecError(XMLSEC_ERRORS_HERE,
399 0 : xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
400 : NULL,
401 : XMLSEC_ERRORS_R_INVALID_STATUS,
402 0 : "status=%d", transform->status);
403 0 : return(-1);
404 : }
405 :
406 0 : return(0);
407 : }
408 :
409 : #if !defined(LIBXML_VERSION) || LIBXML_VERSION < 20704
410 : /*
411 : * xmlC14NMode:
412 : *
413 : * Predefined values for C14N modes
414 : *
415 : */
416 : typedef enum {
417 : XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
418 : XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
419 : XML_C14N_1_1 = 2 /* C14N 1.1 spec */
420 : } xmlC14NMode;
421 : #endif
422 :
423 : static int
424 0 : xmlSecTransformC14NExecute(xmlSecTransformId id, xmlSecNodeSetPtr nodes, xmlChar** nsList,
425 : xmlOutputBufferPtr buf) {
426 : int ret;
427 :
428 0 : xmlSecAssert2(id != xmlSecTransformIdUnknown, -1);
429 0 : xmlSecAssert2(nodes != NULL, -1);
430 0 : xmlSecAssert2(nodes->doc != NULL, -1);
431 0 : xmlSecAssert2(buf != NULL, -1);
432 :
433 : /* execute c14n transform */
434 0 : if(id == xmlSecTransformInclC14NId) {
435 0 : ret = xmlC14NExecute(nodes->doc,
436 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
437 : nodes, XML_C14N_1_0, NULL, 0, buf);
438 0 : } else if(id == xmlSecTransformInclC14NWithCommentsId) {
439 0 : ret = xmlC14NExecute(nodes->doc,
440 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
441 : nodes, XML_C14N_1_0, NULL, 1, buf);
442 0 : } else if(id == xmlSecTransformInclC14N11Id) {
443 0 : ret = xmlC14NExecute(nodes->doc,
444 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
445 : nodes, XML_C14N_1_1, NULL, 0, buf);
446 0 : } else if(id == xmlSecTransformInclC14N11WithCommentsId) {
447 0 : ret = xmlC14NExecute(nodes->doc,
448 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
449 : nodes, XML_C14N_1_1, NULL, 1, buf);
450 0 : } else if(id == xmlSecTransformExclC14NId) {
451 0 : ret = xmlC14NExecute(nodes->doc,
452 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
453 : nodes, XML_C14N_EXCLUSIVE_1_0, nsList, 0, buf);
454 0 : } else if(id == xmlSecTransformExclC14NWithCommentsId) {
455 0 : ret = xmlC14NExecute(nodes->doc,
456 : (xmlC14NIsVisibleCallback)xmlSecNodeSetContains,
457 : nodes, XML_C14N_EXCLUSIVE_1_0, nsList, 1, buf);
458 0 : } else if(id == xmlSecTransformRemoveXmlTagsC14NId) {
459 0 : ret = xmlSecNodeSetDumpTextNodes(nodes, buf);
460 : } else {
461 : /* shoudn't be possible to come here, actually */
462 0 : xmlSecError(XMLSEC_ERRORS_HERE,
463 0 : xmlSecErrorsSafeString(xmlSecTransformKlassGetName(id)),
464 : NULL,
465 : XMLSEC_ERRORS_R_INVALID_TRANSFORM,
466 : XMLSEC_ERRORS_NO_MESSAGE);
467 0 : return(-1);
468 : }
469 :
470 0 : if(ret < 0) {
471 0 : xmlSecError(XMLSEC_ERRORS_HERE,
472 0 : xmlSecErrorsSafeString(xmlSecTransformKlassGetName(id)),
473 : "xmlC14NExecute",
474 : XMLSEC_ERRORS_R_XML_FAILED,
475 : XMLSEC_ERRORS_NO_MESSAGE);
476 0 : return(-1);
477 : }
478 :
479 0 : return(0);
480 : }
481 :
482 : /***************************************************************************
483 : *
484 : * C14N
485 : *
486 : ***************************************************************************/
487 : static xmlSecTransformKlass xmlSecTransformInclC14NKlass = {
488 : /* klass/object sizes */
489 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
490 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
491 :
492 : xmlSecNameC14N, /* const xmlChar* name; */
493 : xmlSecHrefC14N, /* const xmlChar* href; */
494 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
495 : /* xmlSecAlgorithmUsage usage; */
496 :
497 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
498 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
499 : NULL, /* xmlSecTransformNodeReadMethod readNode; */
500 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
501 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
502 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
503 : NULL, /* xmlSecTransformValidateMethod validate; */
504 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
505 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
506 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
507 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
508 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
509 : NULL, /* xmlSecTransformExecuteMethod execute; */
510 :
511 : NULL, /* void* reserved0; */
512 : NULL, /* void* reserved1; */
513 : };
514 :
515 : /**
516 : * xmlSecTransformInclC14NGetKlass:
517 : *
518 : * Inclusive (regular) canonicalization that omits comments transform klass
519 : * (http://www.w3.org/TR/xmldsig-core/#sec-c14nAlg and
520 : * http://www.w3.org/TR/2001/REC-xml-c14n-20010315).
521 : *
522 : * Returns: c14n transform id.
523 : */
524 : xmlSecTransformId
525 0 : xmlSecTransformInclC14NGetKlass(void) {
526 0 : return(&xmlSecTransformInclC14NKlass);
527 : }
528 :
529 : /***************************************************************************
530 : *
531 : * C14N With Comments
532 : *
533 : ***************************************************************************/
534 : static xmlSecTransformKlass xmlSecTransformInclC14NWithCommentsKlass = {
535 : /* klass/object sizes */
536 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
537 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
538 :
539 : /* same as xmlSecTransformId */
540 : xmlSecNameC14NWithComments, /* const xmlChar* name; */
541 : xmlSecHrefC14NWithComments, /* const xmlChar* href; */
542 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
543 : /* xmlSecAlgorithmUsage usage; */
544 :
545 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
546 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
547 : NULL, /* xmlSecTransformNodeReadMethod read; */
548 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
549 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
550 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
551 : NULL, /* xmlSecTransformValidateMethod validate; */
552 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
553 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
554 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
555 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
556 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
557 : NULL, /* xmlSecTransformExecuteMethod execute; */
558 :
559 : NULL, /* void* reserved0; */
560 : NULL, /* void* reserved1; */
561 : };
562 :
563 : /**
564 : * xmlSecTransformInclC14NWithCommentsGetKlass:
565 : *
566 : * Inclusive (regular) canonicalization that includes comments transform klass
567 : * (http://www.w3.org/TR/xmldsig-core/#sec-c14nAlg and
568 : * http://www.w3.org/TR/2001/REC-xml-c14n-20010315).
569 : *
570 : * Returns: c14n with comments transform id.
571 : */
572 : xmlSecTransformId
573 0 : xmlSecTransformInclC14NWithCommentsGetKlass(void) {
574 0 : return(&xmlSecTransformInclC14NWithCommentsKlass);
575 : }
576 :
577 : /***************************************************************************
578 : *
579 : * C14N v1.1
580 : *
581 : ***************************************************************************/
582 : static xmlSecTransformKlass xmlSecTransformInclC14N11Klass = {
583 : /* klass/object sizes */
584 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
585 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
586 :
587 : xmlSecNameC14N11, /* const xmlChar* name; */
588 : xmlSecHrefC14N11, /* const xmlChar* href; */
589 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
590 : /* xmlSecAlgorithmUsage usage; */
591 :
592 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
593 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
594 : NULL, /* xmlSecTransformNodeReadMethod readNode; */
595 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
596 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
597 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
598 : NULL, /* xmlSecTransformValidateMethod validate; */
599 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
600 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
601 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
602 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
603 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
604 : NULL, /* xmlSecTransformExecuteMethod execute; */
605 :
606 : NULL, /* void* reserved0; */
607 : NULL, /* void* reserved1; */
608 : };
609 :
610 : /**
611 : * xmlSecTransformInclC14N11GetKlass:
612 : *
613 : * C14N version 1.1 (http://www.w3.org/TR/xml-c14n11)
614 : *
615 : * Returns: c14n v1.1 transform id.
616 : */
617 : xmlSecTransformId
618 0 : xmlSecTransformInclC14N11GetKlass(void) {
619 0 : return(&xmlSecTransformInclC14N11Klass);
620 : }
621 :
622 : /***************************************************************************
623 : *
624 : * C14N v1.1 With Comments
625 : *
626 : ***************************************************************************/
627 : static xmlSecTransformKlass xmlSecTransformInclC14N11WithCommentsKlass = {
628 : /* klass/object sizes */
629 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
630 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
631 :
632 : /* same as xmlSecTransformId */
633 : xmlSecNameC14N11WithComments, /* const xmlChar* name; */
634 : xmlSecHrefC14N11WithComments, /* const xmlChar* href; */
635 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
636 : /* xmlSecAlgorithmUsage usage; */
637 :
638 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
639 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
640 : NULL, /* xmlSecTransformNodeReadMethod read; */
641 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
642 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
643 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
644 : NULL, /* xmlSecTransformValidateMethod validate; */
645 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
646 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
647 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
648 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
649 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
650 : NULL, /* xmlSecTransformExecuteMethod execute; */
651 :
652 : NULL, /* void* reserved0; */
653 : NULL, /* void* reserved1; */
654 : };
655 :
656 : /**
657 : * xmlSecTransformInclC14N11WithCommentsGetKlass:
658 : *
659 : * C14N version 1.1 (http://www.w3.org/TR/xml-c14n11) with comments
660 : *
661 : * Returns: c14n v1.1 with comments transform id.
662 : */
663 : xmlSecTransformId
664 0 : xmlSecTransformInclC14N11WithCommentsGetKlass(void) {
665 0 : return(&xmlSecTransformInclC14N11WithCommentsKlass);
666 : }
667 :
668 :
669 : /***************************************************************************
670 : *
671 : * Excl C14N
672 : *
673 : ***************************************************************************/
674 : static xmlSecTransformKlass xmlSecTransformExclC14NKlass = {
675 : /* klass/object sizes */
676 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
677 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
678 :
679 : xmlSecNameExcC14N, /* const xmlChar* name; */
680 : xmlSecHrefExcC14N, /* const xmlChar* href; */
681 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
682 : /* xmlSecAlgorithmUsage usage; */
683 :
684 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
685 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
686 : xmlSecTransformC14NNodeRead, /* xmlSecTransformNodeReadMethod readNode; */
687 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
688 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
689 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
690 : NULL, /* xmlSecTransformValidateMethod validate; */
691 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
692 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
693 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
694 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
695 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
696 : NULL, /* xmlSecTransformExecuteMethod execute; */
697 :
698 : NULL, /* void* reserved0; */
699 : NULL, /* void* reserved1; */
700 : };
701 :
702 : /**
703 : * xmlSecTransformExclC14NGetKlass:
704 : *
705 : * Exclusive canoncicalization that ommits comments transform klass
706 : * (http://www.w3.org/TR/xml-exc-c14n/).
707 : *
708 : * Returns: exclusive c14n transform id.
709 : */
710 : xmlSecTransformId
711 0 : xmlSecTransformExclC14NGetKlass(void) {
712 0 : return(&xmlSecTransformExclC14NKlass);
713 : }
714 :
715 : /***************************************************************************
716 : *
717 : * Excl C14N With Comments
718 : *
719 : ***************************************************************************/
720 : static xmlSecTransformKlass xmlSecTransformExclC14NWithCommentsKlass = {
721 : /* klass/object sizes */
722 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
723 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
724 :
725 : xmlSecNameExcC14NWithComments, /* const xmlChar* name; */
726 : xmlSecHrefExcC14NWithComments, /* const xmlChar* href; */
727 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
728 : /* xmlSecAlgorithmUsage usage; */
729 :
730 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
731 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
732 : xmlSecTransformC14NNodeRead, /* xmlSecTransformNodeReadMethod readNode; */
733 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
734 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
735 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
736 : NULL, /* xmlSecTransformValidateMethod validate; */
737 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
738 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
739 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
740 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
741 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
742 : NULL, /* xmlSecTransformExecuteMethod execute; */
743 :
744 : NULL, /* void* reserved0; */
745 : NULL, /* void* reserved1; */
746 : };
747 :
748 : /**
749 : * xmlSecTransformExclC14NWithCommentsGetKlass:
750 : *
751 : * Exclusive canoncicalization that includes comments transform klass
752 : * (http://www.w3.org/TR/xml-exc-c14n/).
753 : *
754 : * Returns: exclusive c14n with comments transform id.
755 : */
756 : xmlSecTransformId
757 0 : xmlSecTransformExclC14NWithCommentsGetKlass(void) {
758 0 : return(&xmlSecTransformExclC14NWithCommentsKlass);
759 : }
760 :
761 : /***************************************************************************
762 : *
763 : * Remove XML tags C14N
764 : *
765 : ***************************************************************************/
766 : static xmlSecTransformKlass xmlSecTransformRemoveXmlTagsC14NKlass = {
767 : /* klass/object sizes */
768 : sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
769 : xmlSecTransformC14NSize, /* xmlSecSize objSize */
770 :
771 : BAD_CAST "remove-xml-tags-transform", /* const xmlChar* name; */
772 : NULL, /* const xmlChar* href; */
773 : xmlSecTransformUsageC14NMethod | xmlSecTransformUsageDSigTransform,
774 : /* xmlSecAlgorithmUsage usage; */
775 :
776 : xmlSecTransformC14NInitialize, /* xmlSecTransformInitializeMethod initialize; */
777 : xmlSecTransformC14NFinalize, /* xmlSecTransformFinalizeMethod finalize; */
778 : NULL, /* xmlSecTransformNodeReadMethod readNode; */
779 : NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
780 : NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
781 : NULL, /* xmlSecTransformSetKeyMethod setKey; */
782 : NULL, /* xmlSecTransformValidateMethod validate; */
783 : xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
784 : NULL, /* xmlSecTransformPushBinMethod pushBin; */
785 : xmlSecTransformC14NPopBin, /* xmlSecTransformPopBinMethod popBin; */
786 : xmlSecTransformC14NPushXml, /* xmlSecTransformPushXmlMethod pushXml; */
787 : NULL, /* xmlSecTransformPopXmlMethod popXml; */
788 : NULL, /* xmlSecTransformExecuteMethod execute; */
789 :
790 : NULL, /* void* reserved0; */
791 : NULL, /* void* reserved1; */
792 : };
793 :
794 : /**
795 : * xmlSecTransformRemoveXmlTagsC14NGetKlass:
796 : *
797 : * The "remove xml tags" transform klass (http://www.w3.org/TR/xmldsig-core/#sec-Base-64):
798 : * Base64 transform requires an octet stream for input. If an XPath node-set
799 : * (or sufficiently functional alternative) is given as input, then it is
800 : * converted to an octet stream by performing operations logically equivalent
801 : * to 1) applying an XPath transform with expression self::text(), then 2)
802 : * taking the string-value of the node-set. Thus, if an XML element is
803 : * identified by a barename XPointer in the Reference URI, and its content
804 : * consists solely of base64 encoded character data, then this transform
805 : * automatically strips away the start and end tags of the identified element
806 : * and any of its descendant elements as well as any descendant comments and
807 : * processing instructions. The output of this transform is an octet stream.
808 : *
809 : * Returns: "remove xml tags" transform id.
810 : */
811 : xmlSecTransformId
812 0 : xmlSecTransformRemoveXmlTagsC14NGetKlass(void) {
813 0 : return(&xmlSecTransformRemoveXmlTagsC14NKlass);
814 : }
815 :
|