BaseTools: Handle the bytes and str difference
Deal with bytes and str is different, remove the unicode(), correct open file parameter. Using utcfromtimestamp instead of fromtimestamp. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
@ -105,7 +105,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('utf-8'))
|
||||
|
||||
#
|
||||
# Read input file into a buffer and save input filename
|
||||
@ -153,7 +153,8 @@ 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('utf-8')
|
||||
PublicKey = ''
|
||||
while len(PublicKeyHexString) > 0:
|
||||
PublicKey = PublicKey + PublicKeyHexString[0:2]
|
||||
@ -210,7 +211,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