## @file\r
-# This tool can be used to generate new RSA 2048 bit private/public key pairs \r
-# in a PEM file format using OpenSSL command line utilities that are installed \r
+# This tool can be used to generate new RSA 2048 bit private/public key pairs\r
+# in a PEM file format using OpenSSL command line utilities that are installed\r
# on the path specified by the system environment variable OPENSSL_PATH.\r
-# This tool can also optionally write one or more SHA 256 hashes of 2048 bit \r
-# public keys to a binary file, write one or more SHA 256 hashes of 2048 bit \r
-# public keys to a file in a C structure format, and in verbose mode display \r
-# one or more SHA 256 hashes of 2048 bit public keys in a C structure format \r
+# This tool can also optionally write one or more SHA 256 hashes of 2048 bit\r
+# public keys to a binary file, write one or more SHA 256 hashes of 2048 bit\r
+# public keys to a file in a C structure format, and in verbose mode display\r
+# one or more SHA 256 hashes of 2048 bit public keys in a C structure format\r
# on STDOUT.\r
# This tool has been tested with OpenSSL 1.0.1e 11 Feb 2013\r
#\r
\r
import os\r
import sys\r
-import argparse \r
+import argparse\r
import subprocess\r
from Common.BuildVersion import gBUILD_VERSION\r
\r
#\r
__prog__ = 'Rsa2048Sha256GenerateKeys'\r
__version__ = '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION)\r
-__copyright__ = 'Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.'\r
+__copyright__ = 'Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.'\r
__usage__ = '%s [options]' % (__prog__)\r
\r
\r
if __name__ == '__main__':\r
#\r
# Create command line argument parser object\r
- # \r
+ #\r
parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve')\r
group = parser.add_mutually_exclusive_group(required=True)\r
group.add_argument("-o", "--output", dest='OutputFile', type=argparse.FileType('wb'), metavar='filename', nargs='*', help="specify the output private key filename in PEM format")\r
\r
#\r
# Parse command line arguments\r
- # \r
+ #\r
args = parser.parse_args()\r
\r
#\r
#\r
try:\r
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
- except: \r
+ except:\r
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(1)\r
- \r
+\r
Version = Process.communicate()\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
- \r
+\r
args.PemFileName = []\r
- \r
+\r
#\r
# Check for output file argument\r
#\r
if Process.returncode != 0:\r
print('ERROR: RSA 2048 key generation failed')\r
sys.exit(Process.returncode)\r
- \r
+\r
#\r
# Check for input file argument\r
#\r
for Item in PublicKeyHash:\r
PublicKeyHashC = PublicKeyHashC + '0x%02x, ' % (ord(Item))\r
PublicKeyHashC = PublicKeyHashC[:-2] + '}'\r
- \r
+\r
#\r
# Write SHA 256 of 2048 bit binary public key to public key hash C structure file\r
#\r
args.PublicKeyHashCFile.close ()\r
except:\r
pass\r
- \r
+\r
#\r
# If verbose is enabled display the public key in C structure format\r
#\r