internal CmiAuthenticodeTimestamperInfo(System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
        {
            this.m_error   = (int)timestamperInfo.dwError;
            this.m_algHash = timestamperInfo.algHash;
            long fileTime = (long)((((ulong)timestamperInfo.ftTimestamp.dwHighDateTime) << 0x20) | ((ulong)timestamperInfo.ftTimestamp.dwLowDateTime));

            this.m_timestampTime = DateTime.FromFileTime(fileTime);
            if (timestamperInfo.pChainContext != IntPtr.Zero)
            {
                this.m_timestamperChain = new X509Chain(timestamperInfo.pChainContext);
            }
        }
Exemple #2
0
        private unsafe void VerifyLicense(System.Deployment.Internal.CodeSigning.CmiManifestVerifyFlags verifyFlags, bool oldFormat)
        {
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(this.m_manifestDom.NameTable);

            nsmgr.AddNamespace("asm", "urn:schemas-microsoft-com:asm.v1");
            nsmgr.AddNamespace("asm2", "urn:schemas-microsoft-com:asm.v2");
            nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
            nsmgr.AddNamespace("msrel", "http://schemas.microsoft.com/windows/rel/2005/reldata");
            nsmgr.AddNamespace("r", "urn:mpeg:mpeg21:2003:01-REL-R-NS");
            nsmgr.AddNamespace("as", "http://schemas.microsoft.com/windows/pki/2005/Authenticode");
            XmlElement element = this.m_manifestDom.SelectSingleNode("asm:assembly/ds:Signature/ds:KeyInfo/msrel:RelData/r:license", nsmgr) as XmlElement;

            if (element != null)
            {
                this.VerifyAssemblyIdentity(nsmgr);
                this.m_authenticodeSignerInfo = new System.Deployment.Internal.CodeSigning.CmiAuthenticodeSignerInfo(-2146762485);
                byte[] bytes = Encoding.UTF8.GetBytes(element.OuterXml);
                fixed(byte *numRef = bytes)
                {
                    System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO pSignerInfo = new System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO {
                        cbSize = (uint)Marshal.SizeOf(typeof(System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO))
                    };
                    System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO pTimestamperInfo = new System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO {
                        cbSize = (uint)Marshal.SizeOf(typeof(System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO))
                    };
                    System.Deployment.Internal.CodeSigning.Win32.CRYPT_DATA_BLOB pLicenseBlob = new System.Deployment.Internal.CodeSigning.Win32.CRYPT_DATA_BLOB();
                    IntPtr ptr = new IntPtr((void *)numRef);

                    pLicenseBlob.cbData = (uint)bytes.Length;
                    pLicenseBlob.pbData = ptr;
                    int hr = System.Deployment.Internal.CodeSigning.Win32.CertVerifyAuthenticodeLicense(ref pLicenseBlob, (uint)verifyFlags, ref pSignerInfo, ref pTimestamperInfo);

                    if (0x800b0100 != pSignerInfo.dwError)
                    {
                        this.m_authenticodeSignerInfo = new System.Deployment.Internal.CodeSigning.CmiAuthenticodeSignerInfo(pSignerInfo, pTimestamperInfo);
                    }
                    System.Deployment.Internal.CodeSigning.Win32.CertFreeAuthenticodeSignerInfo(ref pSignerInfo);
                    System.Deployment.Internal.CodeSigning.Win32.CertFreeAuthenticodeTimestamperInfo(ref pTimestamperInfo);
                    if (hr != 0)
                    {
                        throw new CryptographicException(hr);
                    }
                }

                if (!oldFormat)
                {
                    this.VerifyPublisherIdentity(nsmgr);
                }
            }
        }
 private unsafe void VerifyLicense(System.Deployment.Internal.CodeSigning.CmiManifestVerifyFlags verifyFlags, bool oldFormat)
 {
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(this.m_manifestDom.NameTable);
     nsmgr.AddNamespace("asm", "urn:schemas-microsoft-com:asm.v1");
     nsmgr.AddNamespace("asm2", "urn:schemas-microsoft-com:asm.v2");
     nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
     nsmgr.AddNamespace("msrel", "http://schemas.microsoft.com/windows/rel/2005/reldata");
     nsmgr.AddNamespace("r", "urn:mpeg:mpeg21:2003:01-REL-R-NS");
     nsmgr.AddNamespace("as", "http://schemas.microsoft.com/windows/pki/2005/Authenticode");
     XmlElement element = this.m_manifestDom.SelectSingleNode("asm:assembly/ds:Signature/ds:KeyInfo/msrel:RelData/r:license", nsmgr) as XmlElement;
     if (element != null)
     {
         this.VerifyAssemblyIdentity(nsmgr);
         this.m_authenticodeSignerInfo = new System.Deployment.Internal.CodeSigning.CmiAuthenticodeSignerInfo(-2146762485);
         byte[] bytes = Encoding.UTF8.GetBytes(element.OuterXml);
         fixed (byte* numRef = bytes)
         {
             System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO pSignerInfo = new System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO {
                 cbSize = (uint) Marshal.SizeOf(typeof(System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO))
             };
             System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO pTimestamperInfo = new System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO {
                 cbSize = (uint) Marshal.SizeOf(typeof(System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO))
             };
             System.Deployment.Internal.CodeSigning.Win32.CRYPT_DATA_BLOB pLicenseBlob = new System.Deployment.Internal.CodeSigning.Win32.CRYPT_DATA_BLOB();
             IntPtr ptr = new IntPtr((void*) numRef);
             pLicenseBlob.cbData = (uint) bytes.Length;
             pLicenseBlob.pbData = ptr;
             int hr = System.Deployment.Internal.CodeSigning.Win32.CertVerifyAuthenticodeLicense(ref pLicenseBlob, (uint) verifyFlags, ref pSignerInfo, ref pTimestamperInfo);
             if (0x800b0100 != pSignerInfo.dwError)
             {
                 this.m_authenticodeSignerInfo = new System.Deployment.Internal.CodeSigning.CmiAuthenticodeSignerInfo(pSignerInfo, pTimestamperInfo);
             }
             System.Deployment.Internal.CodeSigning.Win32.CertFreeAuthenticodeSignerInfo(ref pSignerInfo);
             System.Deployment.Internal.CodeSigning.Win32.CertFreeAuthenticodeTimestamperInfo(ref pTimestamperInfo);
             if (hr != 0)
             {
                 throw new CryptographicException(hr);
             }
         }
         if (!oldFormat)
         {
             this.VerifyPublisherIdentity(nsmgr);
         }
     }
 }
 internal CmiAuthenticodeSignerInfo(System.Deployment.Internal.CodeSigning.Win32.AXL_SIGNER_INFO signerInfo, System.Deployment.Internal.CodeSigning.Win32.AXL_TIMESTAMPER_INFO timestamperInfo)
 {
     this.m_error = (int)signerInfo.dwError;
     if (signerInfo.pChainContext != IntPtr.Zero)
     {
         this.m_signerChain = new X509Chain(signerInfo.pChainContext);
     }
     this.m_algHash = signerInfo.algHash;
     if (signerInfo.pwszHash != IntPtr.Zero)
     {
         this.m_hash = Marshal.PtrToStringUni(signerInfo.pwszHash);
     }
     if (signerInfo.pwszDescription != IntPtr.Zero)
     {
         this.m_description = Marshal.PtrToStringUni(signerInfo.pwszDescription);
     }
     if (signerInfo.pwszDescriptionUrl != IntPtr.Zero)
     {
         this.m_descriptionUrl = Marshal.PtrToStringUni(signerInfo.pwszDescriptionUrl);
     }
     if (timestamperInfo.dwError != 0x800b0100)
     {
         this.m_timestamperInfo = new System.Deployment.Internal.CodeSigning.CmiAuthenticodeTimestamperInfo(timestamperInfo);
     }
 }