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