summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2018-06-25 13:31:26 +0300
committerYonghong Zhu <yonghong.zhu@intel.com>2018-06-27 11:33:21 +0300
commit72443dd25014a8b6209895640af36dec33da51e0 (patch)
treece91675cb7bfadbd4c8686b19d3d816fb968f612 /BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
parent5b0671c1e514e534c6d5be9604da33bfc2cd0a24 (diff)
downloadedk2-72443dd25014a8b6209895640af36dec33da51e0.tar.xz
BaseTools: Refactor python print statements
Refactor print statements to be compatible with python 3. Based on "futurize -f libfuturize.fixes.fix_print_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py')
-rw-r--r--BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index 9711de8f5c..41bcaa0437 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -22,6 +22,7 @@
'''
Rsa2048Sha256GenerateKeys
'''
+from __future__ import print_function
import os
import sys
@@ -75,14 +76,14 @@ if __name__ == '__main__':
try:
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(1)
Version = Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print Version[0]
+ print(Version[0])
args.PemFileName = []
@@ -103,7 +104,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.communicate()
if Process.returncode <> 0:
- print 'ERROR: RSA 2048 key generation failed'
+ print('ERROR: RSA 2048 key generation failed')
sys.exit(Process.returncode)
#
@@ -125,7 +126,7 @@ if __name__ == '__main__':
Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()
if Process.returncode <> 0:
- print 'ERROR: Unable to extract public key from private key'
+ print('ERROR: Unable to extract public key from private key')
sys.exit(Process.returncode)
PublicKey = ''
for Index in range (0, len(PublicKeyHexString), 2):
@@ -138,7 +139,7 @@ if __name__ == '__main__':
Process.stdin.write (PublicKey)
PublicKeyHash = PublicKeyHash + Process.communicate()[0]
if Process.returncode <> 0:
- print 'ERROR: Unable to extract SHA 256 hash of public key'
+ print('ERROR: Unable to extract SHA 256 hash of public key')
sys.exit(Process.returncode)
#
@@ -171,4 +172,4 @@ if __name__ == '__main__':
# If verbose is enabled display the public key in C structure format
#
if args.Verbose:
- print 'PublicKeySha256 = ' + PublicKeyHashC
+ print('PublicKeySha256 = ' + PublicKeyHashC)