[PATCH 2/2] Make header order deterministic

Konstantin Ryabitsev <[email protected]> Fri, 21 May 2021 13:39:33 -0400
Newsgroups org.kernel.lore.signatures
Message-ID <307beab7b103b9859b941b9a41a6ef220dd78dd2.1621618750.git.konstantin@linuxfoundation.org>
I know that it doesn't matter, but the OCD part of me likes seeing the
h= value in a deterministic order.

Signed-off-by: Konstantin Ryabitsev <[email protected]>
---
 patatt/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/patatt/__init__.py b/patatt/__init__.py
index 76028ae..a80f63a 100644
--- a/patatt/__init__.py
+++ b/patatt/__init__.py
@@ -149,8 +149,8 @@ class DevsigHeader:
                 raise SigningError('The following required headers not present: %s'
                                    % (b', '.join(reqset.difference(allhdrs)).decode()))
             # Add optional headers that are actually present
-            optpresent = allhdrs.intersection(optset)
-            signlist = list(reqset.union(optpresent))
+            optpresent = list(allhdrs.intersection(optset))
+            signlist = REQ_HDRS + sorted(optpresent)
             self.hdata['h'] = b':'.join(signlist)
 
         elif mode == 'validate':
-- 
2.31.1