2008-01-10 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Jan 2008 18:33:05 +0000 (18:33 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Jan 2008 18:33:05 +0000 (18:33 -0000)
* AuthenticodeDeformatter.cs: Use RSAManaged and the new overloaded
PKCS1.Verify_v15 with tryNonStandardEncoding == true when verifying
timestamping certificate signatures. Fix for #350958

svn path=/trunk/mcs/; revision=92611

mcs/class/Mono.Security/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
mcs/class/Mono.Security/Mono.Security.Authenticode/ChangeLog

index 78d7081280f1371dca811acecd3f348b0db4e0b3..add98b9c3e3bbd16409dc9f29ffe9ae537e9cd0f 100644 (file)
@@ -33,6 +33,7 @@ using System.Runtime.InteropServices;
 using System.Security;
 using System.Security.Cryptography;
 
+using Mono.Security.Cryptography;
 using Mono.Security.X509;
 
 namespace Mono.Security.Authenticode {
@@ -421,10 +422,13 @@ namespace Mono.Security.Authenticode {
                        byte[] serial = cs.SerialNumber;
                        foreach (X509Certificate x509 in coll) {
                                if (CompareIssuerSerial (issuer, serial, x509)) {
-                                       // don't verify if key size don't match
-                                       if (x509.PublicKey.Length > (counterSignature.Length >> 3)) {
+                                       if (x509.PublicKey.Length > counterSignature.Length) {
                                                RSACryptoServiceProvider rsa = (RSACryptoServiceProvider) x509.RSA;
-                                               if (rsa.VerifyHash (p7hash, hashOID, counterSignature)) {
+                                               // we need to HACK around bad (PKCS#1 1.5) signatures made by Verisign Timestamp Service
+                                               // and this means copying stuff into our own RSAManaged to get the required flexibility
+                                               RSAManaged rsam = new RSAManaged ();
+                                               rsam.ImportParameters (rsa.ExportParameters (false));
+                                               if (PKCS1.Verify_v15 (rsam, ha, p7hash, counterSignature, true)) {
                                                        timestampChain.LoadCertificates (coll);
                                                        return (timestampChain.Build (x509));
                                                }
index 3907ff4a897937bf469ebbbb1c2ac6895dc0d840..ac3315e2539c265aeb7f78864c6ec7ac48f5fc46 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AuthenticodeDeformatter.cs: Use RSAManaged and the new overloaded
+       PKCS1.Verify_v15 with tryNonStandardEncoding == true when verifying
+       timestamping certificate signatures. Fix for #350958
+
 2007-11-01  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AuthenticodeFormatter.cs: Allow signature of very big files (e.g. a