BaseTools: Handle the bytes and str difference
Deal with bytes and str is different, remove the unicode() Using utcfromtimestamp instead of fromtimestamp. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
a09f4c91f7
commit
86e6cf98a8
@@ -103,7 +103,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])
|
||||
print(Version[0].decode())
|
||||
|
||||
#
|
||||
# Read input file into a buffer and save input filename
|
||||
@@ -151,10 +151,11 @@ 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('=')[1].strip()
|
||||
PublicKeyHexString = Process.communicate()[0].split(b'=')[1].strip()
|
||||
PublicKeyHexString = PublicKeyHexString.decode(encoding='utf-8')
|
||||
PublicKey = ''
|
||||
while len(PublicKeyHexString) > 0:
|
||||
PublicKey = PublicKey + chr(int(PublicKeyHexString[0:2], 16))
|
||||
PublicKey = PublicKey + PublicKeyHexString[0:2]
|
||||
PublicKeyHexString=PublicKeyHexString[2:]
|
||||
if Process.returncode != 0:
|
||||
sys.exit(Process.returncode)
|
||||
@@ -186,7 +187,7 @@ if __name__ == '__main__':
|
||||
#
|
||||
args.OutputFile = open(args.OutputFileName, 'wb')
|
||||
args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.get_bytes_le())
|
||||
args.OutputFile.write(PublicKey)
|
||||
args.OutputFile.write(bytearray.fromhex(PublicKey))
|
||||
args.OutputFile.write(Signature)
|
||||
args.OutputFile.write(args.InputFileBuffer)
|
||||
args.OutputFile.close()
|
||||
@@ -208,7 +209,7 @@ if __name__ == '__main__':
|
||||
#
|
||||
# Verify the public key
|
||||
#
|
||||
if Header.PublicKey != PublicKey:
|
||||
if Header.PublicKey != bytearray.fromhex(PublicKey):
|
||||
print('ERROR: Public key in input file does not match public key from private key file')
|
||||
sys.exit(1)
|
||||
|
||||
|
Reference in New Issue
Block a user