]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / Pkcs7Sign / Pkcs7Sign.py
index 14e92a5d8b5fd7ad95b4a10a8b07cc11c5772429..5630df55dfacf34345dc124c8da02ab2e7a9a9e4 100644 (file)
@@ -7,18 +7,13 @@
 # This tool has been tested with OpenSSL.\r
 #\r
 # Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.  The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
 '''\r
 Pkcs7Sign\r
 '''\r
+from __future__ import print_function\r
 \r
 import os\r
 import sys\r
@@ -77,9 +72,9 @@ if __name__ == '__main__':
   #\r
   parser = argparse.ArgumentParser(prog=__prog__, usage=__usage__, description=__copyright__, conflict_handler='resolve')\r
   group = parser.add_mutually_exclusive_group(required=True)\r
-  group.add_argument("--version", action='version', version=__version__)\r
   group.add_argument("-e", action="store_true", dest='Encode', help='encode file')\r
   group.add_argument("-d", action="store_true", dest='Decode', help='decode file')\r
+  group.add_argument("--version", action='version', version=__version__)\r
   parser.add_argument("-o", "--output", dest='OutputFile', type=str, metavar='filename', help="specify the output filename", required=True)\r
   parser.add_argument("--signer-private-cert", dest='SignerPrivateCertFile', type=argparse.FileType('rb'), help="specify the signer private cert filename.  If not specified, a test signer private cert is used.")\r
   parser.add_argument("--other-public-cert", dest='OtherPublicCertFile', type=argparse.FileType('rb'), help="specify the other public cert filename.  If not specified, a test other public cert is used.")\r
@@ -121,7 +116,7 @@ if __name__ == '__main__':
   if Process.returncode != 0:\r
     print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print(Version[0].decode())\r
+  print(Version[0].decode(encoding='utf-8', errors='ignore'))\r
 \r
   #\r
   # Read input file into a buffer and save input filename\r
@@ -141,11 +136,11 @@ if __name__ == '__main__':
 \r
   try:\r
     if args.MonotonicCountStr.upper().startswith('0X'):\r
-      args.MonotonicCountValue = (int)(args.MonotonicCountStr, 16)\r
+      args.MonotonicCountValue = int(args.MonotonicCountStr, 16)\r
     else:\r
-      args.MonotonicCountValue = (int)(args.MonotonicCountStr)\r
+      args.MonotonicCountValue = int(args.MonotonicCountStr)\r
   except:\r
-    args.MonotonicCountValue = (int)(0)\r
+    args.MonotonicCountValue = int(0)\r
 \r
   if args.Encode:\r
     #\r
@@ -251,9 +246,9 @@ if __name__ == '__main__':
       sys.exit(1)\r
     else:\r
       if args.SignatureSizeStr.upper().startswith('0X'):\r
-        SignatureSize = (int)(args.SignatureSizeStr, 16)\r
+        SignatureSize = int(args.SignatureSizeStr, 16)\r
       else:\r
-        SignatureSize = (int)(args.SignatureSizeStr)\r
+        SignatureSize = int(args.SignatureSizeStr)\r
     if SignatureSize < 0:\r
         print("ERROR: The value of option --signature-size can't be set to negative value!")\r
         sys.exit(1)\r