diff options
author | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:27:53 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:29:14 +0800 |
commit | 1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch) | |
tree | 0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | |
parent | 678f85131238622e576705117e299d81cff755c9 (diff) | |
download | edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.gz edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.bz2 edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.zip |
Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f85131238622e576705117e299d81cff755c9.
Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py')
-rw-r--r-- | BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index 2f901a7f29..3fd7eefd6a 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -17,6 +17,7 @@ '''
Rsa2048Sha256Sign
'''
+from __future__ import print_function
import os
import sys
@@ -61,9 +62,8 @@ if __name__ == '__main__': #
# Create command line argument parser object
#
- parser = argparse.ArgumentParser(prog=__prog__, usage=__usage__, description=__copyright__, conflict_handler='resolve')
+ parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve')
group = parser.add_mutually_exclusive_group(required=True)
- group.add_argument("--version", action='version', version=__version__)
group.add_argument("-e", action="store_true", dest='Encode', help='encode file')
group.add_argument("-d", action="store_true", dest='Decode', help='decode file')
parser.add_argument("-o", "--output", dest='OutputFile', type=str, metavar='filename', help="specify the output filename", required=True)
@@ -104,7 +104,7 @@ if __name__ == '__main__': if Process.returncode != 0:
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print(Version[0].decode())
+ print(Version[0])
#
# Read input file into a buffer and save input filename
@@ -152,11 +152,10 @@ if __name__ == '__main__': # Extract public key from private key into STDOUT
#
Process = subprocess.Popen('%s rsa -in "%s" -modulus -noout' % (OpenSslCommand, args.PrivateKeyFileName), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- PublicKeyHexString = Process.communicate()[0].split(b'=')[1].strip()
- PublicKeyHexString = PublicKeyHexString.decode(encoding='utf-8')
+ PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()
PublicKey = ''
while len(PublicKeyHexString) > 0:
- PublicKey = PublicKey + PublicKeyHexString[0:2]
+ PublicKey = PublicKey + chr(int(PublicKeyHexString[0:2], 16))
PublicKeyHexString=PublicKeyHexString[2:]
if Process.returncode != 0:
sys.exit(Process.returncode)
@@ -164,9 +163,9 @@ if __name__ == '__main__': if args.MonotonicCountStr:
try:
if args.MonotonicCountStr.upper().startswith('0X'):
- args.MonotonicCountValue = (int)(args.MonotonicCountStr, 16)
+ args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
else:
- args.MonotonicCountValue = (int)(args.MonotonicCountStr)
+ args.MonotonicCountValue = (long)(args.MonotonicCountStr)
except:
pass
@@ -187,8 +186,8 @@ if __name__ == '__main__': # Write output file that contains hash GUID, Public Key, Signature, and Input data
#
args.OutputFile = open(args.OutputFileName, 'wb')
- args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.bytes_le)
- args.OutputFile.write(bytearray.fromhex(PublicKey))
+ args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.get_bytes_le())
+ args.OutputFile.write(PublicKey)
args.OutputFile.write(Signature)
args.OutputFile.write(args.InputFileBuffer)
args.OutputFile.close()
@@ -210,7 +209,7 @@ if __name__ == '__main__': #
# Verify the public key
#
- if Header.PublicKey != bytearray.fromhex(PublicKey):
+ if Header.PublicKey != PublicKey:
print('ERROR: Public key in input file does not match public key from private key file')
sys.exit(1)
|