# 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
#\r
# Create command line argument parser object\r
#\r
- parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve')\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("-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
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])\r
+ print(Version[0].decode(encoding='utf-8', errors='ignore'))\r
\r
#\r
# Read input file into a buffer and save input filename\r
\r
try:\r
if args.MonotonicCountStr.upper().startswith('0X'):\r
- args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)\r
+ args.MonotonicCountValue = int(args.MonotonicCountStr, 16)\r
else:\r
- args.MonotonicCountValue = (long)(args.MonotonicCountStr)\r
+ args.MonotonicCountValue = int(args.MonotonicCountStr)\r
except:\r
- args.MonotonicCountValue = (long)(0)\r
+ args.MonotonicCountValue = int(0)\r
\r
if args.Encode:\r
#\r
sys.exit(1)\r
else:\r
if args.SignatureSizeStr.upper().startswith('0X'):\r
- SignatureSize = (long)(args.SignatureSizeStr, 16)\r
+ SignatureSize = int(args.SignatureSizeStr, 16)\r
else:\r
- SignatureSize = (long)(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