As per w3c xmlsec specification which can be found at http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/#sec-Overview , I would like to know are we allowed to add the xml signature element as the last child element under the root node ?
I tried to read through the spec, but its not explicitly mentioned at which location should we add the signature element. I would like to know for sure whether spec emphasizes where should we add the signature element ?
The spec does not emphasize a specific location for the signature element. The URI mechanism allows any location; in particular the following settings :
<SignedDocumentRoot>
....
<ds:Signature>....</ds:Signature>
</SignedDocucmentRoot>
In this setting you must use the Enveloped Transform defined in the spec. Note that the ds:Signature may be the last child but this is not necessary.
<ds:Signature>
....
<ds:Object>
<SignedDocumentRoot>...</SignedDocumentRoot>
</ds:Object>
</ds:Signature>
The ds:Object is defined in the spec. Here, no special transform is mandated.