You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by sc...@apache.org on 2009/06/09 18:58:25 UTC
svn commit: r783064 - in /xml/security/trunk/c: ./ src/canon/ src/dsig/
src/transformers/
Author: scantor
Date: Tue Jun 9 16:58:25 2009
New Revision: 783064
URL: http://svn.apache.org/viewvc?rev=783064&view=rev
Log:
Partial c14n 1.1 support excluding xml:base.
Modified:
xml/security/trunk/c/CHANGELOG.txt
xml/security/trunk/c/src/canon/XSECC14n20010315.cpp
xml/security/trunk/c/src/canon/XSECC14n20010315.hpp
xml/security/trunk/c/src/dsig/DSIGConstants.cpp
xml/security/trunk/c/src/dsig/DSIGConstants.hpp
xml/security/trunk/c/src/dsig/DSIGTransformC14n.cpp
xml/security/trunk/c/src/transformers/TXFMC14n.cpp
xml/security/trunk/c/src/transformers/TXFMC14n.hpp
Modified: xml/security/trunk/c/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/CHANGELOG.txt?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/CHANGELOG.txt (original)
+++ xml/security/trunk/c/CHANGELOG.txt Tue Jun 9 16:58:25 2009
@@ -3,11 +3,12 @@
* Make SHA-1 the implicit default DigestMethod for RSA-OAEP
key transport, allowing for interop until broken impls are fixed (SC)
* Fix memory leak in OpenSSL RSA/DSA key cloning (SC)
+* Expose KeyInfo extensions via DOM (SC)
+* Fix c14n to omit standard xmlns:xml declarations (SC)
+* Add partial support for Inclusive C14N 1.1 with regard to xml:id but not xml:base (SC)
* Finish port to Xerces 3.0 (SC)
* 64-bit API changes (SC)
* Add VC9 build files (SC)
-* Expose KeyInfo extensions via DOM (SC)
-* Fix c14n to omit standard xmlns:xml declarations (SC)
Changes between version 1.3.1 and 1.4
=====================================
Modified: xml/security/trunk/c/src/canon/XSECC14n20010315.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/canon/XSECC14n20010315.cpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/canon/XSECC14n20010315.cpp (original)
+++ xml/security/trunk/c/src/canon/XSECC14n20010315.cpp Tue Jun 9 16:58:25 2009
@@ -100,27 +100,27 @@
XSECNodeListElt *tmp, *last;
if (lst == NULL) {
-
+
// Goes at start
toIns->next = NULL;
toIns->last = NULL;
-
+
return toIns;
-
+
} /* if mp_attributes == NULL */
-
+
// Need to run through start of list
-
+
tmp = lst;
last = NULL;
int res = -1; // Used to remove a gcc warning
-
+
while ((tmp != NULL) &&
((res = toIns->sortString.sbStrcmp(tmp->sortString)) >= 0)) {
-
+
last = tmp;
tmp = tmp->next;
-
+
} /* while */
if (res ==0) {
@@ -130,42 +130,42 @@
return lst;
}
-
+
if (last == NULL) {
-
+
// It sits before first element
-
+
toIns->next = lst;
toIns->last = NULL;
lst->last = tmp;
-
+
return toIns;
-
+
} /* if last == NULL */
-
+
// We have found where it goes
-
+
toIns->next = tmp;
toIns->last = last;
-
+
if (tmp != NULL)
tmp->last = toIns;
-
+
last->next = toIns;
-
+
return lst;
-
+
}
-
+
// --------------------------------------------------------------------------------
// Exclusive Canonicalisation Methods
// --------------------------------------------------------------------------------
-
+
bool visiblyUtilises(DOMNode *node, safeBuffer &ns) {
// Test whether the node uses the name space passed in
-
+
if (strEquals(node->getPrefix(), (char *) ns.rawBuffer()))
return true;
@@ -206,11 +206,17 @@
}
+void XSECC14n20010315::setInclusive11(void) {
+ m_incl11 = true;
+ m_exclusive = false;
+ m_exclusiveDefault = false;
+}
+
void XSECC14n20010315::setExclusive(void) {
m_exclusive = true;
m_exclusiveDefault = true;
-
+ m_incl11 = false;
}
void XSECC14n20010315::setExclusive(char * xmlnsList) {
@@ -222,7 +228,7 @@
// Set up the define non-exclusive prefixes
nsBuf = new char [strlen(xmlnsList) + 1];
-
+
if (nsBuf == NULL) {
throw XSECException (XSECException::MemoryAllocationFail,
@@ -238,7 +244,7 @@
while (xmlnsList[i] == ' ' ||
xmlnsList[i] == '\0' ||
- xmlnsList[i] == '\t' ||
+ xmlnsList[i] == '\t' ||
xmlnsList[i] == '\r' ||
xmlnsList[i] == '\n')
@@ -247,7 +253,7 @@
j = 0;
while (!(xmlnsList[i] == ' ' ||
xmlnsList[i] == '\0' ||
- xmlnsList[i] == '\t' ||
+ xmlnsList[i] == '\t' ||
xmlnsList[i] == '\r' ||
xmlnsList[i] == '\n'))
@@ -277,7 +283,7 @@
-
+
// --------------------------------------------------------------------------------
// XSECC14n20010315 methods
@@ -298,7 +304,7 @@
if (tmpAtts != NULL)
size = tmpAtts->getLength();
- else
+ else
size = 0;
XMLSize_t i;
@@ -313,8 +319,8 @@
}
}
-
-
+
+
// Constructors
void XSECC14n20010315::init() {
@@ -323,13 +329,13 @@
// Set up the Xerces formatter
- XSECnew(mp_formatter, XSECSafeBufferFormatter("UTF-8",XMLFormatter::NoEscapes,
+ XSECnew(mp_formatter, XSECSafeBufferFormatter("UTF-8",XMLFormatter::NoEscapes,
XMLFormatter::UnRep_CharRef));
// Set up for first attribute list
mp_attributes = mp_currentAttribute = mp_firstNonNsAttribute = NULL;
-
+
// By default process comments
m_processComments = true;
@@ -349,6 +355,9 @@
m_exclusive = false;
m_exclusiveDefault = false;
+ // Default to 1.0 mode
+ m_incl11 = false;
+
// Namespace handling
m_useNamespaceStack = true;
@@ -365,10 +374,10 @@
// Just call the init function;
- init();
+ init();
};
-XSECC14n20010315::XSECC14n20010315(DOMDocument *newDoc,
+XSECC14n20010315::XSECC14n20010315(DOMDocument *newDoc,
DOMNode *newStartNode) : XSECCanon(newDoc, newStartNode) {
// Just call the init function
@@ -440,7 +449,7 @@
XPathEvaluator::initialize();
// We use Xalan to process the Xerces DOM tree and get the XPath nodes
-
+
XercesDOMSupport theDOMSupport;
#if defined XSEC_XERCESPARSERLIAISON_REQS_DOMSUPPORT
XercesParserLiaison theParserLiaison(theDOMSupport);
@@ -458,7 +467,7 @@
xe->setAttribute(/*XalanDOMString(""), */XalanDOMString("xmlns:ietf"), XalanDOMString("http://www.ietf.org"));
// Set up the XPath evaluator
-
+
XPathEvaluator theEvaluator;
// OK, let's find the context node...
@@ -476,16 +485,16 @@
if (theContextNode == 0)
{
-
+
// No appropriate nodes.
return 0;
-
+
}
// OK, let's evaluate the expression...
XalanDOMString ed = XalanDOMString(XPathExpr);
const XalanDOMChar * expr = ed.c_str();
-
+
#if defined XSEC_SELECTNODELIST_REQS_NODEREFLIST
NodeRefList output;
@@ -508,16 +517,16 @@
xe));
//theDoc->getDocumentElement()));
#endif
-
+
//XercesDocumentBridge *theBridge = theParserLiaison.mapDocument(theDoc);
XercesDocumentWrapper *theWrapper = theParserLiaison.mapDocumentToWrapper(theDoc);
XercesWrapperNavigator theWrapperNavigator(theWrapper);
int size = (int) theResult.getLength();
const DOMNode *item;
-
+
for (int i = 0; i < size; ++ i) {
-
+
item = theWrapperNavigator.mapNode(theResult.item(i));
m_XPathMap.addNode(item);
//tmp->element = theBridgeNavigator.mapNode(theResult.item(i));
@@ -567,7 +576,7 @@
switch (c) {
- case '&' :
+ case '&' :
ret[j++] = '&';
ret[j++] = 'a';
@@ -585,7 +594,7 @@
ret[j++] = ';';
break;
-
+
case '>' :
ret[j++] = '&';
@@ -594,7 +603,7 @@
ret[j++] = ';';
break;
-
+
case 0xD :
ret[j++] = '&';
@@ -678,7 +687,7 @@
ret[j++] = ';';
break;
-
+
case 0x9 :
ret[j++] = '&';
@@ -688,7 +697,7 @@
ret[j++] = ';';
break;
-
+
case 0xA :
ret[j++] = '&';
@@ -698,7 +707,7 @@
ret[j++] = ';';
break;
-
+
case 0xD :
ret[j++] = '&';
@@ -782,7 +791,7 @@
while (parent != NULL) {
if (!m_XPathSelection || m_XPathMap.hasNode(parent)) {
-
+
// An output ancestor
if (visiblyUtilises(parent, localName)) {
@@ -826,7 +835,7 @@
return true;
}
-
+
// Either we are now in non-exclusive mode, or the name space in question
// Is to be treated as non-exclusive
@@ -846,7 +855,7 @@
if (m_useNamespaceStack) {
- // In this case, we need to go up until we find the namespace definition
+ // In this case, we need to go up until we find the namespace definition
// in question
parent = e->getParentNode();
@@ -965,7 +974,7 @@
// All done!
m_allNodesDone = true;
-
+
return 0;
}
@@ -980,7 +989,7 @@
// Empty document?
m_allNodesDone = true;
-
+
}
mp_nextNode = next;
@@ -998,30 +1007,30 @@
if (processNode) {
if ((mp_nextNode->getParentNode() == mp_doc) && m_firstElementProcessed) {
-
+
// this is a top level node and first element done
m_buffer.sbStrcpyIn("\x00A<?");
-
+
}
else
m_buffer.sbStrcpyIn("<?");
-
+
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeName());
m_buffer.sbStrcatIn(m_formatBuffer);
-
+
m_formatBuffer << (*mp_formatter << ((DOMProcessingInstruction *) mp_nextNode)->getData());
if (m_formatBuffer.sbStrlen() > 0) {
m_buffer.sbStrcatIn(" ");
m_buffer.sbStrcatIn(m_formatBuffer);
}
-
+
m_buffer.sbStrcatIn("?>");
-
+
if ((mp_nextNode->getParentNode() == mp_doc) && !m_firstElementProcessed) {
-
+
// this is a top level node and first element done
m_buffer.sbStrcatIn("\x00A");
-
+
}
}
@@ -1035,27 +1044,27 @@
if (processNode && m_processComments) {
if ((mp_nextNode->getParentNode() == mp_doc) && m_firstElementProcessed) {
-
+
// this is a top level node and first element done
m_buffer.sbStrcpyIn("\x00A<!--");
-
+
}
else
m_buffer.sbStrcpyIn("<!--");
-
+
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeValue());
if (m_formatBuffer.sbStrlen() > 0) {
m_buffer.sbStrcatIn(m_formatBuffer);
}
-
+
m_buffer.sbStrcatIn("-->");
-
+
if ((mp_nextNode->getParentNode() == mp_doc) && !m_firstElementProcessed) {
-
+
// this is a top level node and first element done
m_buffer.sbStrcatIn("\x00A");
-
+
}
}
@@ -1084,7 +1093,7 @@
// If we are going "up" then we simply close off the element
if (m_returnedFromChild) {
- if (processNode) {
+ if (processNode) {
m_buffer.sbStrcpyIn ("</");
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeName());
m_buffer.sbStrcatIn(m_formatBuffer);
@@ -1097,7 +1106,7 @@
break;
}
- if (processNode) {
+ if (processNode) {
m_buffer.sbStrcpyIn("<");
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeName());
@@ -1123,7 +1132,7 @@
if (tmpAtts != NULL)
size = tmpAtts->getLength();
- else
+ else
size = 0;
XSECNodeListElt *toIns;
@@ -1136,7 +1145,7 @@
currentValue << (*mp_formatter << tmpAtts->item(i)->getNodeValue());
// Build the string used to sort this node
-
+
if ((next == mp_nextNode) && currentName.sbStrncmp("xmlns", 5) == 0) {
// Are we using the namespace stack? If so - store this for later
@@ -1156,34 +1165,35 @@
if (checkRenderNameSpaceNode(mp_nextNode, tmpAtts->item(i))) {
// Add to the list
-
+
m_formatBuffer << (*mp_formatter << tmpAtts->item(i)->getNodeName());
if (m_formatBuffer[5] == ':')
currentName.sbStrcpyIn((char *) &m_formatBuffer[6]);
else
currentName.sbStrcpyIn("");
-
+
toIns = new XSECNodeListElt;
toIns->element = tmpAtts->item(i);
-
+
// Build and insert name space node
toIns->sortString.sbStrcpyIn(XMLNS_PREFIX);
toIns->sortString.sbStrcatIn(currentName);
-
+
// Insert node
mp_attributes = insertNodeIntoList(mp_attributes, toIns);
-
+
}
}
}
else {
-
+
// A "normal" attribute - only process if selected or no XPath or is an
// XML node from a previously un-printed Element node
- bool XMLElement = (next != mp_nextNode) && !m_exclusive && !currentName.sbStrncmp("xml:", 4);
+ bool XMLElement = (next != mp_nextNode) && (!m_exclusive) && !currentName.sbStrncmp("xml:", 4) &&
+ (!m_incl11 || currentName.sbStrcmp("xml:id"));
// If we have an XML element, make sure it was not printed between this
// node and the node currently being worked on
@@ -1206,12 +1216,12 @@
if (ta != NULL)
sz = ta->getLength();
- else
+ else
sz = 0;
for (XMLSize_t j = 0; j < sz; ++j) {
- if (strEquals(ta->item(j)->getNodeName(),
+ if (strEquals(ta->item(j)->getNodeName(),
tmpAtts->item(i)->getNodeName()) == true) {
XMLElement = false;
@@ -1229,20 +1239,20 @@
}
-
-
- if ((!m_XPathSelection && next == mp_nextNode) || XMLElement || ((next == mp_nextNode) && m_XPathMap.hasNode(tmpAtts->item(i)))) {
-
+
+
+ if ((!m_XPathSelection && next == mp_nextNode) || XMLElement || ((next == mp_nextNode) && m_XPathMap.hasNode(tmpAtts->item(i)))) {
+
toIns = new XSECNodeListElt;
toIns->element = tmpAtts->item(i);
-
+
// First the correct prefix to ensure will be sorted
// in correct placing against XMLNS nodes
toIns->sortString.sbStrcpyIn(ATTRIBUTE_PREFIX);
-
+
// Find the namespace URI
- const XMLCh * nsURI =
+ const XMLCh * nsURI =
tmpAtts->item(i)->getNamespaceURI();
if (nsURI == NULL) {
@@ -1264,7 +1274,7 @@
// Insert node
mp_attributes = insertNodeIntoList(mp_attributes, toIns);
-
+
} /* else (sbStrCmp xmlns) */
}
} /* for */
@@ -1305,26 +1315,26 @@
// Add to the list
XSECNodeListElt *toIns;
-
+
m_formatBuffer << (*mp_formatter << nsnode->getNodeName());
if (m_formatBuffer[5] == ':')
currentName.sbStrcpyIn((char *) &m_formatBuffer[6]);
else
currentName.sbStrcpyIn("");
-
+
toIns = new XSECNodeListElt;
toIns->element = nsnode;
-
+
// Build and insert name space node
toIns->sortString.sbStrcpyIn(XMLNS_PREFIX);
toIns->sortString.sbStrcatIn(currentName);
-
+
// Insert node
mp_attributes = insertNodeIntoList(mp_attributes, toIns);
// Mark as printed in the NS Stack
m_nsStack.printNamespace(nsnode, mp_nextNode);
-
+
}
nsnode = m_nsStack.getNextNamespace();
}
@@ -1350,7 +1360,7 @@
if (!m_XPathSelection || m_useNamespaceStack || m_XPathMap.hasNode(next)) {
DOMNode *tmpAtt;
-
+
// An output ancestor
if (visiblyUtilises(next, sbLocalName)) {
DOMNode * nextAttParent = next;
@@ -1405,7 +1415,7 @@
XMLSize_t size;
if (next != NULL)
tmpAtts = next->getAttributes();
-
+
if (next != NULL && tmpAtts != NULL)
size = tmpAtts->getLength();
else
@@ -1430,24 +1440,24 @@
}
if (m_useNamespaceStack && next != NULL)
next = next->getParentNode();
- else
+ else
next = NULL;
}
}
// Did we find a non empty namespace?
if (xmlnsFound) {
-
+
currentName.sbStrcpyIn(""); // Don't include xmlns prefix
XSECNodeListElt * toIns;
-
+
toIns = new XSECNodeListElt;
toIns->element = NULL; // To trigger the state engine
-
+
// Build and insert name space node
toIns->sortString.sbStrcpyIn(XMLNS_PREFIX);
toIns->sortString.sbStrcatIn(currentName);
-
+
// Insert node
mp_attributes = insertNodeIntoList(mp_attributes, toIns);
}
@@ -1467,11 +1477,11 @@
return m_bufferLength;
} /* attrributes != NULL */
-
+
if (processNode)
m_buffer.sbStrcatIn(">");
-
+
// Fall through to find next node
break;
@@ -1480,20 +1490,20 @@
// Always process an attribute node as we have already checked they should
// be printed
-
+
m_buffer.sbStrcpyIn(" ");
if (mp_nextNode != 0) {
-
+
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeName());
m_buffer.sbStrcatIn(m_formatBuffer);
-
+
m_buffer.sbStrcatIn("=\"");
-
+
m_formatBuffer << (*mp_formatter << mp_nextNode->getNodeValue());
sbWork = c14nCleanAttribute(m_formatBuffer);
m_buffer.sbStrcatIn(sbWork);
-
+
m_buffer.sbStrcatIn("\"");
}
else {
@@ -1501,7 +1511,7 @@
m_buffer.sbStrcatIn("=\"");
m_buffer.sbStrcatIn("\"");
}
-
+
// Now see if next node is an attribute
@@ -1532,7 +1542,7 @@
mp_nextNode = mp_attributeParent;
// End the element definition
- if (!m_XPathSelection || (m_XPathMap.hasNode(mp_nextNode)))
+ if (!m_XPathSelection || (m_XPathMap.hasNode(mp_nextNode)))
m_buffer.sbStrcatIn(">");
m_returnedFromChild = false;
@@ -1550,9 +1560,9 @@
m_bufferLength = m_buffer.sbStrlen();;
m_bufferPoint = 0;
-
+
// Firstly, was the last piece of processing because we "came up" from a child node?
-
+
if (m_returnedFromChild) {
if (mp_nextNode == mp_startNode) {
@@ -1567,9 +1577,9 @@
// we have closed off the main mp_doc elt
m_firstElementProcessed = true;
-
+
}
-
+
}
else {
@@ -1580,7 +1590,7 @@
if (next != NULL)
mp_nextNode = next;
-
+
else
// No children, so need to close this node off!
Modified: xml/security/trunk/c/src/canon/XSECC14n20010315.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/canon/XSECC14n20010315.hpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/canon/XSECC14n20010315.hpp (original)
+++ xml/security/trunk/c/src/canon/XSECC14n20010315.hpp Tue Jun 9 16:58:25 2009
@@ -98,7 +98,7 @@
// Constructors
XSECC14n20010315();
XSECC14n20010315(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc);
- XSECC14n20010315(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc,
+ XSECC14n20010315(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc,
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newStartNode);
virtual ~XSECC14n20010315();
@@ -115,6 +115,9 @@
void setExclusive(void);
void setExclusive(char * xmlnsList);
+ // Inclusive 1.1 processing
+ void setInclusive11(void);
+
// Namespace processing
void setUseNamespaceStack(bool flag) {m_useNamespaceStack = flag;}
@@ -129,7 +132,7 @@
private:
void init();
- bool checkRenderNameSpaceNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *e,
+ bool checkRenderNameSpaceNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *e,
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *a);
void stackInit(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * n);
@@ -159,6 +162,9 @@
bool m_exclusive;
bool m_exclusiveDefault;
+ // For Inclusive 1.1 support
+ bool m_incl11;
+
// How do we handle namespaces?
// Use the namespace stack if name space expansion has not been run on the document.
// NOTE : Using the name space stack *will* cause problems if a full XPath expression
Modified: xml/security/trunk/c/src/dsig/DSIGConstants.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGConstants.cpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGConstants.cpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGConstants.cpp Tue Jun 9 16:58:25 2009
@@ -167,6 +167,8 @@
const XMLCh * DSIGConstants::s_unicodeStrURIENVELOPE;
const XMLCh * DSIGConstants::s_unicodeStrURIC14N_NOC;
const XMLCh * DSIGConstants::s_unicodeStrURIC14N_COM;
+const XMLCh * DSIGConstants::s_unicodeStrURIC14N11_NOC;
+const XMLCh * DSIGConstants::s_unicodeStrURIC14N11_COM;
const XMLCh * DSIGConstants::s_unicodeStrURIEXC_C14N_NOC;
const XMLCh * DSIGConstants::s_unicodeStrURIEXC_C14N_COM;
const XMLCh * DSIGConstants::s_unicodeStrURIDSA_SHA1;
@@ -241,6 +243,8 @@
s_unicodeStrURIENVELOPE = XMLString::transcode(URI_ID_ENVELOPE);
s_unicodeStrURIC14N_NOC = XMLString::transcode(URI_ID_C14N_NOC);
s_unicodeStrURIC14N_COM = XMLString::transcode(URI_ID_C14N_COM);
+ s_unicodeStrURIC14N11_NOC = XMLString::transcode(URI_ID_C14N11_NOC);
+ s_unicodeStrURIC14N11_COM = XMLString::transcode(URI_ID_C14N11_COM);
s_unicodeStrURIEXC_C14N_NOC = XMLString::transcode(URI_ID_EXC_C14N_NOC);
s_unicodeStrURIEXC_C14N_COM = XMLString::transcode(URI_ID_EXC_C14N_COM);
s_unicodeStrURIDSA_SHA1 = XMLString::transcode(URI_ID_DSA_SHA1);
@@ -311,6 +315,8 @@
XSEC_RELEASE_XMLCH(s_unicodeStrURIENVELOPE);
XSEC_RELEASE_XMLCH(s_unicodeStrURIC14N_NOC);
XSEC_RELEASE_XMLCH(s_unicodeStrURIC14N_COM);
+ XSEC_RELEASE_XMLCH(s_unicodeStrURIC14N11_NOC);
+ XSEC_RELEASE_XMLCH(s_unicodeStrURIC14N11_COM);
XSEC_RELEASE_XMLCH(s_unicodeStrURIEXC_C14N_NOC);
XSEC_RELEASE_XMLCH(s_unicodeStrURIEXC_C14N_COM);
XSEC_RELEASE_XMLCH(s_unicodeStrURIDSA_SHA1);
@@ -343,7 +349,7 @@
XSEC_RELEASE_XMLCH(s_unicodeStrPROVOpenSSL);
XSEC_RELEASE_XMLCH(s_unicodeStrPROVWinCAPI);
- XSEC_RELEASE_XMLCH(s_unicodeStrPROVNSS);
+ XSEC_RELEASE_XMLCH(s_unicodeStrPROVNSS);
}
@@ -514,6 +520,12 @@
else if (strEquals(URI, DSIGConstants::s_unicodeStrURIEXC_C14N_NOC)) {
cm = CANON_C14NE_NOC;
}
+ else if (strEquals(URI, DSIGConstants::s_unicodeStrURIC14N11_NOC)) {
+ cm = CANON_C14N11_NOC;
+ }
+ else if (strEquals(URI, DSIGConstants::s_unicodeStrURIC14N11_COM)) {
+ cm = CANON_C14N11_COM;
+ }
else {
Modified: xml/security/trunk/c/src/dsig/DSIGConstants.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGConstants.hpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGConstants.hpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGConstants.hpp Tue Jun 9 16:58:25 2009
@@ -76,6 +76,8 @@
#define URI_ID_ENVELOPE "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
#define URI_ID_C14N_NOC "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
#define URI_ID_C14N_COM "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
+#define URI_ID_C14N11_NOC "http://www.w3.org/2006/12/xml-c14n11"
+#define URI_ID_C14N11_COM "http://www.w3.org/2006/12/xml-c14n11#WithComments"
#define URI_ID_EXC_C14N_NOC "http://www.w3.org/2001/10/xml-exc-c14n#"
#define URI_ID_EXC_C14N_COM "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"
#define XPATH_EXPR_ENVELOPE "count(ancestor-or-self::dsig:Signature | \
@@ -133,7 +135,9 @@
CANON_C14N_NOC = 1, // C14n without comments
CANON_C14N_COM = 2, // C14n with comments
CANON_C14NE_NOC = 3, // C14n Exclusive (without comments)
- CANON_C14NE_COM = 4 // C14n Exlusive (with Comments
+ CANON_C14NE_COM = 4, // C14n Exlusive (with Comments
+ CANON_C14N11_NOC = 5, // C14n 1.1 without comments
+ CANON_C14N11_COM = 6 // C14n 1.1 with comments
};
enum signatureMethod {
@@ -160,12 +164,12 @@
TRANSFORM_BASE64,
TRANSFORM_C14N,
+ TRANSFORM_C14N11,
TRANSFORM_EXC_C14N,
TRANSFORM_ENVELOPED_SIGNATURE,
TRANSFORM_XPATH,
TRANSFORM_XSLT,
TRANSFORM_XPATH_FILTER
-
};
enum xpathFilterType {
@@ -222,6 +226,16 @@
uri = URI_ID_EXC_C14N_COM;
break;
+ case (CANON_C14N11_NOC) :
+
+ uri = URI_ID_C14N11_NOC;
+ break;
+
+ case (CANON_C14N11_COM) :
+
+ uri = URI_ID_C14N11_COM;
+ break;
+
default :
return false; // Unknown type
@@ -399,12 +413,12 @@
uri = URI_ID_RSA_1_5;
break;
-
+
case (ENCRYPT_RSA_OAEP_MGFP1) :
uri = URI_ID_RSA_OAEP_MGFP1;
break;
-
+
default:
return false;
@@ -455,6 +469,8 @@
static const XMLCh * s_unicodeStrURIENVELOPE;
static const XMLCh * s_unicodeStrURIC14N_NOC;
static const XMLCh * s_unicodeStrURIC14N_COM;
+ static const XMLCh * s_unicodeStrURIC14N11_NOC;
+ static const XMLCh * s_unicodeStrURIC14N11_COM;
static const XMLCh * s_unicodeStrURIEXC_C14N_NOC;
static const XMLCh * s_unicodeStrURIEXC_C14N_COM;
static const XMLCh * s_unicodeStrURIDSA_SHA1;
@@ -471,15 +487,15 @@
static const XMLCh * s_unicodeStrURIHMAC_SHA256;
static const XMLCh * s_unicodeStrURIHMAC_SHA384;
static const XMLCh * s_unicodeStrURIHMAC_SHA512;
-
+
static const XMLCh * s_unicodeStrURIXMLNS;
static const XMLCh * s_unicodeStrURIMANIFEST;
// URIs for Encryption
static const XMLCh * s_unicodeStrURI3DES_CBC;
- static const XMLCh * s_unicodeStrURIAES128_CBC;
- static const XMLCh * s_unicodeStrURIAES192_CBC;
- static const XMLCh * s_unicodeStrURIAES256_CBC;
+ static const XMLCh * s_unicodeStrURIAES128_CBC;
+ static const XMLCh * s_unicodeStrURIAES192_CBC;
+ static const XMLCh * s_unicodeStrURIAES256_CBC;
static const XMLCh * s_unicodeStrURIKW_AES128;
static const XMLCh * s_unicodeStrURIKW_AES192;
static const XMLCh * s_unicodeStrURIKW_AES256;
@@ -541,18 +557,18 @@
// --------------------------------------------------------------------------------
/* Map URIs to internal enums, if the URIs are known to the library.
- If they aren't, all these calls will set the Method variables to
+ If they aren't, all these calls will set the Method variables to
*_NONE, signifying we don't know them. Note this is not necessarily
an error - the calling application may have installed handlers to handle
these URIs, it's just we don't have an internal enum mapping
*/
-bool DSIG_EXPORT XSECmapURIToSignatureMethods(const XMLCh * URI,
- signatureMethod & sm,
+bool DSIG_EXPORT XSECmapURIToSignatureMethods(const XMLCh * URI,
+ signatureMethod & sm,
hashMethod & hm);
-bool DSIG_EXPORT XSECmapURIToHashMethod(const XMLCh * URI,
+bool DSIG_EXPORT XSECmapURIToHashMethod(const XMLCh * URI,
hashMethod & hm);
-bool DSIG_EXPORT XSECmapURIToCanonicalizationMethod(const XMLCh * URI,
+bool DSIG_EXPORT XSECmapURIToCanonicalizationMethod(const XMLCh * URI,
canonicalizationMethod & cm);
#endif /* DSIGCONSTANTS_HEADER */
Modified: xml/security/trunk/c/src/dsig/DSIGTransformC14n.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/dsig/DSIGTransformC14n.cpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/dsig/DSIGTransformC14n.cpp (original)
+++ xml/security/trunk/c/src/dsig/DSIGTransformC14n.cpp Tue Jun 9 16:58:25 2009
@@ -46,7 +46,7 @@
mp_inclNSNode = NULL;
mp_inclNSStr = NULL;
}
-
+
DSIGTransformC14n::DSIGTransformC14n(const XSECEnv * env) :
DSIGTransform(env) {
@@ -56,18 +56,19 @@
mp_inclNSStr = NULL;
}
-
+
DSIGTransformC14n::~DSIGTransformC14n() {};
// --------------------------------------------------------------------------------
// Interface Methods
// --------------------------------------------------------------------------------
-
+
transformType DSIGTransformC14n::getTransformType() {
if ((m_cMethod == CANON_C14NE_NOC) || (m_cMethod == CANON_C14NE_COM))
return TRANSFORM_EXC_C14N;
-
+ else if ((m_cMethod == CANON_C14N11_NOC) || (m_cMethod == CANON_C14N11_COM))
+ return TRANSFORM_C14N11;
return TRANSFORM_C14N;
}
@@ -75,17 +76,19 @@
void DSIGTransformC14n::appendTransformer(TXFMChain * input) {
TXFMC14n * c;
-
+
XSECnew(c, TXFMC14n(mp_txfmNode->getOwnerDocument()));
input->appendTxfm(c);
switch (m_cMethod) {
case (CANON_C14N_NOC) :
+ case (CANON_C14N11_NOC) :
case (CANON_C14NE_NOC) :
c->stripComments();
break;
case (CANON_C14N_COM) :
+ case (CANON_C14N11_COM) :
case (CANON_C14NE_COM) :
c->activateComments();
break;
@@ -93,7 +96,7 @@
break;
}
- // Check for exclusive
+ // Check for exclusive and 1.1
if (m_cMethod == CANON_C14NE_COM || m_cMethod == CANON_C14NE_NOC) {
if (mp_inclNSStr == NULL) {
@@ -110,6 +113,9 @@
}
}
+ else if (m_cMethod == CANON_C14N11_COM || m_cMethod == CANON_C14N11_NOC) {
+ c->setInclusive11();
+ }
}
@@ -121,7 +127,7 @@
DOMDocument *doc = mp_env->getParentDocument();
prefix = mp_env->getDSIGNSPrefix();
-
+
// Create the transform node
makeQName(str, prefix, "Transform");
ret = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
@@ -151,7 +157,7 @@
atts = mp_txfmNode->getAttributes();
- if (atts == NULL ||
+ if (atts == NULL ||
((att = atts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm)) == NULL)) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
@@ -167,6 +173,12 @@
else if (strEquals(uri, DSIGConstants::s_unicodeStrURIC14N_NOC)) {
m_cMethod = CANON_C14N_NOC;
}
+ else if (strEquals(uri, DSIGConstants::s_unicodeStrURIC14N11_COM)) {
+ m_cMethod = CANON_C14N11_COM;
+ }
+ else if (strEquals(uri, DSIGConstants::s_unicodeStrURIC14N11_NOC)) {
+ m_cMethod = CANON_C14N11_NOC;
+ }
else if (strEquals(uri, DSIGConstants::s_unicodeStrURIEXC_C14N_COM)) {
m_cMethod = CANON_C14NE_COM;
}
@@ -185,7 +197,7 @@
// Exclusive, so there may be an InclusiveNamespaces node
DOMNode * inclNSNode = mp_txfmNode->getFirstChild();
-
+
while (inclNSNode != NULL && (inclNSNode->getNodeType() != DOMNode::ELEMENT_NODE ||
!strEquals(getECLocalName(inclNSNode), "InclusiveNamespaces")))
inclNSNode = inclNSNode->getNextSibling();
@@ -226,10 +238,10 @@
}
- if (method == CANON_C14N_NOC || method == CANON_C14N_COM) {
+ if (method == CANON_C14N_NOC || method == CANON_C14N_COM || method == CANON_C14N11_NOC || method == CANON_C14N11_COM) {
if (m_cMethod == CANON_C14NE_NOC || m_cMethod == CANON_C14NE_COM) {
-
+
if (mp_inclNSNode != 0) {
mp_txfmNode->removeChild(mp_inclNSNode);
@@ -288,8 +300,8 @@
str.sbXMLChCat(prefix);
}
- mp_inclNSNode->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
- str.rawXMLChBuffer(),
+ mp_inclNSNode->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
+ str.rawXMLChBuffer(),
DSIGConstants::s_unicodeStrURIEC);
}
Modified: xml/security/trunk/c/src/transformers/TXFMC14n.cpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/transformers/TXFMC14n.cpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/transformers/TXFMC14n.cpp (original)
+++ xml/security/trunk/c/src/transformers/TXFMC14n.cpp Tue Jun 9 16:58:25 2009
@@ -109,7 +109,7 @@
mp_c14n->setUseNamespaceStack(!input->nameSpacesExpanded());
}
-
+
void TXFMC14n::activateComments(void) {
if (input != NULL)
@@ -136,6 +136,13 @@
}
+void TXFMC14n::setInclusive11() {
+
+ if (mp_c14n != NULL)
+ mp_c14n->setInclusive11();
+
+}
+
// Methods to get tranform output type and input requirement
TXFMBase::ioType TXFMC14n::getInputType(void) {
Modified: xml/security/trunk/c/src/transformers/TXFMC14n.hpp
URL: http://svn.apache.org/viewvc/xml/security/trunk/c/src/transformers/TXFMC14n.hpp?rev=783064&r1=783063&r2=783064&view=diff
==============================================================================
--- xml/security/trunk/c/src/transformers/TXFMC14n.hpp (original)
+++ xml/security/trunk/c/src/transformers/TXFMC14n.hpp Tue Jun 9 16:58:25 2009
@@ -38,7 +38,7 @@
private:
XSECC14n20010315 * mp_c14n; // The actual canonicaliser
-
+
public:
TXFMC14n(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc);
@@ -47,7 +47,7 @@
// Methods to set the inputs
void setInput(TXFMBase *newInput);
-
+
// Methods to get tranform output type and input requirement
virtual TXFMBase::ioType getInputType(void);
@@ -61,13 +61,16 @@
virtual void setExclusive();
virtual void setExclusive(safeBuffer & NSList);
+ // Set inclusive 1.1
+ virtual void setInclusive11();
+
// Methods to get output data
virtual unsigned int readBytes(XMLByte * const toFill, const unsigned int maxToFill);
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getDocument();
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *getFragmentNode();
virtual const XMLCh * getFragmentId();
-
+
private:
TXFMC14n();
};