protected internal File(string name, ulong size) { this._hashCollection = new System.Deployment.Application.HashCollection(); this._name = name; this._size = size; this._nameFS = UriHelper.NormalizePathDirectorySeparators(this._name); }
public static void VerifyFileHash(string filePath, HashCollection hashCollection) { string fileName = Path.GetFileName(filePath); if (hashCollection.Count == 0) { if (!PolicyKeys.RequireHashInManifests()) { Logger.AddWarningInformation(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("NoHashFile"), new object[1] { (object)fileName })); } else { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_HashNotSpecified"), new object[1] { (object)fileName })); } } foreach (Hash hash in hashCollection) { ComponentVerifier.VerifyFileHash(filePath, hash); } }
public File(string name, byte[] hash, ulong size) { this._hashCollection = new System.Deployment.Application.HashCollection(); this._name = name; this._hashCollection.AddHash(hash, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); this._size = size; this._nameFS = UriHelper.NormalizePathDirectorySeparators(this._name); }
public static bool IsVerifiableHashCollection(HashCollection hashCollection) { foreach (Hash hash in hashCollection) { if (!ComponentVerifier.IsVerifiableHash(hash)) { return(false); } } return(true); }
public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry) { this._hashCollection = new System.Deployment.Application.HashCollection(); System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly; this._size = dependentAssembly.Size; this._codebase = dependentAssembly.Codebase; this._group = dependentAssembly.Group; bool flag = false; System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements; uint celt = (hashElements != null) ? hashElements.Count : 0; if (celt > 0) { uint celtFetched = 0; System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt]; System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum; Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched)); if (celtFetched != celt) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount")); } for (uint i = 0; i < celt; i++) { System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData; if (allData.DigestValueSize > 0) { byte[] destination = new byte[allData.DigestValueSize]; Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize); this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform); flag = true; } } } if (!flag && (dependentAssembly.HashValueSize > 0)) { byte[] buffer2 = new byte[dependentAssembly.HashValueSize]; Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int)dependentAssembly.HashValueSize); this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); } this._preRequisite = (dependentAssembly.Flags & 4) != 0; this._optional = (assemblyReferenceEntry.Flags & 1) != 0; this._visible = (dependentAssembly.Flags & 2) != 0; this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0; this._resourceFallbackCulture = dependentAssembly.ResourceFallbackCulture; this._description = dependentAssembly.Description; this._supportUrl = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid"); System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity; this._identity = new System.Deployment.Application.ReferenceIdentity(referenceIdentity); this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase); }
public static bool IsVerifiableHashCollection(HashCollection hashCollection) { using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator()) { while (enumerator.MoveNext()) { if (!IsVerifiableHash(enumerator.Current)) { return(false); } } } return(true); }
public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry) { this._hashCollection = new System.Deployment.Application.HashCollection(); System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly; this._size = dependentAssembly.Size; this._codebase = dependentAssembly.Codebase; this._group = dependentAssembly.Group; bool flag = false; System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements; uint celt = (hashElements != null) ? hashElements.Count : 0; if (celt > 0) { uint celtFetched = 0; System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt]; System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown) hashElements._NewEnum; Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched)); if (celtFetched != celt) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount")); } for (uint i = 0; i < celt; i++) { System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData; if (allData.DigestValueSize > 0) { byte[] destination = new byte[allData.DigestValueSize]; Marshal.Copy(allData.DigestValue, destination, 0, (int) allData.DigestValueSize); this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM) allData.Transform); flag = true; } } } if (!flag && (dependentAssembly.HashValueSize > 0)) { byte[] buffer2 = new byte[dependentAssembly.HashValueSize]; Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int) dependentAssembly.HashValueSize); this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); } this._preRequisite = (dependentAssembly.Flags & 4) != 0; this._optional = (assemblyReferenceEntry.Flags & 1) != 0; this._visible = (dependentAssembly.Flags & 2) != 0; this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0; this._resourceFallbackCulture = dependentAssembly.ResourceFallbackCulture; this._description = dependentAssembly.Description; this._supportUrl = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid"); System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity; this._identity = new System.Deployment.Application.ReferenceIdentity(referenceIdentity); this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase); }
public void AddFile(Uri sourceUri, string targetFilePath, object cookie, HashCollection hashCollection, int maxFileSize) { UriHelper.ValidateSupportedScheme(sourceUri); FileDownloader.DownloadQueueItem downloadQueueItem = new FileDownloader.DownloadQueueItem(); downloadQueueItem._sourceUri = sourceUri; downloadQueueItem._targetPath = targetFilePath; downloadQueueItem._cookie = cookie; downloadQueueItem._hashCollection = hashCollection; downloadQueueItem._maxFileSize = maxFileSize; lock (this._fileQueue) { this._fileQueue.Enqueue((object)downloadQueueItem); ++this._eventArgs._filesTotal; } }
public void AddFile(Uri sourceUri, string targetFilePath, object cookie, HashCollection hashCollection, int maxFileSize) { UriHelper.ValidateSupportedScheme(sourceUri); DownloadQueueItem item = new DownloadQueueItem { _sourceUri = sourceUri, _targetPath = targetFilePath, _cookie = cookie, _hashCollection = hashCollection, _maxFileSize = maxFileSize }; lock (this._fileQueue) { this._fileQueue.Enqueue(item); this._eventArgs._filesTotal++; } }
private static bool FileHashVerified(HashCollection hashCollection, string location) { try { ComponentVerifier.VerifyFileHash(location, hashCollection); } catch (InvalidDeploymentException ex) { if (ex.SubType == ExceptionTypes.HashValidation) { return(false); } throw; } return(true); }
private static bool AddSingleFileInHashtable(Hashtable hashtable, HashCollection hashCollection, string location) { bool flag = false; if (System.IO.File.Exists(location)) { foreach (Hash hash in hashCollection) { string compositString = hash.CompositString; if (!hashtable.Contains((object)compositString)) { hashtable.Add((object)compositString, (object)location); flag = true; } } } return(flag); }
public File(System.Deployment.Internal.Isolation.Manifest.FileEntry fileEntry) { this._hashCollection = new System.Deployment.Application.HashCollection(); this._name = fileEntry.Name; this._loadFrom = fileEntry.LoadFrom; this._size = fileEntry.Size; this._group = fileEntry.Group; this._optional = (fileEntry.Flags & 1) != 0; this._isData = (fileEntry.WritableType & 2) != 0; bool flag = false; System.Deployment.Internal.Isolation.ISection hashElements = fileEntry.HashElements; uint celt = (hashElements != null) ? hashElements.Count : 0; if (celt > 0) { uint celtFetched = 0; System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt]; System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum; Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched)); if (celtFetched != celt) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount")); } for (uint i = 0; i < celt; i++) { System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData; if (allData.DigestValueSize > 0) { byte[] destination = new byte[allData.DigestValueSize]; Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize); this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform); flag = true; } } } if (!flag && (fileEntry.HashValueSize > 0)) { byte[] buffer2 = new byte[fileEntry.HashValueSize]; Marshal.Copy(fileEntry.HashValue, buffer2, 0, (int)fileEntry.HashValueSize); this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)fileEntry.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); } this._nameFS = UriHelper.NormalizePathDirectorySeparators(this._name); }
public File(System.Deployment.Internal.Isolation.Manifest.FileEntry fileEntry) { this._hashCollection = new System.Deployment.Application.HashCollection(); this._name = fileEntry.Name; this._loadFrom = fileEntry.LoadFrom; this._size = fileEntry.Size; this._group = fileEntry.Group; this._optional = (fileEntry.Flags & 1) != 0; this._isData = (fileEntry.WritableType & 2) != 0; bool flag = false; System.Deployment.Internal.Isolation.ISection hashElements = fileEntry.HashElements; uint celt = (hashElements != null) ? hashElements.Count : 0; if (celt > 0) { uint celtFetched = 0; System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt]; System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown) hashElements._NewEnum; Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched)); if (celtFetched != celt) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount")); } for (uint i = 0; i < celt; i++) { System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData; if (allData.DigestValueSize > 0) { byte[] destination = new byte[allData.DigestValueSize]; Marshal.Copy(allData.DigestValue, destination, 0, (int) allData.DigestValueSize); this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM) allData.Transform); flag = true; } } } if (!flag && (fileEntry.HashValueSize > 0)) { byte[] buffer2 = new byte[fileEntry.HashValueSize]; Marshal.Copy(fileEntry.HashValue, buffer2, 0, (int) fileEntry.HashValueSize); this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) fileEntry.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); } this._nameFS = UriHelper.NormalizePathDirectorySeparators(this._name); }
private static bool AddSingleFileInHashtable(Hashtable hashtable, HashCollection hashCollection, string location) { bool flag = false; if (System.IO.File.Exists(location)) { using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator()) { while (enumerator.MoveNext()) { string compositString = enumerator.Current.CompositString; if (!hashtable.Contains(compositString)) { hashtable.Add(compositString, location); flag = true; } } } } return(flag); }
public HashEnumerator(HashCollection hashCollection) { this._hashCollection = hashCollection; this._index = -1; }
public DependentAssembly(System.Deployment.Application.ReferenceIdentity refId) { this._hashCollection = new System.Deployment.Application.HashCollection(); this._identity = refId; }
public FileComponent(string filePath, HashCollection hashCollection) { this._filePath = filePath; this._hashCollection = hashCollection; }
private static bool IsInvalidHash(HashCollection hashCollection) { return !ComponentVerifier.IsVerifiableHashCollection(hashCollection); }
private static void AddFileToDownloader(FileDownloader downloader, AssemblyManifest deployManifest, AssemblyManifest appManifest, object manifestElement, Uri fileSourceUri, string targetDirectory, string targetFileName, HashCollection hashCollection) { string targetFilePath = Path.Combine(targetDirectory, targetFileName); DependencyDownloadCookie cookie = new DependencyDownloadCookie(manifestElement, deployManifest, appManifest); downloader.AddFile(fileSourceUri, targetFilePath, cookie, hashCollection); }
private static void AddFileToDownloader(FileDownloader downloader, AssemblyManifest deployManifest, AssemblyManifest appManifest, object manifestElement, Uri fileSourceUri, string targetDirectory, string targetFileName, HashCollection hashCollection) { string targetFilePath = Path.Combine(targetDirectory, targetFileName); DownloadManager.DependencyDownloadCookie dependencyDownloadCookie = new DownloadManager.DependencyDownloadCookie(manifestElement, deployManifest, appManifest); downloader.AddFile(fileSourceUri, targetFilePath, (object)dependencyDownloadCookie, hashCollection); }
public void AddFile(Uri sourceUri, string targetFilePath, object cookie, HashCollection hashCollection) { this.AddFile(sourceUri, targetFilePath, cookie, hashCollection, -1); }
public void AddFileForVerification(string filePath, HashCollection verificationHashCollection) { FileComponent component = new FileComponent(filePath, verificationHashCollection); this._verificationComponents.Add(component); }
public void AddFileForVerification(string filePath, HashCollection verificationHashCollection) { this._verificationComponents.Add((object)new ComponentVerifier.FileComponent(filePath, verificationHashCollection)); }
public static void VerifyFileHash(string filePath, HashCollection hashCollection) { string fileName = Path.GetFileName(filePath); if (hashCollection.Count == 0) { if (PolicyKeys.RequireHashInManifests()) { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_HashNotSpecified"), new object[] { fileName })); } Logger.AddWarningInformation(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("NoHashFile"), new object[] { fileName })); } foreach (Hash hash in hashCollection) { VerifyFileHash(filePath, hash); } }
private static bool AddSingleFileInHashtable(Hashtable hashtable, HashCollection hashCollection, string location) { bool flag = false; if (System.IO.File.Exists(location)) { using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator()) { while (enumerator.MoveNext()) { string compositString = enumerator.Current.CompositString; if (!hashtable.Contains(compositString)) { hashtable.Add(compositString, location); flag = true; } } } } return flag; }
private static bool FileHashVerified(HashCollection hashCollection, string location) { try { System.Deployment.Application.ComponentVerifier.VerifyFileHash(location, hashCollection); } catch (InvalidDeploymentException exception) { if (exception.SubType != ExceptionTypes.HashValidation) { throw; } return false; } return true; }
public static bool IsVerifiableHashCollection(HashCollection hashCollection) { using (HashCollection.HashEnumerator enumerator = hashCollection.GetEnumerator()) { while (enumerator.MoveNext()) { if (!IsVerifiableHash(enumerator.Current)) { return false; } } } return true; }