[PATCH v2 1/3] binman: Ignore hash*, signature* nodes in sections

Alper Nebi Yasak alpernebiyasak at gmail.com
Mon Aug 31 11:58:18 CEST 2020


Switch to str.startswith for matching like the FIT etype does since the
current version doesn't ignore 'hash-1', 'hash-2', etc.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
---

Changes in v2:
- Add test to check that sections ignore hash*, signature* nodes

 tools/binman/etype/section.py                 |  2 +-
 tools/binman/ftest.py                         |  6 +++
 .../165_section_ignore_hash_signature.dts     | 40 +++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/165_section_ignore_hash_signature.dts

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 73c5553c81..c5166a5b57 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -83,7 +83,7 @@ class Entry_section(Entry):
 
     def _ReadEntries(self):
         for node in self._node.subnodes:
-            if node.name == 'hash':
+            if node.name.startswith('hash') or node.name.startswith('signature'):
                 continue
             entry = Entry.Create(self, node)
             entry.ReadNode()
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5f650b5f94..ab88ee96ab 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3477,5 +3477,11 @@ class TestFunctional(unittest.TestCase):
         fnode = dtb.GetNode('/images/kernel')
         self.assertNotIn('data', fnode.props)
 
+    def testSectionIgnoreHashSignature(self):
+        """Test that sections ignore hash, signature nodes for its data"""
+        data = self._DoReadFile('165_section_ignore_hash_signature.dts')
+        expected = (U_BOOT_DATA + U_BOOT_DATA)
+        self.assertEqual(expected, data)
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/165_section_ignore_hash_signature.dts b/tools/binman/test/165_section_ignore_hash_signature.dts
new file mode 100644
index 0000000000..8adbe25512
--- /dev/null
+++ b/tools/binman/test/165_section_ignore_hash_signature.dts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		section at 0 {
+			u-boot {
+			};
+			hash {
+				algo = "sha256";
+			};
+			signature {
+				algo = "sha256,rsa2048";
+				key-name-hint = "dev";
+			};
+		};
+		section at 1 {
+			u-boot {
+			};
+			hash-1 {
+				algo = "sha1";
+			};
+			hash-2 {
+				algo = "sha256";
+			};
+			signature-1 {
+				algo = "sha1,rsa2048";
+				key-name-hint = "dev";
+			};
+			signature-2 {
+				algo = "sha256,rsa2048";
+				key-name-hint = "dev";
+			};
+		};
+	};
+};
-- 
2.28.0



More information about the U-Boot mailing list