]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/CapsuleData.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CapsuleData.py
index efc281222bd585b19d4a9dc4fc2a3d6635aa376b..5b806d9e44825a6a1a4d20cd05cbc365f9e73004 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # generate capsule\r
 #\r
-#  Copyright (c) 2007-2013, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007-2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -21,6 +21,7 @@ import StringIO
 from struct import pack\r
 import os\r
 from Common.Misc import SaveFileOnChange\r
+import uuid\r
 \r
 ## base class for capsule data\r
 #\r
@@ -178,13 +179,25 @@ class CapsulePayload(CapsuleData):
         self.ImageTypeId = None\r
         self.ImageIndex = None\r
         self.HardwareInstance = None\r
-        self.ImageFile = None\r
-        self.VendorCodeFile = None\r
+        self.ImageFile = []\r
+        self.VendorCodeFile = []\r
+        self.Certificate_Guid = None\r
+        self.MonotonicCount = None\r
+        self.Existed = False\r
+        self.Buffer = None\r
 \r
-    def GenCapsuleSubItem(self):\r
+    def GenCapsuleSubItem(self, AuthData=[]):\r
         if not self.Version:\r
-            self.Version = 0x00000002\r
+            self.Version = '0x00000002'\r
+        if not self.ImageIndex:\r
+            self.ImageIndex = '0x1'\r
+        if not self.HardwareInstance:\r
+            self.HardwareInstance = '0x0'\r
         ImageFileSize = os.path.getsize(self.ImageFile)\r
+        if AuthData:\r
+            # the ImageFileSize need include the full authenticated info size. From first bytes of MonotonicCount to last bytes of certificate.\r
+            # the 32 bit is the MonotonicCount, dwLength, wRevision, wCertificateType and CertType\r
+            ImageFileSize += 32\r
         VendorFileSize = 0\r
         if self.VendorCodeFile:\r
             VendorFileSize = os.path.getsize(self.VendorCodeFile)\r
@@ -214,6 +227,10 @@ class CapsulePayload(CapsuleData):
                        VendorFileSize,\r
                        int(self.HardwareInstance, 16)\r
                        )\r
+        if AuthData:\r
+            Buffer += pack('QIHH', AuthData[0], AuthData[1], AuthData[2], AuthData[3])\r
+            Buffer += uuid.UUID(AuthData[4]).get_bytes_le()\r
+\r
         #\r
         # Append file content to the structure\r
         #\r
@@ -224,4 +241,5 @@ class CapsulePayload(CapsuleData):
             VendorFile = open(self.VendorCodeFile, 'rb')\r
             Buffer += VendorFile.read()\r
             VendorFile.close()\r
+        self.Existed = True\r
         return Buffer\r