private static unsafe XmlDocument GetManifestXml(ActivationContext application, ManifestKinds manifest) { IStream applicationComponentManifest = null; if (manifest == ManifestKinds.Application) { applicationComponentManifest = InternalActivationContextHelper.GetApplicationComponentManifest(application) as IStream; } else if (manifest == ManifestKinds.Deployment) { applicationComponentManifest = InternalActivationContextHelper.GetDeploymentComponentManifest(application) as IStream; } using (MemoryStream stream2 = new MemoryStream()) { byte[] pv = new byte[0x1000]; int count = 0; do { applicationComponentManifest.Read(pv, pv.Length, new IntPtr((void*) &count)); stream2.Write(pv, 0, count); } while (count == pv.Length); stream2.Position = 0L; XmlDocument document = new XmlDocument { PreserveWhitespace = true }; document.Load(stream2); return document; } }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests, X509RevocationFlag revocationFlag, X509RevocationMode revocationMode) { if (application == null) { throw new ArgumentNullException("application"); } if ((revocationFlag < X509RevocationFlag.EndCertificateOnly) || (X509RevocationFlag.ExcludeRoot < revocationFlag)) { throw new ArgumentOutOfRangeException("revocationFlag"); } if ((revocationMode < X509RevocationMode.NoCheck) || (X509RevocationMode.Offline < revocationMode)) { throw new ArgumentOutOfRangeException("revocationMode"); } List<ManifestSignatureInformation> signatureInformation = new List<ManifestSignatureInformation>(); if ((manifests & ManifestKinds.Deployment) == ManifestKinds.Deployment) { ManifestSignedXml xml = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Deployment), ManifestKinds.Deployment); signatureInformation.Add(xml.VerifySignature(revocationFlag, revocationMode)); } if ((manifests & ManifestKinds.Application) == ManifestKinds.Application) { ManifestSignedXml xml2 = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Application), ManifestKinds.Application); signatureInformation.Add(xml2.VerifySignature(revocationFlag, revocationMode)); } return new ManifestSignatureInformationCollection(signatureInformation); }
/// <summary> /// Verify and gather information about the signatures of the specified manifests /// </summary> public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests) { return(VerifySignature(application, manifests, X509RevocationFlag.ExcludeRoot, X509RevocationMode.Online)); }
internal ManifestSignatureInformation(ManifestKinds manifest, StrongNameSignatureInformation strongNameSignature, AuthenticodeSignatureInformation authenticodeSignature) { Debug.Assert(manifest == ManifestKinds.Application || manifest == ManifestKinds.Deployment, "Invalid manifest for signature information"); m_manifest = manifest; m_strongNameSignature = strongNameSignature; m_authenticodeSignature = authenticodeSignature; }
public ManifestSignedXml(XmlDocument manifestXml, ManifestKinds manifest) : base(manifestXml) { this.m_manifest = manifest; this.m_manifestXml = manifestXml; this.m_namespaceManager = new XmlNamespaceManager(manifestXml.NameTable); this.m_namespaceManager.AddNamespace("as", "http://schemas.microsoft.com/windows/pki/2005/Authenticode"); this.m_namespaceManager.AddNamespace("asm", "urn:schemas-microsoft-com:asm.v1"); this.m_namespaceManager.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2"); this.m_namespaceManager.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#"); this.m_namespaceManager.AddNamespace("msrel", "http://schemas.microsoft.com/windows/rel/2005/reldata"); this.m_namespaceManager.AddNamespace("r", "urn:mpeg:mpeg21:2003:01-REL-R-NS"); }
public ManifestSignedXml(XmlDocument manifestXml, ManifestKinds manifest) : base(manifestXml) { Debug.Assert(manifestXml != null, "manifestXml != null"); Debug.Assert(manifest == ManifestKinds.Application || manifest == ManifestKinds.Deployment, "Unknown manifest kind"); m_manifest = manifest; m_manifestXml = manifestXml; m_namespaceManager = new XmlNamespaceManager(manifestXml.NameTable); m_namespaceManager.AddNamespace("as", "http://schemas.microsoft.com/windows/pki/2005/Authenticode"); m_namespaceManager.AddNamespace("asm", "urn:schemas-microsoft-com:asm.v1"); m_namespaceManager.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2"); m_namespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl); m_namespaceManager.AddNamespace("msrel", "http://schemas.microsoft.com/windows/rel/2005/reldata"); m_namespaceManager.AddNamespace("r", "urn:mpeg:mpeg21:2003:01-REL-R-NS"); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests, X509RevocationFlag revocationFlag, X509RevocationMode revocationMode) { if (application == null) { throw new ArgumentNullException("application"); } if (revocationFlag < X509RevocationFlag.EndCertificateOnly || X509RevocationFlag.ExcludeRoot < revocationFlag) { throw new ArgumentOutOfRangeException("revocationFlag"); } if (revocationMode < X509RevocationMode.NoCheck || X509RevocationMode.Offline < revocationMode) { throw new ArgumentOutOfRangeException("revocationMode"); } List <ManifestSignatureInformation> signatures = new List <ManifestSignatureInformation>(); if ((manifests & ManifestKinds.Deployment) == ManifestKinds.Deployment) { XmlDocument deploymentManifest = GetManifestXml(application, ManifestKinds.Deployment); ManifestSignedXml deploymentSignature = new ManifestSignedXml(deploymentManifest, ManifestKinds.Deployment); signatures.Add(deploymentSignature.VerifySignature(revocationFlag, revocationMode)); } if ((manifests & ManifestKinds.Application) == ManifestKinds.Application) { XmlDocument applicationManifest = GetManifestXml(application, ManifestKinds.Application); ManifestSignedXml applicationSignature = new ManifestSignedXml(applicationManifest, ManifestKinds.Application); signatures.Add(applicationSignature.VerifySignature(revocationFlag, revocationMode)); } return(new ManifestSignatureInformationCollection(signatures)); }
private static XmlDocument GetManifestXml(ActivationContext application, ManifestKinds manifest) { Debug.Assert(application != null, "application != null"); IStream manifestStream = null; if (manifest == ManifestKinds.Application) { manifestStream = InternalActivationContextHelper.GetApplicationComponentManifest(application) as IStream; } else if (manifest == ManifestKinds.Deployment) { manifestStream = InternalActivationContextHelper.GetDeploymentComponentManifest(application) as IStream; } Debug.Assert(manifestStream != null, "Cannot get stream for manifest"); using (MemoryStream manifestContent = new MemoryStream()) { byte[] buffer = new byte[4096]; int bytesRead = 0; do { unsafe { manifestStream.Read(buffer, buffer.Length, new IntPtr(&bytesRead)); } manifestContent.Write(buffer, 0, bytesRead); }while (bytesRead == buffer.Length); manifestContent.Position = 0; XmlDocument manifestXml = new XmlDocument(); manifestXml.PreserveWhitespace = true; manifestXml.Load(manifestContent); return(manifestXml); } }
internal ManifestSignatureInformation(ManifestKinds manifest, StrongNameSignatureInformation strongNameSignature, AuthenticodeSignatureInformation authenticodeSignature) { this.m_manifest = manifest; this.m_strongNameSignature = strongNameSignature; this.m_authenticodeSignature = authenticodeSignature; }
private static unsafe XmlDocument GetManifestXml(ActivationContext application, ManifestKinds manifest) { IStream applicationComponentManifest = null; if (manifest == ManifestKinds.Application) { applicationComponentManifest = InternalActivationContextHelper.GetApplicationComponentManifest(application) as IStream; } else if (manifest == ManifestKinds.Deployment) { applicationComponentManifest = InternalActivationContextHelper.GetDeploymentComponentManifest(application) as IStream; } using (MemoryStream stream2 = new MemoryStream()) { byte[] pv = new byte[0x1000]; int count = 0; do { applicationComponentManifest.Read(pv, pv.Length, new IntPtr((void *)&count)); stream2.Write(pv, 0, count); }while (count == pv.Length); stream2.Position = 0L; XmlDocument document = new XmlDocument { PreserveWhitespace = true }; document.Load(stream2); return(document); } }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests, X509RevocationFlag revocationFlag, X509RevocationMode revocationMode) { if (application == null) { throw new ArgumentNullException("application"); } if ((revocationFlag < X509RevocationFlag.EndCertificateOnly) || (X509RevocationFlag.ExcludeRoot < revocationFlag)) { throw new ArgumentOutOfRangeException("revocationFlag"); } if ((revocationMode < X509RevocationMode.NoCheck) || (X509RevocationMode.Offline < revocationMode)) { throw new ArgumentOutOfRangeException("revocationMode"); } List <ManifestSignatureInformation> signatureInformation = new List <ManifestSignatureInformation>(); if ((manifests & ManifestKinds.Deployment) == ManifestKinds.Deployment) { ManifestSignedXml xml = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Deployment), ManifestKinds.Deployment); signatureInformation.Add(xml.VerifySignature(revocationFlag, revocationMode)); } if ((manifests & ManifestKinds.Application) == ManifestKinds.Application) { ManifestSignedXml xml2 = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Application), ManifestKinds.Application); signatureInformation.Add(xml2.VerifySignature(revocationFlag, revocationMode)); } return(new ManifestSignatureInformationCollection(signatureInformation)); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests) { throw new NotImplementedException(); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests) { return VerifySignature(application, manifests, X509RevocationFlag.ExcludeRoot, X509RevocationMode.Online); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests, X509RevocationFlag revocationFlag, X509RevocationMode revocationMode) { throw new NotImplementedException(); }