private static List <IStorage> ToStorageList(IvfcHeader header, IStorage masterHash, IStorage data, bool leaveOpen) { var levels = new List <IStorage> { masterHash }; for (int i = 0; i < header.NumLevels - 1; i++) { IvfcLevelHeader level = header.LevelHeaders[i]; levels.Add(data.Slice(level.Offset, level.Size, leaveOpen)); } return(levels); }
private static IntegrityVerificationInfo[] GetIvfcInfo(IvfcHeader ivfc, IList <IStorage> levels, IntegrityStorageType type) { var initInfo = new IntegrityVerificationInfo[ivfc.NumLevels]; initInfo[0] = new IntegrityVerificationInfo { Data = levels[0], BlockSize = 0 }; for (int i = 1; i < ivfc.NumLevels; i++) { initInfo[i] = new IntegrityVerificationInfo { Data = levels[i], BlockSize = 1 << ivfc.LevelHeaders[i - 1].BlockSizePower, Salt = new HMACSHA256(Encoding.ASCII.GetBytes(SaltSources[i - 1])).ComputeHash(ivfc.SaltSource), Type = type }; } return(initInfo); }
public HierarchicalIntegrityVerificationStorage(IvfcHeader header, IStorage masterHash, IStorage data, IntegrityStorageType type, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen) : this(header, ToStorageList(header, masterHash, data, leaveOpen), type, integrityCheckLevel, leaveOpen) { }
public HierarchicalIntegrityVerificationStorage(IvfcHeader header, IList <IStorage> levels, IntegrityStorageType type, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen) : this(GetIvfcInfo(header, levels, type), integrityCheckLevel, leaveOpen) { }
internal static void SetLevelValidities(this HierarchicalIntegrityVerificationStorage stream, IvfcHeader header) { for (int i = 0; i < stream.Levels.Length - 1; i++) { Validity[] level = stream.LevelValidities[i]; var levelValidity = Validity.Valid; foreach (Validity block in level) { if (block == Validity.Invalid) { levelValidity = Validity.Invalid; break; } if (block == Validity.Unchecked && levelValidity != Validity.Invalid) { levelValidity = Validity.Unchecked; } } header.LevelHeaders[i].HashValidity = levelValidity; } }