BaseTools/Capsule: Support capsules without a payload header
authorKinney, Michael D <michael.d.kinney@intel.com>
Sun, 29 Jul 2018 17:57:12 +0000 (10:57 -0700)
committerKinney, Michael D <michael.d.kinney@intel.com>
Thu, 2 Aug 2018 21:35:29 +0000 (14:35 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=1028

Update --dump-info and --decode to show auth header information
even if a payload header is not present.  The --decode operation
still fails if a payload header is not present.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Capsule/GenerateCapsule.py

index 42cd1fb..7b08918 100644 (file)
@@ -455,6 +455,9 @@ if __name__ == '__main__':
                 FmpCapsuleHeader.DumpInfo ()\r
             if UseSignTool or UseOpenSsl:\r
                 Result = FmpAuthHeader.Decode (Result)\r
+                if args.Verbose:\r
+                    print ('--------')\r
+                    FmpAuthHeader.DumpInfo ()\r
 \r
                 #\r
                 # Verify Image with 64-bit MonotonicCount appended to end of image\r
@@ -479,20 +482,25 @@ if __name__ == '__main__':
                 except ValueError:\r
                     print ('GenerateCapsule: warning: can not verify payload.')\r
 \r
-                Result = FmpPayloadHeader.Decode (Result)\r
-                if args.Verbose:\r
-                    print ('--------')\r
-                    FmpAuthHeader.DumpInfo ()\r
-                    print ('--------')\r
-                    FmpPayloadHeader.DumpInfo ()\r
+                try:\r
+                    Result = FmpPayloadHeader.Decode (Result)\r
+                    if args.Verbose:\r
+                        print ('--------')\r
+                        FmpPayloadHeader.DumpInfo ()\r
+                        print ('========')\r
+                except:\r
+                    if args.Verbose:\r
+                        print ('--------')\r
+                        print ('No FMP_PAYLOAD_HEADER')\r
+                        print ('========')\r
+                    raise\r
             else:\r
                 if args.Verbose:\r
                     print ('--------')\r
                     print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION')\r
                     print ('--------')\r
                     print ('No FMP_PAYLOAD_HEADER')\r
-            if args.Verbose:\r
-                print ('========')\r
+                    print ('========')\r
         except:\r
             print ('GenerateCapsule: error: can not decode capsule')\r
             sys.exit (1)\r
@@ -508,11 +516,15 @@ if __name__ == '__main__':
             FmpCapsuleHeader.DumpInfo ()\r
             try:\r
                 Result = FmpAuthHeader.Decode (Result)\r
-                Result = FmpPayloadHeader.Decode (Result)\r
                 print ('--------')\r
                 FmpAuthHeader.DumpInfo ()\r
-                print ('--------')\r
-                FmpPayloadHeader.DumpInfo ()\r
+                try:\r
+                    Result = FmpPayloadHeader.Decode (Result)\r
+                    print ('--------')\r
+                    FmpPayloadHeader.DumpInfo ()\r
+                except:\r
+                    print ('--------')\r
+                    print ('No FMP_PAYLOAD_HEADER')\r
             except:\r
                 print ('--------')\r
                 print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION')\r