<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 2020-09-29, at 10:03, Weiwu Zhang <<a href="mailto:weiwu.zhang@alphawallet.com" class="">weiwu.zhang@alphawallet.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">1. that xmlsectool inserts the signature as the last element of the<br class="">document, within the document element, not outside of it.<br class=""></div></div></blockquote><div><br class=""></div><div>OK, the --signaturePosition LAST option should be doing that for you.</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class="">3. that the signature is applied on the digest of the canonicalised<br class="">node or nodes that it applies to (i.e. the canonicalised XML is only used in memory, not written to the output).<br class=""></blockquote><div><br class=""></div><div>That's what the code does.</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class="">2. that in doing so, every line of the input (typically unsigned) XML<br class="">document remain intact, not canonicalised, up to the point where the<br class="">signature is inserted before the closing of the document element.<br class=""></div></div></blockquote><div><br class=""></div><div>The input document is not canonicalised before being written to the output file. Canonicalisation is a process performed entirely inside the signature generation library as part of generating the digest.</div><div><br class=""></div><div>If you're seeing differences between the input and output, it's not because of canonicalisation. It's probably down to the serialiser that is used to write the XML document back out again. In general, things that are not part of the document model may not be preserved:</div><div><br class=""></div><div>* Any text prior to the document element (including the "<?xml" header)</div><div><br class=""></div><div>* White space within tags</div><div><br class=""></div><div>* Order of XML attributes within tags</div><div><br class=""></div><div>This is just part of life with XML; if your application depends on preservation of this kind of detailed formatting information, XML may not be the right data format for you.</div><div><br class=""></div><div>It's *particularly* part of life with XML in Java: the language execution environment dictates all aspects of this, and they are not configurable to do what you want. It's possible that other languages make it possible to do this, but I can't help you with that.</div><div><br class=""></div></div><div class=""><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; border-spacing: 0px; -webkit-text-decorations-in-effect: none;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div class=""> -- Ian<br class=""></div><div class=""><span class="Apple-style-span" style="font-size: medium;"><br class=""></span></div></span></div></span><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""></body></html>