From de652b14a78b4767ff460999b6728d7ccc50b057 Mon Sep 17 00:00:00 2001 From: "Kinney, Michael D" Date: Sun, 29 Jul 2018 10:57:12 -0700 Subject: [PATCH] BaseTools/Capsule: Support capsules without a payload header 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 Cc: Jiewen Yao Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-by: Yonghong Zhu --- .../Source/Python/Capsule/GenerateCapsule.py | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/BaseTools/Source/Python/Capsule/GenerateCapsule.py index 42cd1fb8ba..7b08918857 100644 --- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py +++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py @@ -455,6 +455,9 @@ if __name__ == '__main__': FmpCapsuleHeader.DumpInfo () if UseSignTool or UseOpenSsl: Result = FmpAuthHeader.Decode (Result) + if args.Verbose: + print ('--------') + FmpAuthHeader.DumpInfo () # # Verify Image with 64-bit MonotonicCount appended to end of image @@ -479,20 +482,25 @@ if __name__ == '__main__': except ValueError: print ('GenerateCapsule: warning: can not verify payload.') - Result = FmpPayloadHeader.Decode (Result) - if args.Verbose: - print ('--------') - FmpAuthHeader.DumpInfo () - print ('--------') - FmpPayloadHeader.DumpInfo () + try: + Result = FmpPayloadHeader.Decode (Result) + if args.Verbose: + print ('--------') + FmpPayloadHeader.DumpInfo () + print ('========') + except: + if args.Verbose: + print ('--------') + print ('No FMP_PAYLOAD_HEADER') + print ('========') + raise else: if args.Verbose: print ('--------') print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION') print ('--------') print ('No FMP_PAYLOAD_HEADER') - if args.Verbose: - print ('========') + print ('========') except: print ('GenerateCapsule: error: can not decode capsule') sys.exit (1) @@ -508,11 +516,15 @@ if __name__ == '__main__': FmpCapsuleHeader.DumpInfo () try: Result = FmpAuthHeader.Decode (Result) - Result = FmpPayloadHeader.Decode (Result) print ('--------') FmpAuthHeader.DumpInfo () - print ('--------') - FmpPayloadHeader.DumpInfo () + try: + Result = FmpPayloadHeader.Decode (Result) + print ('--------') + FmpPayloadHeader.DumpInfo () + except: + print ('--------') + print ('No FMP_PAYLOAD_HEADER') except: print ('--------') print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION')