usawa

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | Submodules | LICENSE

commit b094026187059f7442bb57714161831b51658213
parent c19f23384b22acf5b22ea3bcdd11e02c37f56572
Author: lash <dev@holbrook.no>
Date:   Fri, 13 Feb 2026 12:41:53 +0000

Add canonical XML export for attachmemt, use in entry sign

Diffstat:
Mdummy/tests/entry.py | 1-
Mdummy/usawa/asset.py | 2++
Mdummy/usawa/entry.py | 8+++++---
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dummy/tests/entry.py b/dummy/tests/entry.py @@ -122,7 +122,6 @@ class TestEntry(unittest.TestCase): wallet = DemoWallet() o.sign(wallet) tree = o.to_tree() - logg.debug('entry tree with attachment {}'.format(lxml.etree.tostring(tree))) if __name__ == '__main__': diff --git a/dummy/usawa/asset.py b/dummy/usawa/asset.py @@ -199,6 +199,8 @@ class Asset: """Generate and return an XML representation of the asset. + :param canon: Return canonical results to use in signature material. + :type canon: boolean :returns: XML tree representing the asset. :rtype: lxml.etree.Element :todo: implement sigs diff --git a/dummy/usawa/entry.py b/dummy/usawa/entry.py @@ -430,11 +430,13 @@ class Entry: """Generate and return an XML representation of the entry. + :param canon: Return canonical results to use in signature material. + :type canon: boolean :todo: Make sure that sigs publickey lookup key is bytes type :returns: XML tree representing the entry. :rtype: lxml.etree.Element """ - def to_tree(self): + def to_tree(self, canon=False): #tree = etree.Element('entry', type=self.typ) tree = lxml.etree.Element(NSPREFIX + 'entry', nsmap=nsmap()) data = lxml.etree.Element('data') @@ -473,7 +475,7 @@ class Entry: data.append(o) for v in self.attachment: - o = v.to_tree() + o = v.to_tree(canon=canon) data.append(o) tree.append(data) @@ -496,7 +498,7 @@ class Entry: :todo: replace attachment list with only non-optional parts for signature. """ def canon(self): - tree = self.to_tree() + tree = self.to_tree(canon=True) b = lxml.etree.canonicalize(tree, strip_text=True, exclude_tags=['sig']) return b.encode('utf-8')