]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Update Pkcs7 and RSA2048 tool with shell=True
authorYonghong Zhu <yonghong.zhu@intel.com>
Tue, 28 Mar 2017 07:04:13 +0000 (15:04 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 29 Mar 2017 08:45:24 +0000 (16:45 +0800)
Pkcs7Sign, Rsa2048Sha256Sign and Rsa2048Sha256GenerateKeys doesn't work
on Linux. It needs to be changed with shell=True.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py

index 6412587e4ba52eb4f253fb0aaba3dc8fec384a51..ef79f80eddf39377379a2dfed54b82e6309fadc7 100644 (file)
@@ -203,7 +203,7 @@ if __name__ == '__main__':
     #\r
     # Sign the input file using the specified private key and capture signature from STDOUT\r
     #\r
-    Process = subprocess.Popen('%s smime -sign -binary -signer "%s" -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCertFileName, args.OtherPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s smime -sign -binary -signer "%s" -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCertFileName, args.OtherPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Signature = Process.communicate(input=FullInputFileBuffer)[0]\r
     if Process.returncode <> 0:\r
       sys.exit(Process.returncode)\r
@@ -272,7 +272,7 @@ if __name__ == '__main__':
     #\r
     # Verify signature\r
     #\r
-    Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.communicate(input=args.SignatureBuffer)[0]\r
     if Process.returncode <> 0:\r
       print 'ERROR: Verification failed'\r
index 2dd6c201683334cb6a82b28f75bf16d249e7172d..df2d9896ca2661c49b0a8a2931eaaa2761ba3ea6 100644 (file)
@@ -98,7 +98,7 @@ if __name__ == '__main__':
       #\r
       # Generate private key and save it to output file in a PEM file format\r
       #\r
-      Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+      Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
       Process.communicate()\r
       if Process.returncode <> 0:\r
         print 'ERROR: RSA 2048 key generation failed'\r
@@ -120,7 +120,7 @@ if __name__ == '__main__':
     #\r
     # Extract public key from private key into STDOUT\r
     #\r
-    Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()\r
     if Process.returncode <> 0:\r
       print 'ERROR: Unable to extract public key from private key'\r
@@ -132,7 +132,7 @@ if __name__ == '__main__':
     #\r
     # Generate SHA 256 hash of RSA 2048 bit public key into STDOUT\r
     #\r
-    Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.stdin.write (PublicKey)\r
     PublicKeyHash = PublicKeyHash + Process.communicate()[0]\r
     if Process.returncode <> 0:\r
index 952583cf4bb00fa2ef67b15d04c7c328df94bccd..4367194c23b191ce25330160a0abfa3ad28367af 100644 (file)
@@ -148,7 +148,7 @@ if __name__ == '__main__':
   #\r
   # Extract public key from private key into STDOUT\r
   #\r
-  Process = subprocess.Popen('%s rsa -in "%s" -modulus -noout' % (OpenSslCommand, args.PrivateKeyFileName), stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+  Process = subprocess.Popen('%s rsa -in "%s" -modulus -noout' % (OpenSslCommand, args.PrivateKeyFileName), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
   PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()\r
   PublicKey = ''\r
   while len(PublicKeyHexString) > 0:\r
@@ -174,7 +174,7 @@ if __name__ == '__main__':
     # \r
     # Sign the input file using the specified private key and capture signature from STDOUT\r
     #\r
-    Process = subprocess.Popen('%s sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Signature = Process.communicate(input=FullInputFileBuffer)[0]\r
     if Process.returncode <> 0:\r
       sys.exit(Process.returncode)\r
@@ -223,7 +223,7 @@ if __name__ == '__main__':
     #\r
     # Verify signature\r
     #    \r
-    Process = subprocess.Popen('%s sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    Process = subprocess.Popen('%s sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.communicate(input=FullInputFileBuffer)\r
     if Process.returncode <> 0:\r
       print 'ERROR: Verification failed'\r